com.sag.osami.contextstore.storage.impl
Class NullStorage

java.lang.Object
  extended by com.sag.osami.contextstore.storage.impl.NullStorage
All Implemented Interfaces:
IContextStorage, ISerializedContextStorage

public class NullStorage
extends java.lang.Object
implements ISerializedContextStorage

A dummy storage implementation which does not store anything and returns null or empty collections as results for loading and querying.


Constructor Summary
NullStorage()
           
 
Method Summary
 void delete(java.util.List<java.lang.Long> contextIds)
          Deletes several context events with given IDs.
 void delete(java.lang.Long contextId)
          Deletes a context event with given ID.
 void delete(java.lang.String query, java.lang.Object... params)
          Deletes several context events defined by the query.
 ContextEvent[] load(boolean deserialize, java.util.List<java.lang.Long> contextIds)
          Loads several context events with the given IDs.
 ContextEvent load(boolean deserialize, java.lang.Long contextId)
          Loads a context event with the given ID.
 ContextEvent[] load(java.util.List<java.lang.Long> contextIds)
          Loads several context events with the given IDs.
 ContextEvent load(java.lang.Long contextId)
          Loads a context event with the given ID.
 java.lang.Iterable<ContextEvent> loadLazy(boolean deserialize, java.util.List<java.lang.Long> contextIds)
          Lazy variant of ISerializedContextStorage.load(boolean, List), i.e. it loads one ContextEvent at a time during iteration.
 java.lang.Iterable<ContextEvent> loadLazy(java.util.List<java.lang.Long> contextIds)
          Lazy variant of IContextStorage.load(List), i.e. it loads one ContextEvent at a time during iteration.
 ContextEvent[] query(boolean deserialize, java.lang.String query, java.lang.Object... params)
          Queries several context events.
 ContextEvent[] query(java.lang.String query, java.lang.Object... params)
          Queries several context events.
 java.lang.Iterable<ContextEvent> queryLazy(boolean deserialize, java.lang.String query, java.lang.Object... params)
          Lazy variant of ISerializedContextStorage.query(boolean, String, Object...), i.e. it loads one ContextEvent at a time during iteration.
 java.lang.Iterable<ContextEvent> queryLazy(java.lang.String query, java.lang.Object... params)
          Lazy variant of IContextStorage.query(String, Object...), i.e. it loads one ContextEvent at a time during iteration.
 java.lang.Long retrieveLastID()
          ContextStore uses the result of this method as the offset for its auto-incremented context event IDs.
 void setSerializer(ISerializationHandler serializer)
          Grants access to the payload data serialization handler.
 void store(boolean serialize, ContextEvent context)
          Stores a context event object persistently.
 void store(ContextEvent context)
          Stores a context event object persistently.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NullStorage

public NullStorage()
Method Detail

load

public ContextEvent load(java.lang.Long contextId)
Description copied from interface: IContextStorage
Loads a context event with the given ID.

Specified by:
load in interface IContextStorage
Parameters:
contextId - ID of the context event
Returns:
loaded context event (or null, if there is no context event with given ID)

load

public ContextEvent[] load(java.util.List<java.lang.Long> contextIds)
Description copied from interface: IContextStorage
Loads several context events with the given IDs. The order within the result is unspecified.

Specified by:
load in interface IContextStorage
Parameters:
contextIds - IDs of the context events.
Returns:
loaded context events (or a zero-length array, if there are no context events with given IDs)

query

public ContextEvent[] query(java.lang.String query,
                            java.lang.Object... params)
Description copied from interface: IContextStorage
Queries several context events.

Specified by:
query in interface IContextStorage
Parameters:
query - Its language/format depends on the actual storage management class.
params - Should be used for parameter binding à la JDBC: query("SELECT * FROM contextstore WHERE type = ? AND timestamp >= ?", "someType", someDate.getTime());
Returns:
queried context events (or a zero-length array, if there are no according context events)

store

public void store(ContextEvent context)
Description copied from interface: IContextStorage
Stores a context event object persistently.

Specified by:
store in interface IContextStorage
Parameters:
context - context event object to be stored.

delete

public void delete(java.lang.Long contextId)
Description copied from interface: IContextStorage
Deletes a context event with given ID.

Specified by:
delete in interface IContextStorage
Parameters:
contextId - ID of context event to be deleted.

delete

public void delete(java.util.List<java.lang.Long> contextIds)
Description copied from interface: IContextStorage
Deletes several context events with given IDs.

Specified by:
delete in interface IContextStorage
Parameters:
contextIds - IDs of context events to be deleted.

delete

public void delete(java.lang.String query,
                   java.lang.Object... params)
Description copied from interface: IContextStorage
Deletes several context events defined by the query.

