|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.concord.biologica.engine.ImportContext
This class represents a context for a set of objects being imported into an active BioLogica process.
Specifically, this class maintains a mapping of old object ids to object references. This diagram shows what the objects look like in the File on the left side and what the objects look like after they've been read into an existing BioLogica process.
File BioLogica Process object 1 object 435 no object references no object references object 2 object 567 reference to object 1 reference to object 435 object 3 object 798 reference to object 1 reference to object 435 reference to object 2 reference to object 567 object 4 object 876 reference to object 3 reference to object 798So the mapping of old IDs to new objects would be:
Old ID New Object Reference 1 reference to object 435 2 reference to object 567 3 reference to object 798 4 reference to object 876As additional objects are read in, this mapping is added to and used.
Of course, this implies that objects are written to the file originally in a parent to child order, as that's the only way to avoid cycles.
This object fires no property change events, as this object is created and used and then deleted all within the process of opening and reading in one file. So no other object has a chance to add itself to this object as a listener.
This class works by maintaining an array of objects that have been read into the world where the index of an object into that array is the id of that object in the world file. But the id of the object after it has been created in this process will normally not be the same as it was in the file. In other words, the id of the object is changed as it is read into this process from the file. This class maintains the mapping of the old ids to the new objects.
Constructor Summary | |
ImportContext()
Creates a new ImportContext. |
Method Summary | |
void |
addObject(EngineObject engineObject,
int oldID)
Add an object to the engine's array of objects, reallocating the array to a larger size if necessary. |
EngineObject |
getObject(int id)
Get an object given its old id in the world file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ImportContext()
InternalEngineException
- - multiple Engine objects detected in processMethod Detail |
public EngineObject getObject(int id)
id
- int - id of the object to get, must be 0 to Integer.MAX_VALUEjava.lang.IllegalArgumentException
- - object with id not foundpublic void addObject(EngineObject engineObject, int oldID)
engineObject
- EngineObject - object to add, may not be nulloldID
- int - the old id the object had (NOT the id it has now)java.lang.IllegalArgumentException
- - input arguments illegalInternalEngineException
- - oldID was more than 1024 greater than array size
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |