public class ScanWriteUtils
extends java.lang.Object
| Constructor and Description | 
|---|
| ScanWriteUtils() | 
| Modifier and Type | Method and Description | 
|---|---|
| static boolean | getTokenPrinting()Returns  trueif token printing is enabled in thescanfull()method. | 
| static boolean | postscanAttributeName(java.util.Deque<ScanToken> tokens,
                     java.lang.String name)Checks if the next token in the queue is a StringToken
 containing the specified name. | 
| static <C> C | postscanComponent(java.util.Deque<ScanToken> tokens,
                 java.lang.Class<C> clazz,
                 CompositeComponent ancestor)Calls  postscan()for an component stored in the token queue. | 
| static boolean | postscanComponent(java.util.Deque<ScanToken> tokens,
                 CompositeComponent ancestor)Checks if the next token on the queue is an ObjectToken
 holding a component reference. | 
| static boolean | postscanComponent(java.util.Deque<ScanToken> tokens,
                 java.lang.String name,
                 CompositeComponent ancestor)Checks if the next token on the queue is a StringToken matching a 
 specific attribute name. | 
| static void | postscanComponentBegin(java.util.Deque<ScanToken> tokens,
                      ModelComponent comp)Checks if the next token in the queue is a BEGIN token for
 a component, and if so, consumes it. | 
| static ScanToken | postscanComponentToken(java.util.Deque<ScanToken> tokens)Checks if the next token on the queue is an ObjectToken
 holding a component reference. | 
| static java.util.ArrayList<Property> | postscanProperties(java.util.Deque<ScanToken> tokens,
                  CompositeComponent ancestor)Checks that the next set of tokens in the stream consist of
 a BEGIN token, a set of property paths, and an END token. | 
| static Property | postscanProperty(java.util.Deque<ScanToken> tokens,
                CompositeComponent ancestor)Removes the next token from the queue, checks that it is a StringToken
 containing a property path relative to  ancestor, and locates
 and returns the property. | 
| static boolean | postscanPropertyValue(java.util.Deque<ScanToken> tokens,
                     HasProperties host,
                     java.lang.String propName)Checks if the next token in the queue is a StringToken containing a
 specified property name. | 
| static boolean | postscanPropertyValues(java.util.Deque<ScanToken> tokens,
                      HasProperties host,
                      java.lang.String[] propNames)Checks if the next token in the queue is a StringToken
 containing one of a specified set of property names. | 
| static <C> C | postscanReference(java.util.Deque<ScanToken> tokens,
                 java.lang.Class<C> clazz,
                 CompositeComponent ancestor)Removes the next token from the queue, checks that it is a StringToken 
 containing a reference path relative to  ancestor, locates
 the referenced component, verifies that it is an instance ofclazz, and returns it. | 
| static <C> C | postscanReference(StringToken strtok,
                 java.lang.Class<C> clazz,
                 CompositeComponent ancestor) | 
| static <C> C[] | postscanReferences(java.util.Deque<ScanToken> tokens,
                  java.lang.Class<C> clazz,
                  CompositeComponent ancestor)Checks that the next set of tokens in the stream consist of
 a BEGIN token, a set of reference path names, and an END token. | 
| static <C> void | postscanReferences(java.util.Deque<ScanToken> tokens,
                  java.util.Collection<C> refs,
                  java.lang.Class<C> clazz,
                  CompositeComponent ancestor)Checks that the next set of tokens in the stream consist of
 a BEGIN token, a set of reference path names, and an END token. | 
| static void | printTokens(java.util.Deque<ScanToken> tokens)Diagnostic method to print a token queue to the standard 
 output stream. | 
| static void | printTokens(java.io.PrintWriter pw,
           java.util.Deque<ScanToken> tokens)Diagnostic method to print a token queue to a print writer. | 
| static void | scanAndDiscard(ReaderTokenizer rtok)Scans and discards the input associated with a component, which is
 assumed to be enclosed within square brackets. | 
