com.oakgrovesystems.reactor.client
Class ClientLabelPathToIdMapper

java.lang.Object
  |
  +--com.oakgrovesystems.reactor.client.ClientLabelPathToIdMapper
All Implemented Interfaces:
LabelPathToIdMapper
Direct Known Subclasses:
ClientLabelPathToIdMapperAndCreator

public class ClientLabelPathToIdMapper
extends java.lang.Object
implements LabelPathToIdMapper

Maps LabelPaths to ReactorObjectIds. Uses a Map to dereference ReactorObjectIds as necessary to do the mapping. This class was written with the assumption that the Map contains properly initialized ProcessMediation objects. For example, an Operand's getProcess() method should not return the id of a Status. However, this precondition is not enforced and errors that result from this precondition not being met were not taken into consideration when writing the class. This class should be improved to either enforce this precondition or gracefully handle errors that result from it not being met.


Constructor Summary
ClientLabelPathToIdMapper()
          Constructs a ClientLabelPathToIdMapperthat utilizes caching to improve performance.
ClientLabelPathToIdMapper(java.util.Map objectMap)
          Constructs a mapper that uses objectMap to look up objects by their ids and utilizes caching to improve performance.
 
Method Summary
protected  void addToCache(com.oakgrovesystems.reactor.LabelPath pathToMap, java.lang.Class filterClass, com.oakgrovesystems.reactor.ReactorObjectId id)
          Adds ReactorObjectId corresponding to LabelPath to cache
 void emptyCache()
          Clears the mapper's cache and reinitializes the root naming context.
 com.oakgrovesystems.reactor.ReactorObjectId getId(com.oakgrovesystems.reactor.LabelPath pathToMap)
          Maps a LabelPath to a ReactorObjectId.
 com.oakgrovesystems.reactor.ReactorObjectId getId(com.oakgrovesystems.reactor.LabelPath pathToMap, java.lang.Class filterClass)
          Maps a LabelPath to a ReactorObjectId.
 com.oakgrovesystems.reactor.ReactorObjectId getId(com.oakgrovesystems.reactor.LabelPath pathToMap, java.lang.Class filterClass, com.oakgrovesystems.reactor.ReactorObjectId root)
          Maps a LabelPath to a ReactorObjectId with the id specified as the starting point for label path resolution.
 com.oakgrovesystems.reactor.ReactorObjectId getId(com.oakgrovesystems.reactor.LabelPath pathToMap, com.oakgrovesystems.reactor.ReactorObjectId root)
          Maps a LabelPath to a ReactorObjectId with the id specified as the starting point for label path resolution.
 com.oakgrovesystems.reactor.ReactorObjectId getIdForUniqueLabelPath(com.oakgrovesystems.reactor.LabelPath uniquePathToMap)
          Maps a LabelPath to a ReactorObjectId.
 com.oakgrovesystems.reactor.ReactorObjectId getIdForUniqueLabelPath(com.oakgrovesystems.reactor.LabelPath uniquePathToMap, java.lang.Class filterClass)
          Maps a LabelPath to a ReactorObjectId.
 com.oakgrovesystems.reactor.ReactorObjectId getIdForUniqueLabelPath(com.oakgrovesystems.reactor.LabelPath uniquePathToMap, java.lang.Class filterClass, com.oakgrovesystems.reactor.ReactorObjectId root)
          Maps a LabelPath to a ReactorObjectId with the id specified as the starting point for label path resolution.
 com.oakgrovesystems.reactor.ReactorObjectId getIdForUniqueLabelPath(com.oakgrovesystems.reactor.LabelPath uniquePathToMap, com.oakgrovesystems.reactor.ReactorObjectId root)
          Maps a LabelPath to a ReactorObjectId with the id specified as the starting point for label path resolution.
 java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap)
          Maps a LabelPath to a Set of ReactorObjectIds
 java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap, java.lang.Class filterClass)
          Maps a LabelPath to a Set of ReactorObjectIds
 java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap, java.lang.Class filterClass, boolean definitionsOnly)
          Maps a LabelPath to a Set of ReactorObjectIds
 java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap, java.lang.Class filterClass, com.oakgrovesystems.reactor.ReactorObjectId root)
          Maps a LabelPath to a Set of ReactorObjectIds with the id specified as the starting point for label path resolution
 java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap, java.lang.Class filterClass, com.oakgrovesystems.reactor.ReactorObjectId root, boolean definitionsOnly)
           
 java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap, com.oakgrovesystems.reactor.ReactorObjectId root)
          Maps a LabelPath to a Set of ReactorObjectIds using the Process with the id specified as the starting point for label path resolution
 java.util.Map getObjectMap()
          Returns the Map being used to look up ProcessMediationObjects.
 void setObjectMap(java.util.Map objectMap)
          Sets the Map for this mapper to use to look up ProcessMediationObjects by their ids.
 void setUseCaching(boolean useCaching)
          Sets whether or not the Mapper will use caching to improve performance.
 boolean usesCaching()
          Returns a boolean indicating whether or not this mapper is using caching to improve perfomance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientLabelPathToIdMapper

