Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.export
Class BaseRetainedExporter

java.lang.Object
  extended by org.web3d.vrml.export.Exporter
      extended by org.web3d.vrml.export.BaseRetainedExporter
All Implemented Interfaces:
BinaryContentHandler, ContentHandler, ProtoHandler, RouteHandler, ScriptHandler, StringContentHandler
Direct Known Subclasses:
X3DClassicRetainedExporter, X3DRetainedSAXExporter

public abstract class BaseRetainedExporter
extends Exporter
implements BinaryContentHandler

An exporter that brings the whole file into memory before exporting. This has same advantages and disadvantages. Advantages: Ease of implementation. Streamed writing has several difficulties. Disadvantages: Comments will be lost Locations of import/exports/proto decls/routes might be changed. Upgrade logic must be in terminal files unless we want to track current node/field In the future we'd like to perform this across a SAI graph(ie no SAV stream to sniff), this block will document what problems that will entail: The DEF table for .wrl files has duplicates, so getDEFNodes loses info ExternProto URL already has worldUrl added in, removeing worldRoot might not work TODO: Count Node num to help place ROUTE in the right place?

Version:
$Revision: 1.29 $
Author:
Alan Hudson

Field Summary
protected  SceneBuilder builder
          The NR scene builder to create the scenegraph
protected  java.util.ArrayList componentList
          Additional components to add, list of ComponentInfo
protected static java.lang.String CONTAINER_PROPS_FILE
          Name of the property file holding the default container fields
protected  java.util.Properties containerFields
          Property for container fields
protected  boolean convertOldContent
          Should VRML97 optional nodes like h-Anim and GeoVRML be converted
protected  org.ietf.uri.ResourceConnection currentConnection
          The current resource connection if being used
protected  java.util.Map currentDefMap
          The current DEF map, node to DEF name
protected  java.util.Map currentIsMap
          The current IS map
protected  PrototypeDecl currentPrototypeDecl
          The current proto definition
protected  VRMLNodeType defaultNode
          The current default valued node
protected  java.util.HashMap defaultNodes
          A cache of nodes with default values
protected  java.lang.String encodingTo
          The current encoding
protected  java.util.HashMap epToUrl
          Mapping of EXTERNPROTO to url[]
protected  VRMLFieldReader fieldReader
          An X3DField reader for converting field types.
protected  java.util.HashMap fieldRemap
          Fields to remap their types.
protected  java.text.NumberFormat floatFormat
          The format string to pass in for float formating
protected  boolean geospatialFound
          Where there Geospatial nodes found
protected  java.util.HashMap geospatialNodes
          Geospatial nodes
protected  boolean hanimFound
          Where there H-Anim nodes found
protected  java.util.HashMap hanimNodes
          H-Anim nodes
protected  java.util.HashMap isCache
          A cache of IS map preprocessed versions
protected  int majorVersion
          The major version of the spec this file belongs to.
protected  int minorVersion
          The minor version of the spec this file belongs to.
protected  VRMLNodeFactory nodeFactory
          The NR node factory to get default values from
protected  java.util.HashMap oldProtos
          Protos/Extern Proto definitions to remove if convertOldContent is true
protected  java.io.OutputStream oStream
          The stream to write results to
protected  boolean processingDocument
          Are we processing a document
protected  java.lang.String profile
          The profile
protected  CRProtoCreator protoCreator
          The creator used to instantiate protos
protected  VRMLScene scene
          The top scene
protected  java.util.regex.Pattern[] scriptPatterns
          Upgrade patterns for scripts
protected  java.lang.String[] scriptReplacements
          The replacement values
protected  int sigDigits
          The number of significant digits when printing floats, -1 not to change
protected  long startTime
          Start time used for optimization
protected  boolean stripWhitespace
          Should we strip whitespace
protected  boolean upgrading
          Are we upgrading from VRML to X3D
 
Fields inherited from class org.web3d.vrml.export.Exporter
errorReporter
 
Constructor Summary
BaseRetainedExporter(int major, int minor, ErrorReporter reporter, int sigDigits)
          Create a new exporter for the given spec version
 
Method Summary
 void componentDecl(java.lang.String componentName)
          A component declaration has been found in the code.
