Errai 3.0.1-SNAPSHOT

org.jboss.errai.jpa.client.local.backend
Interface StorageBackend

All Known Implementing Classes:
WebStorageBackend

public interface StorageBackend

Represents a browser-local persistent storage backend.

WARNING: this interface is in an extreme state of flux. It is guaranteed to change as the first few alternative implementations are developed.

Author:
Jonathan Fuerth

Method Summary
<X,Y> boolean
contains(Key<X,Y> key)
          Tests if this backend contains data for the given key.
<X> X
get(Key<X,?> key)
          Retrieves the value most recently stored in this backend under the given key, reconnecting referenced objects by calling back up into the owning EntityManager.
<X> List<X>
getAll(ErraiIdentifiableType<X> type, EntityJsonMatcher matcher)
          Returns all entities of the given type (and its subtypes) whose JSON representations are accepted by the given matcher.
<X> boolean
isModified(Key<X,?> key, X value)
          Checks if the value currently associated with key in this backend datastore is identical to the given one.
<X> void
put(Key<X,?> key, X value)
          Stores the given Errai-Marshalling-Capable value under the given key.
<X> void
remove(Key<X,?> key)
          Removes the key and its associated value (if any) from this storage backend.
 void removeAll()
          Removes all data from this storage backend.
 

Method Detail

put

<X> void put(Key<X,?> key,
             X value)
Stores the given Errai-Marshalling-Capable value under the given key. A pre-existing value under the same key (if any) is silently replaced by the new one.

Type Parameters:
X - The entity's Java type
Parameters:
key - The identity of the entry in the storage backend. Null is not permitted.
value - The value to store. Must be marshallable using Errai Marshalling. Null is not permitted; use remove(Key) to remove an entity from this data store.

get

<X> X get(Key<X,?> key)
Retrieves the value most recently stored in this backend under the given key, reconnecting referenced objects by calling back up into the owning EntityManager.

Note that this operation is not a good method for testing if the backend contains a given object, because of the potentially wide-reaching side effects caused by recursively resolving the entity references in the object being retrieved. To test if the backend contains an object for a particular key, use contains(Key).

Type Parameters:
X - The entity's Java type
Parameters:
key - The identity of the object to be retrieved. The actual entity returned may be a subtype of the type specified in the key. Null is not permitted.
Returns:
The retrieved object, reconstituted from its backend (serialized) representation, including references to other objects. Return value is null if there is no value presently associated with key.

getAll

<X> List<X> getAll(ErraiIdentifiableType<X> type,
                   EntityJsonMatcher matcher)
Returns all entities of the given type (and its subtypes) whose JSON representations are accepted by the given matcher.

Parameters:
type - The type of entities to retrieve
matcher - The matcher that decides which entity instances will be retrieved.
Returns:
all matching entities of the given type.

contains

<X,Y> boolean contains(Key<X,Y> key)
Tests if this backend contains data for the given key. As with get(Key), subtypes are taken into account. If this backend contains an entity with the same ID as the given key and the same type or a subtype of the type specified in the key, this method will return true.

Parameters:
key - The identity of the object to be tested for. Null is not permitted.
Returns:
True if the backend contains the entity instance associated with the given key, and false otherwise.

remove

<X> void remove(Key<X,?> key)
Removes the key and its associated value (if any) from this storage backend. If the key is not present in this backend, this method returns normally and has no effect.

Type Parameters:
X - The entity's Java type
Parameters:
key - The identity of the object to be removed. Null is not permitted.

isModified

<X> boolean isModified(Key<X,?> key,
                       X value)
Checks if the value currently associated with key in this backend datastore is identical to the given one. For the purposes of this method, two values are considered identical if their serialized representation is the same. This method does not check for equality using the equals() method of value.

Type Parameters:
X - The entity's Java type
Parameters:
key - The identity of the object to be removed. Null is not permitted.
value - The value to check. Must be marshallable using Errai Marshalling.

removeAll

void removeAll()
Removes all data from this storage backend.


Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.