public ClientLabelPathToIdMapper()
Constructs a ClientLabelPathToIdMapperthat utilizes caching to improve performance. The new mapper will not be useful until it is given a Map to use to look up ProcessMediationObjects by a call to setObjectMap().


ClientLabelPathToIdMapper

public ClientLabelPathToIdMapper(java.util.Map objectMap)
                          throws ProcessMediationException
Constructs a mapper that uses objectMap to look up objects by their ids and utilizes caching to improve performance.

Parameters:
objectMap - the Map to use to look up objects by their ids
Throws:
ProcessMediationException - if the Map contains values other than ProcessMediationObjects or Maps an id to an object with a different id.
Method Detail

setObjectMap

public void setObjectMap(java.util.Map objectMap)
                  throws ProcessMediationException
Sets the Map for this mapper to use to look up ProcessMediationObjects by their ids. This method has a side-effect of emptying the mapper's cache.

Parameters:
objectMap - The map that should be used to lookup ProcessMediationObjects by their ids. The Map should have with keys that are Strings and values that are ProcessMediationObjects.
Throws:
ProcessMediationException - if the Map contains values other than ProcessMediationObjects or Maps an id to an object with a different id.

getObjectMap

public java.util.Map getObjectMap()
Returns the Map being used to look up ProcessMediationObjects.

Returns:
The Map being used to look up ProcessMediationObjects

setUseCaching

public void setUseCaching(boolean useCaching)
Sets whether or not the Mapper will use caching to improve performance. While set to true: The default is to use caching. Note: The behavior of the getXXX() methods is not defined when the mapper is set to use caching and the cache is stale. The cache may be stale if and only if a getXXX() method has called while the mapper is using caching the object map is subsequently modified. To return the mapper to a state where the getXXX() methods are defined, call the emptyCache() method.

Parameters:
useCaching - whether or not the Mapper will use caching

usesCaching

public boolean usesCaching()
Returns a boolean indicating whether or not this mapper is using caching to improve perfomance.

Returns:
A boolean indicating whether or not this mapper is using caching to improve perfomance.

emptyCache

public void emptyCache()
                throws ProcessMediationException
Clears the mapper's cache and reinitializes the root naming context.

Throws:
ProcessMediationException - If the objectMap contains errors

getIdSet

public java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap,
                              java.lang.Class filterClass)
Maps a LabelPath to a Set of ReactorObjectIds

Specified by:
getIdSet in interface LabelPathToIdMapper
Parameters:
pathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
filterClass - The Class with which an object must be assignment compatible in order to be included in the returned Set.
Returns:
The Set of ReactorObjectIds of all Objects o available to the mapper such that the LabelPath pathToMap will resolve to o and filterClass.isInstance(o)==true. Returns an empty set if no such objects are available to the mapper.

getIdSet

public java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap,
                              java.lang.Class filterClass,
                              boolean definitionsOnly)
Description copied from interface: LabelPathToIdMapper
Maps a LabelPath to a Set of ReactorObjectIds

Specified by:
getIdSet in interface LabelPathToIdMapper
Parameters:
pathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
filterClass - The Class with which an object must be assignment compatible in order to be included in the returned Set.
definitionsOnly - If true, the objects must be in a process definition tree.
Returns:
The Set of ReactorObjectIds of all Objects o available to the mapper such that the LabelPath pathToMap will resolve to o and filterClass.isInstance(o)==true. Returns an empty set if no such objects are available to the mapper.