| static boolean | scanAndStoreComponent(ReaderTokenizer rtok,
                     java.lang.String name,
                     java.util.Deque<ScanToken> tokens)Attempts to scan a class-qualified component associated with a given
 attribute name. | 
| static void | scanAndStorePropertyPath(ReaderTokenizer rtok,
                        java.util.Deque<ScanToken> tokens)If the next input token is a quoted string or word, then assume that
 it corresponds to property path, store its value
 in the token queue as a  StringToken, and returntrue. | 
| static boolean | scanAndStorePropertyPath(ReaderTokenizer rtok,
                        java.lang.String name,
                        java.util.Deque<ScanToken> tokens)Attempts to scan a property path associated with a given attribute name. | 
| static int | scanAndStorePropertyPaths(ReaderTokenizer rtok,
                         java.util.Deque<ScanToken> tokens)Assumes that the next set of input tokens are a set of property
 paths enclosed between square brackets. | 
| static int | scanAndStorePropertyPaths(ReaderTokenizer rtok,
                         java.lang.String name,
                         java.util.Deque<ScanToken> tokens)Attempts to scan a set of property paths associated with a given attribute
 name. | 
| static boolean | scanAndStorePropertyValue(ReaderTokenizer rtok,
                         HasProperties host,
                         java.lang.String propName,
                         java.util.Deque<ScanToken> tokens)Attempts to scan and store a specific property value for a specified
 host. | 
| static boolean | scanAndStorePropertyValues(ReaderTokenizer rtok,
                          HasProperties host,
                          java.lang.String[] propNames,
                          java.util.Deque<ScanToken> tokens)Attempts to scan and store a specific set of property values
 for a specified host. | 
| static boolean | scanAndStoreReference(ReaderTokenizer rtok,
                     java.util.Deque<ScanToken> tokens)If the next input token is a quoted string or word, then assume that
 it corresponds to component reference path, store its value
 in the token queue as a  StringToken, and returntrue. | 
| static boolean | scanAndStoreReference(ReaderTokenizer rtok,
                     java.lang.String name,
                     java.util.Deque<ScanToken> tokens)Attempts to scan a reference path associated with a given attribute name. | 
| static int | scanAndStoreReferences(ReaderTokenizer rtok,
                      java.util.Deque<ScanToken> tokens)Assumes that the next set of input tokens are a set of component 
 reference paths enclosed between square brackets. | 
| static int | scanAndStoreReferences(ReaderTokenizer rtok,
                      java.lang.String name,
                      java.util.Deque<ScanToken> tokens)Attempts to scan a set of reference paths associated with a given 
 attribute name. | 
| static boolean | scanAttributeName(ReaderTokenizer rtok,
                 java.lang.String name) | 
| static void | scanfull(ReaderTokenizer rtok,
        ModelComponent comp,
        CompositeComponent ancestor)Performs both a scan and a postscan for a specific component. | 
| static boolean | scanProperty(ReaderTokenizer rtok,
            HasProperties host)Attempts to scan and set a property value for a specified host. | 
| static java.lang.Object | scanPropertyValue(ReaderTokenizer rtok,
                 HasProperties host,
                 java.lang.String propName)Scans a specific property value for a 
 host, assuming that the property name has already been
 scanned and matched. | 
| static Vector3d[] | scanVector3dList(ReaderTokenizer rtok) | 
| static void | setTokenPrinting(boolean enable)Debugging hook to enable printing of the token queue produced
 in the  scanfull()method, beforepostscan()is called. | 
| static void | writeBracketedReferences(java.io.PrintWriter pw,
                        java.util.Collection<? extends ModelComponent> comps,
                        CompositeComponent ancestor)Writes the reference paths for a set of components to a
 print writer, enclosed by square brackets. | 
| static void | writeComponent(java.io.PrintWriter pw,
              NumberFormat fmt,
              Scannable obj,
              java.lang.Object ref)Writes a class-qualified component to a print writer. | 
