Package com.teamdev.jxbrowser.frame
Interface WebStorage
public interface WebStorage
An HTML WebStorage.
Provides access to the session storage or local storage for a particular document on the loaded web page. Allows you to add, modify, or delete the stored items.
- Since:
- 7.1
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all the items from the storage.booleanReturnstrueif the storage contains an item with the specifiedkey, otherwisefalse.Returns anOptionalthat contains the value associated with the givenkeyif it exists in the storage, otherwise an emptyOptional.key(int index) Returns anOptionalthat contains the name of the key by the specifiedindexif it exists in the storage, otherwise an emptyOptional.intlength()Returns the number of key/value pairs in the storage.voidAdds the item with the specifiedkeyandvalueto the storage, or updates it if the item with the givenkeyalready exists.voidremoveItem(String key) Removes the item with the specifiedkeyfrom the storage.
-
Method Details
-
length
int length()Returns the number of key/value pairs in the storage.- Throws:
ObjectClosedException- when the frame is closedWebStorageSecurityException- if the access to the storage is forbidden for the current document
-
key
Returns anOptionalthat contains the name of the key by the specifiedindexif it exists in the storage, otherwise an emptyOptional. The order of keys is not specified and may change as you add or remove items to the storage.- Parameters:
index- the index of the key to get the name of. Must be in range0 <= index < length()- Throws:
IllegalArgumentException- when theindexis not in the0 <= index < length()rangeObjectClosedException- when the frame is closedWebStorageSecurityException- if the access to the storage is forbidden for the current document
-
item
Returns anOptionalthat contains the value associated with the givenkeyif it exists in the storage, otherwise an emptyOptional.- Parameters:
key- the key name of the item to retrieve the value of. Can be empty or blank- Throws:
ObjectClosedException- when the frame is closedWebStorageSecurityException- if the access to the storage is forbidden for the current document
-
putItem
Adds the item with the specifiedkeyandvalueto the storage, or updates it if the item with the givenkeyalready exists.- Parameters:
key- the key name of the item to put. Can be empty or blankvalue- the value of the item to put. Can be empty or blank- Throws:
ObjectClosedException- when the frame is closedWebStorageOverflowException- when if the item size exceeds the available space in the storageWebStorageSecurityException- if the access to the storage is forbidden for the current document
-
removeItem
Removes the item with the specifiedkeyfrom the storage. Does nothing if there is no item with the specifiedkeyin the storage.- Parameters:
key- the key name of the item to remove. Can be empty or blank- Throws:
ObjectClosedException- when the frame is closedWebStorageSecurityException- if the access to the storage is forbidden for the current document
-
clear
void clear()Removes all the items from the storage.- Throws:
ObjectClosedException- when the frame is closedWebStorageSecurityException- if the access to the storage is forbidden for the current document
-
contains
Returnstrueif the storage contains an item with the specifiedkey, otherwisefalse.- Parameters:
key- the key name to check. Can be empty or blank- Throws:
ObjectClosedException- when the frame is closedWebStorageSecurityException- if the access to the storage is forbidden for the current document
-