getIdSet

public java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap,
                              java.lang.Class filterClass,
                              com.oakgrovesystems.reactor.ReactorObjectId root)
Description copied from interface: LabelPathToIdMapper
Maps a LabelPath to a Set of ReactorObjectIds with the id specified as the starting point for label path resolution

Specified by:
getIdSet in interface LabelPathToIdMapper
Parameters:
pathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
filterClass - The Class with which an object must be assignment compatible in order to be included in the returned Set.
Returns:
The Set of ReactorObjectIds of all Objects o available to the mapper such that the LabelPath pathToMap will resolve to o and filterClass.isInstance(o)==true. Returns an empty set if no such objects are available to the mapper.

getIdSet

public java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap,
                              java.lang.Class filterClass,
                              com.oakgrovesystems.reactor.ReactorObjectId root,
                              boolean definitionsOnly)

getIdSet

public java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap)
Maps a LabelPath to a Set of ReactorObjectIds

Specified by:
getIdSet in interface LabelPathToIdMapper
Parameters:
pathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
Returns:
The Set of ReactorObjectIds of all Objects o available to the mapper such that the LabelPath pathToMap will resolve to o. Returns an empty set if no such objects are available to the mapper.

getIdSet

public java.util.Set getIdSet(com.oakgrovesystems.reactor.LabelPath pathToMap,
                              com.oakgrovesystems.reactor.ReactorObjectId root)
Description copied from interface: LabelPathToIdMapper
Maps a LabelPath to a Set of ReactorObjectIds using the Process with the id specified as the starting point for label path resolution

Specified by:
getIdSet in interface LabelPathToIdMapper
Parameters:
pathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
Returns:
The Set of ReactorObjectIds of all Objects o available to the mapper such that the LabelPath pathToMap will resolve to o. Returns an empty set if no such objects are available to the mapper.

addToCache

protected void addToCache(com.oakgrovesystems.reactor.LabelPath pathToMap,
                          java.lang.Class filterClass,
                          com.oakgrovesystems.reactor.ReactorObjectId id)
Adds ReactorObjectId corresponding to LabelPath to cache


getId

public com.oakgrovesystems.reactor.ReactorObjectId getId(com.oakgrovesystems.reactor.LabelPath pathToMap)
Maps a LabelPath to a ReactorObjectId. If the LabelPath provided maps to more than one ReactorObjectId, this method may return any one of them.

Specified by:
getId in interface LabelPathToIdMapper
Parameters:
pathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
Returns:
The ReactorObjectId of an Object o such that the LabelPath pathToMap will resolve to o. Returns null if no such objects are available to the mapper.

getId

public com.oakgrovesystems.reactor.ReactorObjectId getId(com.oakgrovesystems.reactor.LabelPath pathToMap,
                                                         com.oakgrovesystems.reactor.ReactorObjectId root)
Description copied from interface: LabelPathToIdMapper
Maps a LabelPath to a ReactorObjectId with the id specified as the starting point for label path resolution. If the LabelPath provided maps to more than one ReactorObjectId, this method may return any one of them.

Specified by:
getId in interface LabelPathToIdMapper
Parameters:
pathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
Returns:
The ReactorObjectId of an Object o such that the LabelPath pathToMap will resolve to o. Returns null if no such objects are available to the mapper.

getId

public com.oakgrovesystems.reactor.ReactorObjectId getId(com.oakgrovesystems.reactor.LabelPath pathToMap,
                                                         java.lang.Class filterClass)
Maps a LabelPath to a ReactorObjectId. If the LabelPath provided maps to more than one ReactorObjectId, this method may return any one of them.

Specified by:
getId in interface LabelPathToIdMapper
Parameters:
pathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
filterClass -
Returns:
The ReactorObjectId of an Object o such that the LabelPath pathToMap will resolve to o and filterClass.isInstance(o)==true. Returns null if no such objects are available to the mapper.

getId