| static void | writeReferences(java.io.PrintWriter pw,
               java.lang.Iterable<ModelComponent> comps,
               CompositeComponent ancestor)Writes the reference paths for a set of components to a
 print writer. | 
| static void | writeVector3dList(java.io.PrintWriter pw,
                 NumberFormat fmt,
                 Vector3d[] list) | 
public static void setTokenPrinting(boolean enable)
scanfull() method, before postscan()
 is called.enable - if true, enables token printing.public static boolean getTokenPrinting()
true if token printing is enabled in the
 scanfull() method.true if token printing is enabled in 
 scan()public static boolean scanAndStoreReference(ReaderTokenizer rtok, java.util.Deque<ScanToken> tokens) throws java.io.IOException
StringToken, and return
 true.rtok - input token streamtokens - token queue for postscantrue if reference path is scanned and stored 
 in the queue as a StringTokenjava.io.IOException - if an I/O or syntax error occurredpublic static int scanAndStoreReferences(ReaderTokenizer rtok, java.util.Deque<ScanToken> tokens) throws java.io.IOException
StringTokens, and return the number
 of reference paths found.rtok - input token streamtokens - token storage queue for postscanjava.io.IOException - if an I/O or syntax error occurredpublic static boolean scanAttributeName(ReaderTokenizer rtok, java.lang.String name) throws java.io.IOException
java.io.IOExceptionpublic static void scanAndStorePropertyPath(ReaderTokenizer rtok, java.util.Deque<ScanToken> tokens) throws java.io.IOException
StringToken, and return
 true.rtok - input token streamtokens - token storage queue for postscanjava.io.IOException - if an I/O or syntax error occurredpublic static int scanAndStorePropertyPaths(ReaderTokenizer rtok, java.util.Deque<ScanToken> tokens) throws java.io.IOException
StringTokens, and return the number
 of paths found.rtok - input token streamtokens - token storage queue for postscanjava.io.IOException - if an I/O or syntax error occurredpublic static boolean scanAndStoreReference(ReaderTokenizer rtok, java.lang.String name, java.util.Deque<ScanToken> tokens) throws java.io.IOException
true.
 Otherwise, returns false.rtok - input token streamname - attribute nametokens - token storage queue for postscanjava.io.IOException - if an I/O or syntax error occurredpublic static int scanAndStoreReferences(ReaderTokenizer rtok, java.lang.String name, java.util.Deque<ScanToken> tokens) throws java.io.IOException
rtok - input token streamname - attribute nametokens - token storage queue for postscanjava.io.IOException - if an I/O or syntax error occurredpublic static boolean scanAndStorePropertyPath(ReaderTokenizer rtok, java.lang.String name, java.util.Deque<ScanToken> tokens) throws java.io.IOException
true.
 Otherwise, return false.rtok - input token streamname - attribute nametokens - token storage queue for postscanjava.io.IOException - if an I/O or syntax error occurredpublic static int scanAndStorePropertyPaths(ReaderTokenizer rtok, java.lang.String name, java.util.Deque<ScanToken> tokens) throws java.io.IOException
true.
 Otherwise, return false.rtok - input token streamname - attribute nametokens - token storage queue for postscanjava.io.IOException - if an I/O or syntax error occurredpublic static boolean postscanAttributeName(java.util.Deque<ScanToken> tokens, java.lang.String name)
true. Otherwise, returns false.tokens - queue of stored tokensname - name to check on the token queuetrue if the next token is a StringToken containing
 name.public static void postscanComponentBegin(java.util.Deque<ScanToken> tokens, ModelComponent comp) throws java.io.IOException
tokens - queue of stored tokenscomp - component associated with the BEGINjava.io.IOException - if an I/O or syntax error occurredpublic static boolean postscanComponent(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor) throws java.io.IOException
true.
 Otherwise, returns false.tokens - queue of stored tokensancestor - ancestor for evaluating reference pathsjava.io.IOException - if unexpected token input was encounteredpublic static boolean postscanComponent(java.util.Deque<ScanToken> tokens, java.lang.String name, CompositeComponent ancestor) throws java.io.IOException
