org.apache.commons.betwixt.strategy
Class IdStoringStrategy
java.lang.Object
|
+--org.apache.commons.betwixt.strategy.IdStoringStrategy
- Direct Known Subclasses:
- DefaultIdStoringStrategy
- public abstract class IdStoringStrategy
- extends java.lang.Object
Pluggable strategy for id storage management.
It is possible to use this strategy for innovative
active storage storage strategies as well as passive ones.
For example, it is possible to have some beans map to
references without ever being fully mapped.
- Since:
- 0.7
- Author:
- Christian Aust
Method Summary |
abstract java.lang.Object |
getReferenced(Context context,
java.lang.String id)
Gets an object matching the given reference. |
abstract java.lang.String |
getReferenceFor(Context context,
java.lang.Object bean)
Retrieves a reference for the given instance. |
abstract void |
reset()
Reset to the initial state. |
abstract void |
setReference(Context context,
java.lang.Object bean,
java.lang.String id)
Stores an instance reference for later retrieval. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT
public static IdStoringStrategy DEFAULT
- Default storage strategy
- See Also:
DefaultIdStoringStrategy
IdStoringStrategy
public IdStoringStrategy()
getReferenceFor
public abstract java.lang.String getReferenceFor(Context context,
java.lang.Object bean)
- Retrieves a reference for the given instance.
If a not null value is returned from this method,
then the bean content will not be written.
Use
IDGenerator
strategy to vary the values
written for a bean.
- Parameters:
context
- current context, not nullbean
- the instance, not null- Returns:
- id as String when this bean has already been reference,
or null to indicate that this bean is not yet reference
setReference
public abstract void setReference(Context context,
java.lang.Object bean,
java.lang.String id)
- Stores an instance reference for later retrieval.
This method is shared by writing and reading.
- Parameters:
context
- current context, not nullbean
- the instance, not nullid
- the id to use
getReferenced
public abstract java.lang.Object getReferenced(Context context,
java.lang.String id)
- Gets an object matching the given reference.
- Parameters:
context
- Context
, not nullid
- the reference id- Returns:
- an bean matching the given reference,
or null if there is no bean matching the given reference
reset
public abstract void reset()
- Reset to the initial state.
Copyright © 2002-2005 The Apache Software Foundation. All Rights Reserved.