public com.oakgrovesystems.reactor.ReactorObjectId getId(com.oakgrovesystems.reactor.LabelPath pathToMap,
                                                         java.lang.Class filterClass,
                                                         com.oakgrovesystems.reactor.ReactorObjectId root)
Description copied from interface: LabelPathToIdMapper
Maps a LabelPath to a ReactorObjectId with the id specified as the starting point for label path resolution. If the LabelPath provided maps to more than one ReactorObjectId, this method may return any one of them.

Specified by:
getId in interface LabelPathToIdMapper
Parameters:
pathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
filterClass -
Returns:
The ReactorObjectId of an Object o such that the LabelPath pathToMap will resolve to o and filterClass.isInstance(o)==true. Returns null if no such objects are available to the mapper.

getIdForUniqueLabelPath

public com.oakgrovesystems.reactor.ReactorObjectId getIdForUniqueLabelPath(com.oakgrovesystems.reactor.LabelPath uniquePathToMap)
                                                                    throws IdentifierMappingException
Maps a LabelPath to a ReactorObjectId.

Specified by:
getIdForUniqueLabelPath in interface LabelPathToIdMapper
Parameters:
uniquePathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
Returns:
The ReactorObjectId of an Object o such that the LabelPath pathToMap will resolve to o. Returns null if no such objects are available to the mapper.
Throws:
IdentifierMappingException - If the LabelPath provided maps to more than one object.

getIdForUniqueLabelPath

public com.oakgrovesystems.reactor.ReactorObjectId getIdForUniqueLabelPath(com.oakgrovesystems.reactor.LabelPath uniquePathToMap,
                                                                           com.oakgrovesystems.reactor.ReactorObjectId root)
                                                                    throws IdentifierMappingException
Description copied from interface: LabelPathToIdMapper
Maps a LabelPath to a ReactorObjectId with the id specified as the starting point for label path resolution.

Specified by:
getIdForUniqueLabelPath in interface LabelPathToIdMapper
Parameters:
uniquePathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
Returns:
The ReactorObjectId of an Object o such that the LabelPath pathToMap will resolve to o. Returns null if no such objects are available to the mapper.
Throws:
IdentifierMappingException - If the LabelPath provided maps to more than one object.

getIdForUniqueLabelPath

public com.oakgrovesystems.reactor.ReactorObjectId getIdForUniqueLabelPath(com.oakgrovesystems.reactor.LabelPath uniquePathToMap,
                                                                           java.lang.Class filterClass)
                                                                    throws IdentifierMappingException
Maps a LabelPath to a ReactorObjectId.

Specified by:
getIdForUniqueLabelPath in interface LabelPathToIdMapper
Parameters:
uniquePathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
filterClass - The Class with which an object must be assignment compatible in order to be included in the returned Set.
Returns:
The ReactorObjectId of an Object o such that the LabelPath pathToMap will resolve to o and filterClass.isInstance(o)==true. Returns null if no such objects are available to the mapper.
Throws:
IdentifierMappingException - If the LabelPath provided maps to more than one object that is assignment compatible with the given class.

getIdForUniqueLabelPath

public com.oakgrovesystems.reactor.ReactorObjectId getIdForUniqueLabelPath(com.oakgrovesystems.reactor.LabelPath uniquePathToMap,
                                                                           java.lang.Class filterClass,
                                                                           com.oakgrovesystems.reactor.ReactorObjectId root)
                                                                    throws IdentifierMappingException
Description copied from interface: LabelPathToIdMapper
Maps a LabelPath to a ReactorObjectId with the id specified as the starting point for label path resolution.

Specified by:
getIdForUniqueLabelPath in interface LabelPathToIdMapper
Parameters:
uniquePathToMap - The LabelPath that must resolve to an object for that object to be included in the returned Set.
filterClass - The Class with which an object must be assignment compatible in order to be included in the returned Set.
Returns:
The ReactorObjectId of an Object o such that the LabelPath pathToMap will resolve to o and filterClass.isInstance(o)==true. Returns null if no such objects are available to the mapper.
Throws:
IdentifierMappingException - If the LabelPath provided maps to more than one object that is assignment compatible with the given class.


Copyright (c) 1999-2004 Oak Grove Systems. All Rights Reserved.