public class ChainOfR<T,V,S> extends java.lang.Object implements Copyable
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
ChainOfR.DuplicateIndexException  | 
static class  | 
ChainOfR.IndexNotFoundException  | 
static interface  | 
ChainOfR.RequestHandler<V,S>  | 
| Constructor and Description | 
|---|
ChainOfR(ChainOfR.RequestHandler<V,S> handler)  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
add(T chainIndex,
   T chainParentIndex,
   V userObject)
Adds a new User Object to a chain. 
 | 
java.lang.Object | 
copyTo(java.lang.Object target)
Shallow copies the data structure that implements the ChainOfR pattern. 
 | 
protected void | 
copyToImpl(ChainOfR<T,V,S> copy)  | 
V | 
get(T chainIndex)  | 
V | 
getHandlingObject(T startNodeIndex,
                 S request)
Same as handle(), but return the user object that handled the request. 
 | 
V | 
getParent(T chainIndex)  | 
T | 
getParentLabel(T chainIndex)  | 
boolean | 
handle(T startNodeIndex,
      S request)
Handle the command, starting from a certain node and traversing 
 referred nodes. 
 | 
void | 
purge()
Delete all nodes in this chain, intended for testing. 
 | 
void | 
replace(T chainIndex,
       V userObject)
Replace an existing User Object with a new one. 
 | 
public ChainOfR(ChainOfR.RequestHandler<V,S> handler)
public boolean handle(T startNodeIndex, S request) throws java.lang.Exception
ChainOfR.IndexNotFoundException - if the starting index cannot be found.java.lang.Exception - any other exception raised when handling the request.public V getHandlingObject(T startNodeIndex, S request) throws java.lang.Exception
ChainOfR.IndexNotFoundException - if startNodeIndex is not foundjava.lang.Exception - if an error occurs when processing the request.public void add(T chainIndex, T chainParentIndex, V userObject) throws ChainOfR.DuplicateIndexException, MetadataException
chainIndex - a label for the new handlerchainParentIndex - label for the parent for this handleruserObject - a user object that should be associated with this handlerMetadataException - if chainIndex, or chainParentIndex cannot be found.ChainOfR.DuplicateIndexExceptionpublic void replace(T chainIndex, V userObject) throws MetadataException
chainIndex - userObject - MetadataException - if chainIndex is not foundpublic T getParentLabel(T chainIndex) throws ChainOfR.IndexNotFoundException
ChainOfR.IndexNotFoundExceptionpublic V getParent(T chainIndex) throws ChainOfR.IndexNotFoundException
ChainOfR.IndexNotFoundExceptionpublic V get(T chainIndex) throws ChainOfR.IndexNotFoundException
ChainOfR.IndexNotFoundExceptionpublic void purge()
public java.lang.Object copyTo(java.lang.Object target)