tokens - queue of stored tokensname - attribute nameancestor - ancestor for evaluating reference pathsjava.io.IOException - if unexpected token input was encounteredpublic static ScanToken postscanComponentToken(java.util.Deque<ScanToken> tokens) throws java.io.IOException
null.tokens - queue of stored tokensnull.java.io.IOException - if unexpected token input was encounteredpublic static <C> C postscanReference(StringToken strtok, java.lang.Class<C> clazz, CompositeComponent ancestor) throws java.io.IOException
java.io.IOExceptionpublic static <C> C postscanReference(java.util.Deque<ScanToken> tokens, java.lang.Class<C> clazz, CompositeComponent ancestor) throws java.io.IOException
ancestor, locates
 the referenced component, verifies that it is an instance of 
 clazz, and returns it.tokens - queue of stored tokensclazz - class that the referenced component must be an instance ofancestor - ancestor for the reference pathjava.io.IOException - if the next token is not a StringToken or
 if the reference cannot be foundpublic static <C> C[] postscanReferences(java.util.Deque<ScanToken> tokens, java.lang.Class<C> clazz, CompositeComponent ancestor) throws java.io.IOException
ancestor, type checked to ensure that they are
 instances of clazz, and then returned as an array.tokens - queue of stored tokensclazz - class that each referenced component must be an instance ofancestor - ancestor for the reference pathjava.io.IOException - if the token structure is incorrect or if
 the referenced components cannot be found.public static <C> void postscanReferences(java.util.Deque<ScanToken> tokens, java.util.Collection<C> refs, java.lang.Class<C> clazz, CompositeComponent ancestor) throws java.io.IOException
ancestor, type checked to ensure that they are
 instances of clazz, and then returned in
 the collection refs.tokens - queue of stored tokensrefs - returns the component referencesclazz - class that each referenced component must be an instance ofancestor - ancestor for the reference pathjava.io.IOException - if the token structure is incorrect or if
 the referenced components cannot be found.public static Property postscanProperty(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor) throws java.io.IOException
ancestor, and locates
 and returns the property.tokens - queue of stored tokensancestor - ancestor for the property pathjava.io.IOException - if the next token is not a StringToken or
 if the property cannot be foundpublic static java.util.ArrayList<Property> postscanProperties(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor) throws java.io.IOException
ancestor and returned in an ArrayList.tokens - queue of stored tokensancestor - ancestor for the reference pathjava.io.IOException - if the token structure is incorrect or if
 the properties cannot be foundpublic static void scanfull(ReaderTokenizer rtok, ModelComponent comp, CompositeComponent ancestor) throws java.io.IOException
rtok - input token streamcomp - component to scanancestor - ancestor component for resolving referencesjava.io.IOException - if an I/O or syntax error occurredpublic static void scanAndDiscard(ReaderTokenizer rtok) throws java.io.IOException
rtok - input token streamjava.io.IOExceptionpublic static void printTokens(java.util.Deque<ScanToken> tokens)
tokens - token queue to be printedpublic static void printTokens(java.io.PrintWriter pw,
                               java.util.Deque<ScanToken> tokens)
pw - print writer for printing the token queuetokens - token queue to be printedpublic static boolean scanProperty(ReaderTokenizer rtok, HasProperties host) throws java.io.IOException
true.
 Otherwise, return false.rtok - input token streamhost - host containing the propertytrue if a property was matched and scannedjava.io.IOException - if an I/O or syntax error occurredpublic static java.lang.Object scanPropertyValue(ReaderTokenizer rtok, HasProperties host, java.lang.String propName) throws java.io.IOException
rtok - input token streamhost - host containing the propertypropName - property to try and scanjava.io.IOException - if an I/O or syntax error occurredpublic static boolean scanAndStorePropertyValues(ReaderTokenizer rtok, HasProperties host, java.lang.String[] propNames, java.util.Deque<ScanToken> tokens) throws java.io.IOException
StrinToken and an ObjectToken, 
 and return true.
 Otherwise, return false.
 This method is intended for handling property values which must be set in the post-scan stage after references have been set.