protected  void convertFieldData(int newType, VRMLFieldData data, VRMLFieldDeclaration decl)
          Convert a field data from one type to another.
 void endDocument()
          Declaration of the end of the document.
 void endExternProtoDecl()
          Notification of the end of an EXTERNPROTO declaration.
 void endField()
          Notification of the end of a field declaration.
 void endNode()
          Notification of the end of a node declaration.
 void endProtoBody()
          Notification of the end of an ordinary proto body.
 void endProtoDecl()
          Notification of the end of an ordinary proto declaration statement.
 void endScriptDecl()
          Notification of the end of a script declaration.
 void exportDecl(java.lang.String defName, java.lang.String exported)
          An EXPORT declaration has been found in the document.
 void externProtoURI(java.lang.String[] values)
          Notification of the URI list for an EXTERNPROTO.
 void fieldValue(boolean value)
          Set the value of the field at the given index as an boolean.
 void fieldValue(boolean[] value, int len)
          Set the value of the field at the given index as an array of boolean.
 void fieldValue(double value)
          Set the value of the field at the given index as an double.
 void fieldValue(double[] value, int len)
          Set the value of the field at the given index as an array of doubles.
 void fieldValue(float value)
          Set the value of the field at the given index as a float.
 void fieldValue(float[] value, int len)
          Set the value of the field at the given index as an array of floats.
 void fieldValue(int value)
          Set the value of the field at the given index as an integer.
 void fieldValue(int[] value, int len)
          Set the value of the field at the given index as an array of integers.
 void fieldValue(long value)
          Set the value of the field at the given index as an long.
 void fieldValue(long[] value, int len)
          Set the value of the field at the given index as an array of longs.
 void fieldValue(java.lang.String value)
          The value of a normal field.
 void fieldValue(java.lang.String[] values)
          The value of an MFField where the underlying parser knows about how the values are broken up.
 void fieldValue(java.lang.String[] value, int len)
          Set the value of the field at the given index as an array of strings.
protected  java.lang.String findIS(VRMLNodeType node, int idx, java.util.Map isMap)
          Find the IS relationship for a node.
protected  java.lang.String getPublicId(int major, int minor)
          Get the publicId for this spec version
protected  java.lang.String getSystemId(int major, int minor)
          Get the publicId for this spec version
 void importDecl(java.lang.String inline, java.lang.String exported, java.lang.String imported)
          An IMPORT declaration has been found in the document.
protected  void loadContainerProperties(int majorVersion, int minorVersion)
          Load the properties files for the given spec version.
 void metaDecl(java.lang.String key, java.lang.String value)
          A META declaration has been found in the code.
protected abstract  void printComponents(ComponentInfo[] comps)
          Print the component decl
protected  void printDefMap(java.util.Map defMap)
          Utility to print DEF mapping for debugging purposes.
protected abstract  void printExports(java.util.Map exports)
          Print Exports.
protected abstract  void printHeader(int major, int minor)
          Print the header.
protected abstract  void printImports(java.util.Map imports)
          Print Imports.
protected  void printIS(java.util.Map isMap)
          Utility to print IS mapping for debugging purposes.
protected abstract  void printMetaData(java.util.Map meta)
          Print the MetaData.
protected abstract  void printProfile(java.lang.String profile)
          Print the profile decl.
protected abstract  void printPrototypeDecl(PrototypeDecl proto)
          Print a proto declaration.
protected abstract  void printROUTE(ROUTE route, java.util.Map defMap)
          Print a ROUTE statement.
 void profileDecl(java.lang.String profileName)
          A profile declaration has been found in the code.
 void protoFieldDecl(int access, java.lang.String type, java.lang.String name, java.lang.Object value)
          Notification of a proto's field declaration.
 void protoIsDecl(java.lang.String fieldName)
          Notification of a field value uses an IS statement.