Specified by:
delete in interface IContextStorage
Parameters:
query - Defines the context events to be deleted.
params - Parameters for the query.
See Also:
IContextStorage.query(String, Object...)

load

public ContextEvent load(boolean deserialize,
                         java.lang.Long contextId)
Description copied from interface: ISerializedContextStorage
Loads a context event with the given ID.

Specified by:
load in interface ISerializedContextStorage
Parameters:
deserialize - whether the payload data should remain serialized or should be deserialized
contextId - ID of the context event
Returns:
loaded context event (or null, if there is no context event with given ID)

load

public ContextEvent[] load(boolean deserialize,
                           java.util.List<java.lang.Long> contextIds)
Description copied from interface: ISerializedContextStorage
Loads several context events with the given IDs. The order within the result is unspecified.

Specified by:
load in interface ISerializedContextStorage
Parameters:
deserialize - whether the payload data should remain serialized or should be deserialized
contextIds - IDs of the context events
Returns:
loaded context events (or a zero-length array, if there are no context events with given IDs)

query

public ContextEvent[] query(boolean deserialize,
                            java.lang.String query,
                            java.lang.Object... params)
Description copied from interface: ISerializedContextStorage
Queries several context events.

Specified by:
query in interface ISerializedContextStorage
Parameters:
deserialize - whether the payload data should remain serialized or should be deserialized
query - its language/format depends on the actual storage management class.
params - Should be used for parameter binding à la JDBC: query("SELECT * FROM CONTEXTSTORE WHERE TYPE = ? AND TIMESTAMP >= ?", "someType", someDate.getTime());
Returns:
queried context events (or a zero-length array, if there are no according context events)

store

public void store(boolean serialize,
                  ContextEvent context)
Description copied from interface: ISerializedContextStorage
Stores a context event object persistently.

Specified by:
store in interface ISerializedContextStorage
Parameters:
serialize - whether the payload data should be serialized or not (because it is already serialized)
context - context event object to be stored

setSerializer

public void setSerializer(ISerializationHandler serializer)
Description copied from interface: ISerializedContextStorage
Grants access to the payload data serialization handler.

Specified by:
setSerializer in interface ISerializedContextStorage
Parameters:
serializer - payload data serialization handler

retrieveLastID

public java.lang.Long retrieveLastID()
Description copied from interface: ISerializedContextStorage
ContextStore uses the result of this method as the offset for its auto-incremented context event IDs. This method is used only during the initialization of the ContextStore, it doesn't have to return the current last given ID during the whole lifetime.

Specified by:
retrieveLastID in interface ISerializedContextStorage
Returns:
the so-far highest already assigned ID of a persisted context event

loadLazy

public java.lang.Iterable<ContextEvent> loadLazy(java.util.List<java.lang.Long> contextIds)
                                          throws java.lang.UnsupportedOperationException
Description copied from interface: IContextStorage
Lazy variant of IContextStorage.load(List), i.e. it loads one ContextEvent at a time during iteration. This operation is optional.

Specified by:
loadLazy in interface IContextStorage
Parameters:
contextIds - IDs of the context events.
Throws:
java.lang.UnsupportedOperationException - if the underlying storage implementation does not support lazy querying
See Also:
IContextStorage.load(List)

queryLazy

public java.lang.Iterable<ContextEvent> queryLazy(java.lang.String query,
                                                  java.lang.Object... params)
Description copied from interface: IContextStorage
Lazy variant of IContextStorage.query(String, Object...), i.e. it loads one ContextEvent at a time during iteration. This operation is optional.

Specified by:
queryLazy in interface IContextStorage
Parameters:
query - The context event query.
params - Parameters for the query.
See Also:
IContextStorage.query(String, Object...)

loadLazy

public java.lang.Iterable<ContextEvent> loadLazy(boolean deserialize,
                                                 java.util.List<java.lang.Long> contextIds)
Description copied from interface: ISerializedContextStorage
Lazy variant of ISerializedContextStorage.load(boolean, List), i.e. it loads one ContextEvent at a time during iteration. This operation is optional.

Specified by:
loadLazy in interface ISerializedContextStorage
See Also:
ISerializedContextStorage.load(boolean, List)

queryLazy

public java.lang.Iterable<ContextEvent> queryLazy(boolean deserialize,
                                                  java.lang.String query,
                                                  java.lang.Object... params)
Description copied from interface: ISerializedContextStorage
Lazy variant of ISerializedContextStorage.query(boolean, String, Object...), i.e. it loads one ContextEvent at a time during iteration. This operation is optional.

Specified by:
queryLazy in interface ISerializedContextStorage
See Also:
ISerializedContextStorage.query(boolean, String, Object...)