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 TypeMethodDescriptionvoid
clear()
Removes all the items from the storage.boolean
Returnstrue
if the storage contains an item with the specifiedkey
, otherwisefalse
.Returns anOptional
that contains the value associated with the givenkey
if it exists in the storage, otherwise an emptyOptional
.key
(int index) Returns anOptional
that contains the name of the key by the specifiedindex
if it exists in the storage, otherwise an emptyOptional
.int
length()
Returns the number of key/value pairs in the storage.void
Adds the item with the specifiedkey
andvalue
to the storage, or updates it if the item with the givenkey
already exists.void
removeItem
(String key) Removes the item with the specifiedkey
from 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 anOptional
that contains the name of the key by the specifiedindex
if 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 theindex
is 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 anOptional
that contains the value associated with the givenkey
if 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 specifiedkey
andvalue
to the storage, or updates it if the item with the givenkey
already 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 specifiedkey
from the storage. Does nothing if there is no item with the specifiedkey
in 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
Returnstrue
if 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
-