rtok - input token streamhost - host containing the propertiespropNames - names of properties to matchtokens - token queue for postscantrue if a property value was scanned
 and stored.java.io.IOException - if an I/O or syntax error occurredpublic static boolean scanAndStorePropertyValue(ReaderTokenizer rtok, HasProperties host, java.lang.String propName, java.util.Deque<ScanToken> tokens) throws java.io.IOException
StrinToken and an ObjectToken, and return
 true.  Otherwise, return false.
 This method is intended for handling property values which must be set in the post-scan stage after references have been set.
rtok - input token streamhost - host containing the propertiespropName - name of the property to matchtokens - token queue for postscantrue if z roperty value was scanned
 and stored.java.io.IOException - if an I/O or syntax error occurredpublic static boolean postscanPropertyValues(java.util.Deque<ScanToken> tokens, HasProperties host, java.lang.String[] propNames) throws java.io.IOException
true. Otherwise,
 returns false.tokens - queue of stored tokenshost - host containing the propertiespropNames - names of the properties to matchtrue if a property was matched and setjava.io.IOException - if an I/O or syntax error occurredpublic static boolean postscanPropertyValue(java.util.Deque<ScanToken> tokens, HasProperties host, java.lang.String propName) throws java.io.IOException
true. Otherwise, returns
 false.tokens - queue of stored tokenshost - host containing the propertiespropName - names of the property to matchtrue if a property was matched and setjava.io.IOException - if an I/O or syntax error occurredpublic static void writeBracketedReferences(java.io.PrintWriter pw,
                                            java.util.Collection<? extends ModelComponent> comps,
                                            CompositeComponent ancestor)
                                     throws java.io.IOException
pw - PrintWriter to write the references tocomps - components providing the reference pathsancestor - ancestor component with respect to which reference
 paths should be generatedjava.io.IOExceptionpublic static void writeReferences(java.io.PrintWriter pw,
                                   java.lang.Iterable<ModelComponent> comps,
                                   CompositeComponent ancestor)
                            throws java.io.IOException
writeBracketedReferences(), the paths are not enclosed
 within square brackets.pw - PrintWriter to write the references tocomps - components providing the reference pathsancestor - ancestor component with respect to which reference
 paths should be generatedjava.io.IOExceptionpublic static boolean scanAndStoreComponent(ReaderTokenizer rtok, java.lang.String name, java.util.Deque<ScanToken> tokens) throws java.io.IOException
true.  Otherwise, returns false.rtok - input token streamname - attribute nametokens - token storage queue for postscanjava.io.IOException - if an I/O or syntax error occurredpublic static <C> C postscanComponent(java.util.Deque<ScanToken> tokens, java.lang.Class<C> clazz, CompositeComponent ancestor) throws java.io.IOException
postscan() for an component stored in the token queue.
 Removes the next token from the queue, checks that it is an ObjectToken
 containing an component, verifies that the component it is an instance of
 clazz, calls postscan() for the component and
 returns it.tokens - queue of stored tokensclazz - class that the component must be an instance ofancestor - ancestor uses for post-scanning the componentjava.io.IOException - if the next token is not an ObjectToken, the component
 is not an instance of clazz, or an error occured within the
 component's postscan() call.public static void writeComponent(java.io.PrintWriter pw,
                                  NumberFormat fmt,
                                  Scannable obj,
                                  java.lang.Object ref)
                           throws java.io.IOException
pw - PrintWriter to write the component tofmt - numeric format for writing the componentobj - component to be writtenref - reference object used for writing the componentjava.io.IOExceptionpublic static void writeVector3dList(java.io.PrintWriter pw,
                                     NumberFormat fmt,
                                     Vector3d[] list)
                              throws java.io.IOException
java.io.IOExceptionpublic static Vector3d[] scanVector3dList(ReaderTokenizer rtok) throws java.io.IOException
java.io.IOException