Class Store


  extended by Object
      extended by Store

public class Store
extends Object

This class is a Widget specific persistent storage. Store is like a hashtable - it supports getting, putting, removing and listing of elements. Elements may be stored or retrieved in three different formats: ByteArray, Value or Streams. Note that format information is not stored along with content, meaning that code must read and write information using the same format.

See Also:
ByteArray, Value, InputStream, OutputStream

Method Summary
 ByteArray get(String name)
          Returns the named element as ByteArray.
 int getSize()
          Returns the amount of space, in bytes, that the store occupies.
 InputStream getStream(String name)
          Returns the named element as InputStream.
 Value getValue(String name)
          Returns the named element as Value.
 boolean has(String name)
          Checks if the store has a named element.
 List list()
          Returns a list containing the names of all stored elements.
 void put(String name, ByteArray array)
          Sets an element to Store.
 void put(String name, OutputStream output)
          Sets an element to Store.
 void put(String name, Value value)
          Sets an element to Store.
 void remove(String name)
          Removes named element from Store.
 
Methods inherited from class Object
toString, equals, hashCode
 
Methods inherited from
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

list

public List list()
Returns a list containing the names of all stored elements.

Returns:
List of String elements

get

public ByteArray get(String name)
Returns the named element as ByteArray.

Parameters:
name - Name of element to retrieve
Returns:
ByteArray or null if the store does not contain named elements.

getValue

public Value getValue(String name)
Returns the named element as Value.

Parameters:
name - Name of element to retrieve
Returns:
Value or null if the store does not contain named elements.

getStream

public InputStream getStream(String name)
Returns the named element as InputStream.

Parameters:
name - Name of element to retrieve
Returns:
InputStream or null if the store does not contain named elements.

has

public boolean has(String name)
Checks if the store has a named element.

Parameters:
name - Name of element to check for
Returns:
true if the element exists, false otherwise.

put

public void put(String name,
                ByteArray array)
Sets an element to Store. If there already exists an element with given name, it is overwritten.

Parameters:
name - Name of element to retrieve
array - Content of element

put

public void put(String name,
                Value value)
Sets an element to Store. If there already exists an element with given name, it is overwritten.

Parameters:
name - Name of element to retrieve
value - Content of element

put

public void put(String name,
                OutputStream output)
Sets an element to Store. If there already exists an element with given name, it is overwritten.

Parameters:
name - Name of element to retrieve
output - Content of element

remove

public void remove(String name)
Removes named element from Store.

Parameters:
name - Name of element to remove

getSize

public int getSize()
Returns the amount of space, in bytes, that the store occupies. The size returned includes also any overhead associated with the implementation.

Returns:
the size of the record store in bytes