Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.trapezium.vrml.visitor
Class PROTOcollector  view PROTOcollector download PROTOcollector.java

java.lang.Object
  extended bycom.trapezium.pattern.Visitor
      extended bycom.trapezium.vrml.visitor.PROTOcollector
All Implemented Interfaces:
java.io.Serializable

public class PROTOcollector
extends com.trapezium.pattern.Visitor

The PROTOcollector resolves conflicts introduced when one scene graph is merged into another. It collects infomation about all conflicts, then provides information about those conflicts. The method "resolveConflicts" resolves those which can be handled in-place. Otherwise, it has methods for extracting the information token by token. In-place conflict resolution handles DEF/USE/PROTO naming conflicts, but does not handle moving PROTOs to new locations in the file. Conflict resolution is one of two ways: the DEFNameFactory in the destination scene is used if it exists, otherwise an algorithm of appending "_1", "_2", etc. is used until a name without a conflict is found.


Field Summary
(package private)  int currentToken
           
(package private)  java.util.Hashtable defMapTable
           
(package private)  com.trapezium.vrml.Scene destinationScene
           
(package private)  int numberTokens
           
(package private)  java.util.BitSet protoInstanceLocations
           
(package private)  java.util.Vector protoList
           
(package private)  java.util.BitSet protoLocations
           
(package private)  java.util.Hashtable protoMapTable
           
(package private)  java.util.Hashtable protoTable
           
(package private)  java.util.BitSet routeLocations
           
(package private)  java.util.Vector routes
           
(package private)  java.util.Hashtable routeTable
           
(package private)  java.util.BitSet useLocations
           
(package private)  com.trapezium.vrml.Scene visitedScene
           
 
Fields inherited from class com.trapezium.pattern.Visitor
dataSource, visitLevel
 
Constructor Summary
PROTOcollector(com.trapezium.vrml.Scene s, com.trapezium.vrml.Scene destinationScene)
          class constructor
 
Method Summary
 int getNextToken()
          Get the next token offset
 int getNumberPROTOs()
          How many PROTOs were found
 int getNumberROUTEs()
          Get the number of ROUTEs saved
 com.trapezium.vrml.node.PROTObase getPROTO(int offset)
          Get a particular PROTO
 com.trapezium.vrml.ROUTE getROUTE(int offset)
          Get a specific ROUTE that was saved
 com.trapezium.vrml.Scene getScene()
          Get the scene that is going to be modified as a result of merging into the destinationScene.
 boolean hasMoreTokens()
          Check if there are more tokens to access in the scene to merge
 boolean hasPROTOs()
          were any PROTOs found?
 boolean hasROUTEs()
          Check if any ROUTEs were saved
 boolean protoIsRemapped(int tokenOffset)
          Is there a PROTO instance at a particular token offset that is renamed due to a PROTO declaration conflict.
(package private)  java.lang.String remap(int tokenOffset, java.util.Hashtable table)
          Generic remapping of Strings based on token offset.
 java.lang.String remapProto(int tokenOffset)
          Get the name for a remapped PROTO.
 java.lang.String remapUse(int tokenOffset)
          Get the name for a remapped USE node.
(package private)  void saveDEFUSENode(com.trapezium.vrml.node.DEFUSENode dun)
          Save a DEFUSENode.
(package private)  void savePROTO(com.trapezium.vrml.node.PROTObase proto)
          Save a PROTO, renaming it if its name conflicts with one in the destination scene.
(package private)  void savePROTOinstance(com.trapezium.vrml.node.PROTOInstance a)
          Save a PROTOInstance, if the PROTO declaration has a naming conflict all PROTOInstances must be renamed.
(package private)  void saveROUTE(com.trapezium.vrml.ROUTE route)
          Save a ROUTE, if either its source or dest object name is remapped according to the defMapTable, redo the token.
 void scanTokens()
          Start scanning tokens in the scene to merge
 boolean useIsRemapped(int tokenOffset)
          Is there a USE node at a particular token offset that is renamed due to a DEF declaration conflict.
 boolean visitObject(java.lang.Object a)
          Visit an object in the Scene, save PROTO, DEF/USE, and ROUTE info for possible conflict resolution.
 
