org.apache.commons.betwixt.strategy
Class DefaultIdStoringStrategy
java.lang.Object
|
+--org.apache.commons.betwixt.strategy.IdStoringStrategy
|
+--org.apache.commons.betwixt.strategy.DefaultIdStoringStrategy
- public class DefaultIdStoringStrategy
- extends IdStoringStrategy
Stores every ID that given to it into an internal HashMap
and
returns it on request.
- Since:
- 0.7
- Author:
- Christian Aust
Method Summary |
java.lang.Object |
getReferenced(Context context,
java.lang.String id)
Gets an object matching the given reference. |
java.lang.String |
getReferenceFor(Context context,
java.lang.Object bean)
Returns a String id for the given bean if it has been stored previously. |
void |
reset()
Clears all beans. |
void |
setReference(Context context,
java.lang.Object bean,
java.lang.String id)
Stores an ID for the given instance and context. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DefaultIdStoringStrategy
public DefaultIdStoringStrategy()
- Constructs a
IdStoringStrategy
using a HashMap
for
storage.
getReferenceFor
public java.lang.String getReferenceFor(Context context,
java.lang.Object bean)
- Returns a String id for the given bean if it has been stored previously.
Otherwise returns null.
- Overrides:
getReferenceFor
in class IdStoringStrategy
- Parameters:
context
- current context, not nullbean
- the instance, not null- Returns:
- id as String, or null if not found
- See Also:
IdStoringStrategy.getReferenceFor(org.apache.commons.betwixt.expression.Context,
java.lang.Object)
setReference
public void setReference(Context context,
java.lang.Object bean,
java.lang.String id)
- Stores an ID for the given instance and context. It will check first if
this ID has been previously stored and will do nothing in that case.
- Overrides:
setReference
in class IdStoringStrategy
- Parameters:
context
- current context, not nullbean
- current instance, not nullid
- the ID to store- See Also:
IdStoringStrategy.setReference(org.apache.commons.betwixt.expression.Context,
java.lang.Object, java.lang.String)
getReferenced
public java.lang.Object getReferenced(Context context,
java.lang.String id)
- Gets an object matching the given reference.
- Overrides:
getReferenced
in class IdStoringStrategy
- 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 void reset()
- Clears all beans.
- Overrides:
reset
in class IdStoringStrategy
Copyright © 2002-2005 The Apache Software Foundation. All Rights Reserved.