protected  void reverseMap(java.util.Map in, java.util.Map out)
          Reverse a maps key/value mapping.
 void routeDecl(java.lang.String srcNode, java.lang.String srcField, java.lang.String destNode, java.lang.String destField)
          Notification of a ROUTE declaration in the file.
 void scriptFieldDecl(int access, java.lang.String type, java.lang.String name, java.lang.Object value)
          Notification of a script's field declaration.
 void setConvertOldContent(boolean convert)
          Should old optional content like h-Anim and GeoVRML be converted to native nodes.
 void setDocumentLocator(Locator loc)
          Set the document locator that can be used by the implementing code to find out information about the current line information.
 void startDocument(java.lang.String uri, java.lang.String url, java.lang.String encoding, java.lang.String type, java.lang.String version, java.lang.String comment)
          Declaration of the start of the document.
 void startExternProtoDecl(java.lang.String name)
          Notification of the start of an EXTERNPROTO declaration of the given name.
 void startField(java.lang.String name)
          Notification of a field declaration.
 void startNode(java.lang.String name, java.lang.String defName)
          Notification of the start of a node.
 void startProtoBody()
          Notification of the start of an ordinary proto body.
 void startProtoDecl(java.lang.String name)
          Notification of the start of an ordinary (inline) proto declaration.
 void startScriptDecl()
          Notification of the start of a script declaration.
 void useDecl(java.lang.String defName)
          The field value is a USE for the given node name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTAINER_PROPS_FILE

protected static final java.lang.String CONTAINER_PROPS_FILE
Name of the property file holding the default container fields

See Also:
Constant Field Values

oStream

protected java.io.OutputStream oStream
The stream to write results to


majorVersion

protected int majorVersion
The major version of the spec this file belongs to.


minorVersion

protected int minorVersion
The minor version of the spec this file belongs to.


builder

protected SceneBuilder builder
The NR scene builder to create the scenegraph


nodeFactory

protected VRMLNodeFactory nodeFactory
The NR node factory to get default values from


defaultNodes

protected java.util.HashMap defaultNodes
A cache of nodes with default values


defaultNode

protected VRMLNodeType defaultNode
The current default valued node


upgrading

protected boolean upgrading
Are we upgrading from VRML to X3D


currentDefMap

protected java.util.Map currentDefMap
The current DEF map, node to DEF name


currentIsMap

protected java.util.Map currentIsMap
The current IS map


currentPrototypeDecl

protected PrototypeDecl currentPrototypeDecl
The current proto definition


protoCreator

protected CRProtoCreator protoCreator
The creator used to instantiate protos


scene

protected VRMLScene scene
The top scene


profile

protected java.lang.String profile
The profile


componentList

protected java.util.ArrayList componentList
Additional components to add, list of ComponentInfo


epToUrl

protected java.util.HashMap epToUrl
Mapping of EXTERNPROTO to url[]


scriptPatterns

protected java.util.regex.Pattern[] scriptPatterns
Upgrade patterns for scripts


scriptReplacements

protected java.lang.String[] scriptReplacements
The replacement values


convertOldContent

protected boolean convertOldContent
Should VRML97 optional nodes like h-Anim and GeoVRML be converted


oldProtos

protected java.util.HashMap oldProtos
Protos/Extern Proto definitions to remove if convertOldContent is true


fieldRemap

protected java.util.HashMap fieldRemap
Fields to remap their types. Node.fieldName -> new type


hanimFound

protected boolean hanimFound
Where there H-Anim nodes found


hanimNodes

protected java.util.HashMap hanimNodes
H-Anim nodes


geospatialFound

protected boolean geospatialFound
Where there Geospatial nodes found


geospatialNodes

protected java.util.HashMap geospatialNodes
Geospatial nodes


isCache

protected java.util.HashMap isCache
A cache of IS map preprocessed versions


containerFields

protected java.util.Properties containerFields
Property for container fields


encodingTo

protected java.lang.String encodingTo
The current encoding


stripWhitespace

protected boolean stripWhitespace
Should we strip whitespace


processingDocument

protected boolean processingDocument
Are we processing a document


fieldReader

protected VRMLFieldReader fieldReader
An X3DField reader for converting field types.


currentConnection

protected org.ietf.uri.ResourceConnection currentConnection
The current resource connection if being used


startTime

protected long startTime
Start time used for optimization


sigDigits

protected int sigDigits
The number of significant digits when printing floats, -1 not to change


floatFormat

protected java.text.NumberFormat floatFormat
The format string to pass in for float formating

Constructor Detail

BaseRetainedExporter

public BaseRetainedExporter(int major,
                            int minor,
                            ErrorReporter reporter,
                            int sigDigits)
Create a new exporter for the given spec version

Parameters:
major - The major version number of this scene
minor - The minor version number of this scene
reporter - The error reporter to use
sigDigits - The number of significant digits for floats, -1 for unchanged
Method Detail

setConvertOldContent