Methods inherited from class com.trapezium.pattern.Visitor
accepts, acceptsPassOne, acceptsPassTwo, done, getDataSource, isTwoPassVisitor, setDataSource, spacer, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

protoList

java.util.Vector protoList

visitedScene

com.trapezium.vrml.Scene visitedScene

destinationScene

com.trapezium.vrml.Scene destinationScene

protoInstanceLocations

java.util.BitSet protoInstanceLocations

protoLocations

java.util.BitSet protoLocations

useLocations

java.util.BitSet useLocations

routeLocations

java.util.BitSet routeLocations

numberTokens

int numberTokens

protoMapTable

java.util.Hashtable protoMapTable

defMapTable

java.util.Hashtable defMapTable

protoTable

java.util.Hashtable protoTable

routeTable

java.util.Hashtable routeTable

routes

java.util.Vector routes

currentToken

int currentToken
Constructor Detail

PROTOcollector

public PROTOcollector(com.trapezium.vrml.Scene s,
                      com.trapezium.vrml.Scene destinationScene)
class constructor

Method Detail

getScene

public com.trapezium.vrml.Scene getScene()
Get the scene that is going to be modified as a result of merging into the destinationScene.


hasPROTOs

public boolean hasPROTOs()
were any PROTOs found?


getNumberPROTOs

public int getNumberPROTOs()
How many PROTOs were found


getPROTO

public com.trapezium.vrml.node.PROTObase getPROTO(int offset)
Get a particular PROTO


visitObject

public boolean visitObject(java.lang.Object a)
Visit an object in the Scene, save PROTO, DEF/USE, and ROUTE info for possible conflict resolution.


saveROUTE

void saveROUTE(com.trapezium.vrml.ROUTE route)
Save a ROUTE, if either its source or dest object name is remapped according to the defMapTable, redo the token.


hasROUTEs

public boolean hasROUTEs()
Check if any ROUTEs were saved


getNumberROUTEs

public int getNumberROUTEs()
Get the number of ROUTEs saved


getROUTE

public com.trapezium.vrml.ROUTE getROUTE(int offset)
Get a specific ROUTE that was saved


saveDEFUSENode

void saveDEFUSENode(com.trapezium.vrml.node.DEFUSENode dun)
Save a DEFUSENode. If it is a DEF, it is renamed if its name conflicts with one in the destination scene. The DEF is also registered with the destination scene to allow detection of other conflicts. If it is a USE, it is renamed if the corresponding DEF was renamed.


savePROTO

void savePROTO(com.trapezium.vrml.node.PROTObase proto)
Save a PROTO, renaming it if its name conflicts with one in the destination scene. The PROTO is also registered in the destination scene, since this is its ultimate destination, so that conflicts between this and others merging into the same destination are detected.


savePROTOinstance

void savePROTOinstance(com.trapezium.vrml.node.PROTOInstance a)
Save a PROTOInstance, if the PROTO declaration has a naming conflict all PROTOInstances must be renamed. This method saves the location of a PROTOInstance in case this is necessary.


scanTokens

public void scanTokens()
Start scanning tokens in the scene to merge


hasMoreTokens

public boolean hasMoreTokens()
Check if there are more tokens to access in the scene to merge


protoIsRemapped

public boolean protoIsRemapped(int tokenOffset)
Is there a PROTO instance at a particular token offset that is renamed due to a PROTO declaration conflict.


useIsRemapped

public boolean useIsRemapped(int tokenOffset)
Is there a USE node at a particular token offset that is renamed due to a DEF declaration conflict.


remapProto

public java.lang.String remapProto(int tokenOffset)
Get the name for a remapped PROTO.


remapUse

public java.lang.String remapUse(int tokenOffset)
Get the name for a remapped USE node.


remap

java.lang.String remap(int tokenOffset,
                       java.util.Hashtable table)
Generic remapping of Strings based on token offset.


getNextToken

public int getNextToken()
Get the next token offset