public class ObjectMap
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
ObjectMap.ScoreOptions
This class allows the merge algorithm to be customized to work for the
various merge types.
|
Modifier and Type | Field and Description |
---|---|
protected static FtDebug |
debug |
protected static java.lang.String |
MERGEDMAPID |
Constructor and Description |
---|
ObjectMap()
Construct an object map with no shared map characteristics.
|
ObjectMap(ObjectMapSet mtoSet,
long nextElementId,
long safeElementId,
ObjectMapTopLevelIdSet topLevelIds,
HashtableEx attributes,
ObjectMapPropertySet mapProps)
This method is required for internal use only and should not be
used for purposes other then rectituting an object map.
|
Modifier and Type | Method and Description |
---|---|
void |
addElement(IMappedTestObject element)
Add a
IMappedTestObject object to the map. |
void |
addElement(IMappedTestObject element,
boolean defineGuidMapId) |
void |
cleanup()
Break up an object map to help teh garbage collector reclaim memory.
|
void |
clearPropertyCache() |
void |
clearState()
Clear the
IMappedTestObject state of every node in the map. |
boolean |
containsId(java.lang.String id)
Return
true if the specified map id is present in this map. |
static void |
copyMapFile(java.io.File fromFile,
java.io.File toFile)
Copy 'from' file to 'to' file and clear any state setting found in the original map.
|
static ObjectMap |
createLocalMapFromSharedMap(java.lang.String datastore,
java.lang.String localMapName,
java.lang.String sharedMapName)
This method can be used to construct a local map from an existing shared
map.
|
static void |
deleteObjectMapState(java.lang.String datastore,
java.lang.String mapName)
Delete off any local cache files associated with this instance of an object map.
|
static void |
deletePersistantState(java.lang.String datastore,
java.lang.String mapName) |
java.util.Enumeration |
elements()
Return an enumerator for the
IMappedTestObject elements in the map. |
IMappedTestObject |
find(java.lang.String id)
Find an
IMappedTestObject by identifier in the map. |
protected IMappedTestObject |
findLocal(java.lang.String id)
Find an
IMappedTestObject by identifier in the map. |
void |
freeObjectMap()
This method frees all assets held by an allocated object map.
|
void |
freeSharedMemory()
This method frees all shared memory associated with this map.
|
java.lang.Object |
getAttribute(java.lang.String name)
This method returns an attribute from the object map.
|
java.util.Enumeration |
getAttributeNames()
This method returns an enumeration for the attributes associated with an object map.
|
protected long |
getCurrentSafeElementId()
This method is for internal use ONLY.
|
java.io.File |
getFile()
This method returns the file name used to load the object map originally.
|
static java.io.File |
getFile(java.lang.String datastore,
java.lang.String mapBaseName,
boolean isLocalMap)
This method constructs an appropriate file name from the supplied
parts.
|
ObjectMapPropertySet |
getMapProperties()
This method returns the set of properties associated with the ObjectMap.
|
java.lang.String |
getMergedToMto(IMappedTestObject mto)
When a "from" mto is merged into this map, the merged id is cached in the "from"
mto for fast lookup.
|
protected ObjectMapSet |
getMtoSet()
This method is for internal use ONLY.
|
protected long |
getNextElementId()
This method is for internal use ONLY.
|
static java.lang.String |
getPrivateMapName(java.lang.String script)
This method constructs an appropriate project relative transient map file
name from the supplied parts.
|
HashtableEx |
getPropertyCache()
Return a cache of properties used in this map with a default value for the property.
|
protected long |
getSafeElementId()
This method is for internal use ONLY.
|
SpyMappedTestObject |
getSharedInstance(IMappedTestObject node)
This method crates a global reference for a local mapped test object
that can be viewed in another process.
|
SpyMappedTestObject |
getSharedInstance(java.lang.String id)
This method crates a global reference for a local mapped test object
that can be viewed in another process.
|
java.lang.String[] |
getTopLevelIds()
Return a list of identifiers for the registered top level
IMappedTestObject objects. |
protected ObjectMapTopLevelIdSet |
getTopLevelIdSet()
This method is for internal use ONLY.
|
IMappedTestObject[] |
getTopLevelObjects()
Return a list of registered top level
IMappedTestObject objects, including
owned top level objects. |
IMappedTestObject[] |
getTopLevelObjects(boolean includeOwned)
Return a list of registered top level
IMappedTestObject objects. |
java.util.Hashtable |
getUserModifiedIds()
Set a map id as having been modified directly by a user.
|
java.util.Hashtable |
getUserRemovedIds()
Return an enumerator for the elements deleted from the map.
|
boolean |
isUserModified(java.lang.String id)
Set a map id as having been modified directly by a user.
|
static ObjectMap |
load(java.io.File file)
This method loads an object map from the specified file.
|
static ObjectMap |
loadFromStream(java.io.InputStream input) |
static void |
loadPersistantState(java.io.File mapFile,
ObjectMap objectMap)
This method takes a datastore relative map names and updates it with any cached
persistent state.
|
static java.io.File |
locateFile(java.lang.String datastore,
java.lang.String mapName) |
void |
merge(ObjectMap ancestor,
ObjectMap source) |
void |
merge(ObjectMap ancestor,
ObjectMap fromMap,
ObjectMapSet usedLeafNodes,
ObjectMap.ScoreOptions scoreOptions) |
void |
merge(ObjectMap fromMap,
ObjectMapSet usedLeafNodes,
ObjectMap.ScoreOptions scoreOptions)
This is the root of the internal map merging algorithm.
|
void |
merge(SpyMap mtoCache)
This method merges the results of a recorder shared map into an object
map.
|
IMappedTestObject |
mergeThisToThat(IMappedTestObject sourceMto,
IMappedTestObject targetMto)
Merge two mapped test objects together
|
void |
registerTopLevelObject(java.lang.String id)
Add a
IMappedTestObject object to the list of top level ids. |
void |
remove(java.lang.String id,
boolean removeChildren,
boolean removeOwned)
Remove the specified element from the map.
|
void |
removeTopLevelObject(java.lang.String id)
Remove a
IMappedTestObject object from the list of top level
ids. |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
This method adds an attribute to the object map.
|
void |
setMtoSetElement(java.lang.String id,
IMappedTestObject element) |
void |
setUserModified(java.lang.String id)
Set a map id as having been modified directly by a user.
|
void |
setUserRemoved(java.lang.String id) |
int |
size()
Return a count of the number of elements in the map.
|
static void |
store(ObjectMap objectMap,
java.io.File file) |
static void |
store(ObjectMap objectMap,
java.io.File file,
boolean silent)
This method stores an object map to the specified file.
|
static void |
storePersistantState(ObjectMap objectMap,
java.io.File mapFile,
boolean refreshIDE) |
static void |
storeToStream(ObjectMap objectmap,
java.io.OutputStream boStream) |
static void |
updateMergedProperties(IMappedTestObject targetMto,
IMappedTestObject mergedMto) |
void |
updateSafeElementId()
The merge algorithm needs to keep track of the safe element id so that
shared map nodes can be properly separated from new nodes.
|
void |
updateThisToThatProperties(IMappedTestObject targetMto,
IMappedTestObject mergedMto) |
protected static FtDebug debug
protected static final java.lang.String MERGEDMAPID
public ObjectMap()
public ObjectMap(ObjectMapSet mtoSet, long nextElementId, long safeElementId, ObjectMapTopLevelIdSet topLevelIds, HashtableEx attributes, ObjectMapPropertySet mapProps)
public void cleanup()
public static ObjectMap loadFromStream(java.io.InputStream input)
public static ObjectMap load(java.io.File file)
public static void storeToStream(ObjectMap objectmap, java.io.OutputStream boStream)
public static void store(ObjectMap objectMap, java.io.File file)
public static void store(ObjectMap objectMap, java.io.File file, boolean silent)
public static java.io.File getFile(java.lang.String datastore, java.lang.String mapBaseName, boolean isLocalMap)
public java.io.File getFile()
null
for a newly constructed object map.public static java.lang.String getPrivateMapName(java.lang.String script)
public static void deleteObjectMapState(java.lang.String datastore, java.lang.String mapName)
public java.lang.Object getAttribute(java.lang.String name)
name
- The name of the attribute.public void setAttribute(java.lang.String name, java.lang.Object value)
name
- The name of the attribute.value
- The data associated with the attribute.public java.util.Enumeration getAttributeNames()
public ObjectMapPropertySet getMapProperties()
public void updateSafeElementId()
public void addElement(IMappedTestObject element)
IMappedTestObject
object to the map. An unique identifier
is assigned to the objet when added to the object map. If the object
already has an identifier associated with it an appropriate exception
is thrown.public void addElement(IMappedTestObject element, boolean defineGuidMapId)
public IMappedTestObject find(java.lang.String id) throws ObjectNotInMapException
IMappedTestObject
by identifier in the map.ObjectNotInMapException
protected IMappedTestObject findLocal(java.lang.String id)
IMappedTestObject
by identifier in the map. No exception is thrown by this
version of the find.public void remove(java.lang.String id, boolean removeChildren, boolean removeOwned) throws ObjectNotInMapException
ObjectNotInMapException
is thrown.ObjectNotInMapException
public void setUserRemoved(java.lang.String id)
public java.util.Hashtable getUserRemovedIds()
public void setUserModified(java.lang.String id)
public boolean isUserModified(java.lang.String id)
public java.util.Hashtable getUserModifiedIds()
public java.util.Enumeration elements()
IMappedTestObject
elements in the map.public int size()
public boolean containsId(java.lang.String id)
true
if the specified map id is present in this map.public void registerTopLevelObject(java.lang.String id)
IMappedTestObject
object to the list of top level ids.
A check is performed to make sure the object does not have a parent
and an appropriate exception raised if the parent is non-null.public void removeTopLevelObject(java.lang.String id)
IMappedTestObject
object from the list of top level
ids.public java.lang.String[] getTopLevelIds()
IMappedTestObject
objects.public IMappedTestObject[] getTopLevelObjects()
IMappedTestObject
objects, including
owned top level objects.public IMappedTestObject[] getTopLevelObjects(boolean includeOwned)
IMappedTestObject
objects.public SpyMappedTestObject getSharedInstance(IMappedTestObject node) throws ObjectNotInMapException
ObjectNotInMapException
public SpyMappedTestObject getSharedInstance(java.lang.String id) throws ObjectNotInMapException
ObjectNotInMapException
public void clearState()
IMappedTestObject
state of every node in the map.public void freeObjectMap()
public void freeSharedMemory()
public static ObjectMap createLocalMapFromSharedMap(java.lang.String datastore, java.lang.String localMapName, java.lang.String sharedMapName)
datastore
- This is the datastore directory that the objects maps are
located relative to. Note that they must be defined in the
same datastore.public static void copyMapFile(java.io.File fromFile, java.io.File toFile)
public HashtableEx getPropertyCache()
Note that all the keys in the property cache are String values and the values are all
type MappedTestObjectProperty
.
public void updateThisToThatProperties(IMappedTestObject targetMto, IMappedTestObject mergedMto)
public static void updateMergedProperties(IMappedTestObject targetMto, IMappedTestObject mergedMto)
public IMappedTestObject mergeThisToThat(IMappedTestObject sourceMto, IMappedTestObject targetMto)
public void merge(SpyMap mtoCache)
SpyMappedTestObject
objects. This method matches those elements to
existing elements in this object map or constructs new nodes that
represent those nodes. As a side effect of this method identifiers
are set in the SpyMappedTestObject
objects in the recorder
shared map.public void setMtoSetElement(java.lang.String id, IMappedTestObject element)
public static java.io.File locateFile(java.lang.String datastore, java.lang.String mapName)
public void merge(ObjectMap fromMap, ObjectMapSet usedLeafNodes, ObjectMap.ScoreOptions scoreOptions)
public void merge(ObjectMap ancestor, ObjectMap fromMap, ObjectMapSet usedLeafNodes, ObjectMap.ScoreOptions scoreOptions)
public java.lang.String getMergedToMto(IMappedTestObject mto)
protected ObjectMapSet getMtoSet()
protected long getNextElementId()
protected long getCurrentSafeElementId()
protected long getSafeElementId()
protected ObjectMapTopLevelIdSet getTopLevelIdSet()
public void clearPropertyCache()
public static void loadPersistantState(java.io.File mapFile, ObjectMap objectMap)
public static void deletePersistantState(java.lang.String datastore, java.lang.String mapName)
public static void storePersistantState(ObjectMap objectMap, java.io.File mapFile, boolean refreshIDE)