public void setConvertOldContent(boolean convert)
Should old optional content like h-Anim and GeoVRML be converted to native nodes.

Parameters:
convert - true to convert the protos

printHeader

protected abstract void printHeader(int major,
                                    int minor)
Print the header.

Parameters:
major - The major version
minor - The minor version

printProfile

protected abstract void printProfile(java.lang.String profile)
Print the profile decl.

Parameters:
profile - The profile

printComponents

protected abstract void printComponents(ComponentInfo[] comps)
Print the component decl

Parameters:
comps - The component list

printMetaData

protected abstract void printMetaData(java.util.Map meta)
Print the MetaData.

Parameters:
meta - The scene Metadata map

printPrototypeDecl

protected abstract void printPrototypeDecl(PrototypeDecl proto)
Print a proto declaration.

Parameters:
proto - The decl to print

printROUTE

protected abstract void printROUTE(ROUTE route,
                                   java.util.Map defMap)
Print a ROUTE statement.

Parameters:
route - The ROUTE to print
defMap - The DEF map

printExports

protected abstract void printExports(java.util.Map exports)
Print Exports.

Parameters:
exports - A map of exports(name,AS).

printImports

protected abstract void printImports(java.util.Map imports)
Print Imports.

Parameters:
imports - A map of imports(exported, String[] {def, as}.

endDocument

public void endDocument()
                 throws SAVException,
                        VRMLException
Declaration of the end of the document. There will be no further parsing and hence events after this.

Specified by:
endDocument in interface ContentHandler
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

setDocumentLocator

public void setDocumentLocator(Locator loc)
Set the document locator that can be used by the implementing code to find out information about the current line information. This method is called by the parser to your code to give you a locator to work with. If this has not been set by the time startDocument() has been called, you can assume that you will not have one available.

Specified by:
setDocumentLocator in interface ContentHandler
Parameters:
loc - The locator instance to use

startDocument

public void startDocument(java.lang.String uri,
                          java.lang.String url,
                          java.lang.String encoding,
                          java.lang.String type,
                          java.lang.String version,
                          java.lang.String comment)
                   throws SAVException,
                          VRMLException
Declaration of the start of the document. The parameters are all of the values that are declared on the header line of the file after the # start. The type string contains the representation of the first few characters of the file after the #. This allows us to work out if it is VRML97 or the later X3D spec.

Version numbers change from VRML97 to X3D and aren't logical. In the first, it is #VRML V2.0 and the second is #X3D V1.0 even though this second header represents a later spec.

Specified by:
startDocument in interface ContentHandler
Parameters:
uri - The URI of the file.
url - The base URL of the file for resolving relative URIs contained in the file
encoding - The encoding of this document - utf8 or binary
type - The bytes of the first part of the file header
version - The VRML version of this document
comment - Any trailing text on this line. If there is none, this is null.
Throws:
SAVException - This call is taken at the wrong time in the structure of the document
VRMLException - The content provided is invalid for this part of the document or can't be parsed

profileDecl

public void profileDecl(java.lang.String profileName)
                 throws SAVException,
                        VRMLException
A profile declaration has been found in the code. IAW the X3D specification, this method will only ever be called once in the lifetime of the parser for this document. The name is the name of the profile for the document to use.

Specified by:
profileDecl in interface ContentHandler
Parameters:
profileName - The name of the profile to use
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

componentDecl

public void componentDecl(java.lang.String componentName)
                   throws SAVException,
                          VRMLException
A component declaration has been found in the code. There may be zero or more component declarations in the file, appearing just after the profile declaration. The textual information after the COMPONENT keyword is left unparsed and presented through this call. It is up to the user application to parse the component information.

Specified by:
componentDecl in interface ContentHandler
Parameters:
componentName - The name of the component to use
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

metaDecl

public void metaDecl(java.lang.String key,
                     java.lang.String value)
              throws SAVException,
                     VRMLException
A META declaration has been found in the code. There may be zero or more meta declarations in the file, appearing just after the component declaration. Each meta declaration has a key and value strings. No information is to be implied from this. It is for extra data only.

Specified by:
metaDecl in interface ContentHandler
Parameters:
key - The value of the key string
value - The value of the value string
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

importDecl

public void importDecl(java.lang.String inline,
                       java.lang.String exported,
                       java.lang.String imported)
                throws SAVException,
                       VRMLException
An IMPORT declaration has been found in the document. All three parameters will always be provided, regardless of whether the AS keyword has been used or not. The parser implementation will automatically set the local import name as needed.

Specified by:
importDecl in interface ContentHandler
Parameters:
inline - The name of the inline DEF nodes
exported - The exported name from the inlined file
imported - The local name to use for the exported name
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

exportDecl

public void exportDecl(java.lang.String defName,
                       java.lang.String exported)
                throws SAVException,
                       VRMLException
An EXPORT declaration has been found in the document. Both paramters will always be provided regardless of whether the AS keyword has been used. The parser implementation will automatically set the exported name as needed.

Specified by:
exportDecl in interface ContentHandler
Parameters:
defName - The DEF name of the nodes to be exported
exported - The name to be exported as
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

startNode

public void startNode(java.lang.String name,
                      java.lang.String defName)
               throws SAVException,
                      VRMLException
Notification of the start of a node. This is the opening statement of a node and it's DEF name. USE declarations are handled in a separate method.

Specified by:
startNode in interface ContentHandler
Parameters:
name - The name of the node that we are about to parse
defName - The string associated with the DEF name. Null if not given for this node.
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

endNode

public void endNode()
             throws SAVException,
                    VRMLException
Notification of the end of a node declaration.

Specified by:
endNode in interface ContentHandler
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

startField

public void startField(java.lang.String name)
                throws SAVException,
                       VRMLException
Notification of a field declaration. This notification is only called if it is a standard node. If the node is a script or PROTO declaration then the ScriptHandler or ProtoHandler methods are used.

Specified by:
startField in interface ContentHandler
Parameters:
name - The name of the field declared
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(java.lang.String value)
                throws SAVException,
                       VRMLException
The value of a normal field. This is a string that represents the entire value of the field. MFStrings will have to be parsed. This is a terminating call for startField as well. The next call will either be another startField() or endNode().

If this field is an SFNode with a USE declaration you will have the useDecl(String) method called rather than this method. If the SFNode is empty the value returned here will be "NULL".

There are times where we have an MFField that is declared in the file to be empty. To signify this case, this method will be called with a parameter value of null. A lot of the time this is because we can't really determine if the incoming node is an MFNode or not.

Specified by:
fieldValue in interface BinaryContentHandler
Specified by:
fieldValue in interface StringContentHandler
Parameters:
value - The value of this field
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(java.lang.String[] values)
                throws SAVException,
                       VRMLException
The value of an MFField where the underlying parser knows about how the values are broken up. The parser is not required to support this callback, but implementors of this interface should understand it. The most likely time we will have this method called is for MFString or URL lists. If called, it is guaranteed to split the strings along the SF node type boundaries.

Specified by:
fieldValue in interface StringContentHandler
Parameters:
values - The list of string representing the values
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(int value)
                throws SAVException,
                       VRMLException
Set the value of the field at the given index as an integer. This would be used to set SFInt32 field types.

Specified by:
fieldValue in interface BinaryContentHandler
Parameters:
value - The new value to use for the node
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(int[] value,
                       int len)
                throws SAVException,
                       VRMLException
Set the value of the field at the given index as an array of integers. This would be used to set MFInt32 field types.

Specified by:
fieldValue in interface BinaryContentHandler
Parameters:
value - The new value to use for the node
len - The number of valid entries in the value array
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(boolean value)
                throws SAVException,
                       VRMLException
Set the value of the field at the given index as an boolean. This would be used to set SFBool field types.

Specified by:
fieldValue in interface BinaryContentHandler
Parameters:
value - The new value to use for the node
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(boolean[] value,
                       int len)
                throws SAVException,
                       VRMLException
Set the value of the field at the given index as an array of boolean. This would be used to set MFBool field types.

Specified by:
fieldValue in interface BinaryContentHandler
Parameters:
value - The new value to use for the node
len - The number of valid entries in the value array
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(float value)
                throws SAVException,
                       VRMLException
Set the value of the field at the given index as a float. This would be used to set SFFloat field types.

Specified by:
fieldValue in interface BinaryContentHandler
Parameters:
value - The new value to use for the node
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(float[] value,
                       int len)
                throws SAVException,
                       VRMLException
Set the value of the field at the given index as an array of floats. This would be used to set MFFloat, SFVec2f, SFVec3f and SFRotation field types.

Specified by:
fieldValue in interface BinaryContentHandler
Parameters:
value - The new value to use for the node
len - The number of valid entries in the value array
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(long value)
                throws SAVException,
                       VRMLException
Set the value of the field at the given index as an long. This would be used to set SFTime field types.

Specified by:
fieldValue in interface BinaryContentHandler
Parameters:
value - The new value to use for the node
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(long[] value,
                       int len)
                throws SAVException,
                       VRMLException
Set the value of the field at the given index as an array of longs. This would be used to set MFTime field types.

Specified by:
fieldValue in interface BinaryContentHandler
Parameters:
value - The new value to use for the node
len - The number of valid entries in the value array
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(double value)
                throws SAVException,
                       VRMLException
Set the value of the field at the given index as an double. This would be used to set SFDouble field types.

Specified by:
fieldValue in interface BinaryContentHandler
Parameters:
value - The new value to use for the node
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(double[] value,
                       int len)
                throws SAVException,
                       VRMLException
Set the value of the field at the given index as an array of doubles. This would be used to set MFDouble, SFVec2d and SFVec3d field types.

Specified by:
fieldValue in interface BinaryContentHandler
Parameters:
value - The new value to use for the node
len - The number of valid entries in the value array
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

fieldValue

public void fieldValue(java.lang.String[] value,
                       int len)
                throws SAVException,
                       VRMLException
Set the value of the field at the given index as an array of strings. This would be used to set MFString field types.

Specified by:
fieldValue in interface BinaryContentHandler
Parameters:
value - The new value to use for the node
len - The number of valid entries in the value array
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

useDecl

public void useDecl(java.lang.String defName)
             throws SAVException,
                    VRMLException
The field value is a USE for the given node name. This is a terminating call for startField as well. The next call will either be another startField() or endNode().

Specified by:
useDecl in interface ContentHandler
Parameters:
defName - The name of the DEF string to use
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

endField

public void endField()
              throws SAVException,
                     VRMLException
Notification of the end of a field declaration. This is called only at the end of an MFNode declaration. All other fields are terminated by either useDecl(String) or fieldValue(String). This will only ever be called if there have been nodes declared. If no nodes have been declared (ie "[]") then you will get a fieldValue(). call with the parameter value of null.

Specified by:
endField in interface ContentHandler
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

routeDecl

public void routeDecl(java.lang.String srcNode,
                      java.lang.String srcField,
                      java.lang.String destNode,
                      java.lang.String destField)
               throws SAVException,
                      VRMLException
Notification of a ROUTE declaration in the file. The context of this route should be assumed from the surrounding calls to start and end of proto and node bodies.

Specified by:
routeDecl in interface RouteHandler
Parameters:
srcNode - The name of the DEF of the source node
srcField - The name of the field to route values from
destNode - The name of the DEF of the destination node
destField - The name of the field to route values to
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException

startScriptDecl

public void startScriptDecl()
                     throws SAVException,
                            VRMLException
Notification of the start of a script declaration. All calls between now and the corresponding endScriptDecl() call belong to this script node. This method will be called after the ContentHandler startNode() method call. All DEF information is contained in that method call and this just signifies the start of script processing so that we know to treat the field parsing callbacks a little differently.

Specified by:
startScriptDecl in interface ScriptHandler
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

endScriptDecl

public void endScriptDecl()
                   throws SAVException,
                          VRMLException
Notification of the end of a script declaration. This is guaranteed to be called before the ContentHandler endNode() callback.

Specified by:
endScriptDecl in interface ScriptHandler
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

scriptFieldDecl

public void scriptFieldDecl(int access,
                            java.lang.String type,
                            java.lang.String name,
                            java.lang.Object value)
                     throws SAVException,
                            VRMLException
Notification of a script's field declaration. This is used for all fields except url, mustEvaluate and directOutput fields. These fields use the normal field callbacks of ContentHandler.

If the current parsing is in a proto and the field "value" is defined with an IS statement then the value returned here is null. There will be a subsequent call to the ProtoHandlers protoIsDecl() method with the name of the field included.

Specified by:
scriptFieldDecl in interface ScriptHandler
Parameters:
access - The access type (eg exposedField, field etc)
type - The field type (eg SFInt32, MFVec3d etc)
name - The name of the field
value - The default value of the field as either String or String[]. Null if not allowed.
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

startProtoDecl

public void startProtoDecl(java.lang.String name)
                    throws SAVException,
                           VRMLException
Notification of the start of an ordinary (inline) proto declaration. The proto has the given node name.

Specified by:
startProtoDecl in interface ProtoHandler
Parameters:
name - The name of the proto
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

endProtoDecl

public void endProtoDecl()
                  throws SAVException,
                         VRMLException
Notification of the end of an ordinary proto declaration statement. This is called just after the closing bracket of the declaration and before the opening of the body statement. If the next thing called is not a startProtoBody() Then that method should toss an exception.

Specified by:
endProtoDecl in interface ProtoHandler
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

protoFieldDecl

public void protoFieldDecl(int access,
                           java.lang.String type,
                           java.lang.String name,
                           java.lang.Object value)
                    throws SAVException,
                           VRMLException
Notification of a proto's field declaration. This is used for both external and ordinary protos. Externprotos don't allow the declaration of a value for the field. In this case, the parameter value will be null.

Specified by:
protoFieldDecl in interface ProtoHandler
Parameters:
access - The access type (eg exposedField, field etc)
type - The field type (eg SFInt32, MFVec3d etc)
name - The name of the field
value - The default value of the field as either String or String[]. Null if not allowed.
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

protoIsDecl

public void protoIsDecl(java.lang.String fieldName)
                 throws SAVException,
                        VRMLException
Notification of a field value uses an IS statement.

Specified by:
protoIsDecl in interface ProtoHandler
Parameters:
fieldName - The name of the field that is being IS'd
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

startProtoBody

public void startProtoBody()
                    throws SAVException,
                           VRMLException
Notification of the start of an ordinary proto body. All nodes contained between here and the corresponding endProtoBody() statement form the body and not the normal scenegraph information.

Specified by:
startProtoBody in interface ProtoHandler
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

endProtoBody

public void endProtoBody()
                  throws SAVException,
                         VRMLException
Notification of the end of an ordinary proto body. Parsing now returns to ordinary node declarations.

Specified by:
endProtoBody in interface ProtoHandler
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

startExternProtoDecl

public void startExternProtoDecl(java.lang.String name)
                          throws SAVException,
                                 VRMLException
Notification of the start of an EXTERNPROTO declaration of the given name. Between here and the matching endExternProtoDecl() call you should only receive protoFieldDecl(int, java.lang.String, java.lang.String, java.lang.Object) calls.

Specified by:
startExternProtoDecl in interface ProtoHandler
Parameters:
name - The node name of the extern proto
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

endExternProtoDecl

public void endExternProtoDecl()
                        throws SAVException,
                               VRMLException
Notification of the end of an EXTERNPROTO declaration. This is called just after the closing bracket of the declaration and before the opening of the body statement. If the next thing called is not a externProtoURI(java.lang.String[]) Then that method should toss an exception.

Specified by:
endExternProtoDecl in interface ProtoHandler
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

externProtoURI

public void externProtoURI(java.lang.String[] values)
                    throws SAVException,
                           VRMLException
Notification of the URI list for an EXTERNPROTO. This is a complete list as an array of URI strings. The calling application is required to interpet the incoming string. Even if the externproto has no URIs registered, this method shall be called. If there are none available, this will be called with a zero length list of values.

Specified by:
externProtoURI in interface ProtoHandler
Parameters:
values - A list of strings representing all of the URI values
Throws:
SAVException - This call is taken at the wrong time in the structure of the document.
VRMLException - This call is taken at the wrong time in the structure of the document.

findIS

protected java.lang.String findIS(VRMLNodeType node,
                                  int idx,
                                  java.util.Map isMap)
Find the IS relationship for a node.

Parameters:
node - The current node
idx - The current field
isMap - The current IS map

printIS

protected void printIS(java.util.Map isMap)
Utility to print IS mapping for debugging purposes.

Parameters:
isMap - The map to print

printDefMap

protected void printDefMap(java.util.Map defMap)
Utility to print DEF mapping for debugging purposes.

Parameters:
defMap - The map to print

getPublicId

protected java.lang.String getPublicId(int major,
                                       int minor)
Get the publicId for this spec version

Parameters:
major - The major version
minor - The minor version
Returns:
The speced public id

getSystemId

protected java.lang.String getSystemId(