Package org.web3d.vrml.export
Class X3DRetainedSAXExporter
java.lang.Object
org.web3d.vrml.export.Exporter
org.web3d.vrml.export.BaseRetainedExporter
org.web3d.vrml.export.X3DRetainedSAXExporter
- All Implemented Interfaces:
SceneGraphTraversalSimpleObserver
,BinaryContentHandler
,ContentHandler
,ProtoHandler
,RouteHandler
,ScriptHandler
,StringContentHandler
- Direct Known Subclasses:
X3DBinaryRetainedDirectExporter
,X3DXMLRetainedExporter
public abstract class X3DRetainedSAXExporter
extends BaseRetainedExporter
implements SceneGraphTraversalSimpleObserver
A retained exporter that issues SAX events. Extensions of this class
are expected to setup the content handler. This class should contain
as much of the XML specific knowledge as possible.
This implementation will use FastInfoSet's AttributesHolder to
gain a type aware wrapper for attributes.
Known Issues:
Proto node fields are copied into instances
- Version:
- $Revision: 1.11 $
- Author:
- Alan Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Are we exporting to binaryprotected static final int
protected boolean
Should we strip all unnecessary charactersprotected boolean
Switch between methods, should go awayprotected int
The compression method to use for binaryprotected NodeCompressor
The current compressor.protected static final int
protected Map
An empty map to avoid null testingprotected Writer
The passed in writerprotected ContentHandler
The contentHandler to write toprotected boolean
Should we ignore data, its handled by the compressorprotected int
The current indent levelprotected static String
The indent String to replicate per levelprotected org.j3d.util.IntHashMap
<String> A mapping of indent to Stringprotected String
The current indent stringstatic final int
static final int
static final int
static final int
protected boolean
Should we print the DOCTYPEprotected boolean
Should we print the XML Elementprotected Set
<PrototypeDecl> The current set of proto definitionsprotected Map
<String, VRMLFieldDeclaration> Single level proto mapprotected float
The float lossy paramprotected VRMLWorldRootNodeType
The world rootprotected SceneGraphTraverser
Traverser for printing proto'sprotected Set
<VRMLNodeType> Temporary map during traversal for use referencesprotected boolean
Should we use node compressorsExtra attributes on the X3D tagFields inherited from class org.web3d.vrml.export.BaseRetainedExporter
builder, componentList, CONTAINER_PROPS_FILE, containerFields, convertOldContent, currentConnection, currentDefMap, currentIsMap, currentPrototypeDecl, defaultNode, defaultNodes, encodingTo, epToUrl, fieldReader, fieldRemap, geospatialFound, geospatialNodes, hanimFound, hanimNodes, isCache, nodeFactory, oldProtos, oStream, p, processingDocument, profile, protoCreator, scene, scriptPatterns, scriptReplacements, sigDigits, startTime, stripWhitespace, upgrading
Fields inherited from class org.web3d.vrml.export.Exporter
errorReporter, lastErrorCode, majorVersion, minorVersion
-
Constructor Summary
ConstructorsConstructorDescriptionX3DRetainedSAXExporter
(int major, int minor, org.j3d.util.ErrorReporter errorReporter, int compressionMethod, float quantizeParam) Create a new exporter for the given spec versionX3DRetainedSAXExporter
(int major, int minor, org.j3d.util.ErrorReporter errorReporter, int compressionMethod, float quantizeParam, int sigDigits) Create a new exporter for the given spec version -
Method Summary
Modifier and TypeMethodDescriptionprotected String
createX3DString
(VRMLFieldDeclaration decl, double[] val, int numElements) Create an X3D string from an array of valuesprotected String
createX3DString
(VRMLFieldDeclaration decl, float[] val, int numElements) Create an X3D string from an array of valuesprotected String
createX3DString
(VRMLFieldDeclaration decl, int[] val, int numElements) Create an X3D string from an array of valuesprotected void
encodeDoubleArray
(double[] fval, int numElements, VRMLFieldDeclaration decl, String qName, com.sun.xml.fastinfoset.sax.AttributesHolder aholder, int ftype) Encode double array data.protected void
encodeFloatArray
(float[] fval, int numElements, VRMLFieldDeclaration decl, String qName, com.sun.xml.fastinfoset.sax.AttributesHolder aholder, int ftype) Encode float array data.void
Declaration of the end of the document.boolean
Return the flag indicating that the doc type element is to be includedboolean
Return the flag indicating that the xml element is to be includedvoid
observedNode
(VRMLNodeType parent, VRMLNodeType child, int field, boolean used) Notification of a child node.void
printComponents
(ComponentInfo[] comps) Print the component declvoid
printEndNode
(VRMLNodeType node, boolean hadChildren, boolean compressed, Map<Integer, List<ProtoFieldInfo>> isMap) Print the end of a node.void
Print identifying information about this exportervoid
printExports
(Map<String, String> exports) Print Exports.void
Print an external proto declaration.void
printHeader
(int major, int minor) Print the header.void
printImports
(Map<String, VRMLNode> imports) Print Imports.void
printMetaData
(Map<String, String> meta) Print the MetaData.void
printProfile
(String profile) Print the profile decl.void
printPrototypeDecl
(PrototypeDecl proto) Print a proto declaration.void
printROUTE
(ROUTE route, Map<VRMLNode, String> defMap) Print a ROUTE statement.boolean
printStartNode
(VRMLNodeType node, boolean use, Map<VRMLNode, String> defMap, Map<Integer, List<ProtoFieldInfo>> isMap, String containerField, boolean compressed) Print the start of a node, and all its non node fields.void
printStartScriptNode
(AbstractDynamicFieldNode node, com.sun.xml.fastinfoset.sax.AttributesHolder atts, boolean use, Map<VRMLNode, String> defMap, Map<Integer, List<ProtoFieldInfo>> isMap) Print the start of a node, and all its non node fields.void
setPrintDocType
(boolean enable) Set the flag indicating that the doc type element should be includedvoid
setPrintXML
(boolean enable) Set the flag indicating that the xml element should be includedvoid
setX3DAttributes
(Map<String, String> atts) Set attributes to be added to the X3D tag.void
Print a node and its children.void
writeScene
(VRMLScene scene) Write a scene out.Methods inherited from class org.web3d.vrml.export.BaseRetainedExporter
componentDecl, convertFieldData, endExternProtoDecl, endField, endNode, endProtoBody, endProtoDecl, endScriptDecl, exportDecl, externProtoURI, fieldValue, fieldValue, fieldValue, fieldValue, fieldValue, fieldValue, fieldValue, fieldValue, fieldValue, fieldValue, fieldValue, fieldValue, fieldValue, findIS, getPublicId, getSystemId, importDecl, loadContainerProperties, metaDecl, printDefMap, printIS, profileDecl, protoFieldDecl, protoIsDecl, reverseMap, routeDecl, scriptFieldDecl, setConvertOldContent, setDocumentLocator, startDocument, startExternProtoDecl, startField, startNode, startProtoBody, startProtoDecl, startScriptDecl, useDecl
Methods inherited from class org.web3d.vrml.export.Exporter
getLastErrorCode
-
Field Details
-
METHOD_FASTEST_PARSING
public static final int METHOD_FASTEST_PARSING- See Also:
-
METHOD_SMALLEST_NONLOSSY
public static final int METHOD_SMALLEST_NONLOSSY- See Also:
-
METHOD_SMALLEST_LOSSY
public static final int METHOD_SMALLEST_LOSSY- See Also:
-
METHOD_STRINGS
public static final int METHOD_STRINGS- See Also:
-
INDENT_STRING
The indent String to replicate per level -
BYTE_ALGORITHM_ID
protected static final int BYTE_ALGORITHM_ID- See Also:
-
DELTA_ZLIB_INT_ARRAY_ALGORITHM_ID
protected static final int DELTA_ZLIB_INT_ARRAY_ALGORITHM_ID- See Also:
-
EMPTY_MAP
An empty map to avoid null testing -
indent
protected int indentThe current indent level -
indentString
The current indent string -
indentMap
A mapping of indent to String -
usedNodes
Temporary map during traversal for use references -
filterWriter
The passed in writer -
protoDeclSet
The current set of proto definitions -
traverser
Traverser for printing proto's -
root
The world root -
printDocType
protected boolean printDocTypeShould we print the DOCTYPE -
printXML
protected boolean printXMLShould we print the XML Element -
useNC
protected boolean useNCShould we use node compressors -
ignoreData
protected boolean ignoreDataShould we ignore data, its handled by the compressor -
protoMap
Single level proto map -
currentCompressor
The current compressor. Needs to change to a generic interface -
compressedAttWay
protected boolean compressedAttWaySwitch between methods, should go away -
handler
The contentHandler to write to -
compressionMethod
protected int compressionMethodThe compression method to use for binary -
quantizeParam
protected float quantizeParamThe float lossy param -
binary
protected boolean binaryAre we exporting to binary -
x3dAtts
-
compress
protected boolean compressShould we strip all unnecessary characters
-
-
Constructor Details
-
X3DRetainedSAXExporter
public X3DRetainedSAXExporter(int major, int minor, org.j3d.util.ErrorReporter errorReporter, int compressionMethod, float quantizeParam) Create a new exporter for the given spec version- Parameters:
major
- The major version number of this sceneminor
- The minor version number of this sceneerrorReporter
- The error reporter to usecompressionMethod
-quantizeParam
-
-
X3DRetainedSAXExporter
public X3DRetainedSAXExporter(int major, int minor, org.j3d.util.ErrorReporter errorReporter, int compressionMethod, float quantizeParam, int sigDigits) Create a new exporter for the given spec version- Parameters:
major
- The major version number of this sceneminor
- The minor version number of this sceneerrorReporter
- The error reporter to usecompressionMethod
-quantizeParam
-sigDigits
-
-
-
Method Details
-
setX3DAttributes
-
setPrintDocType
public void setPrintDocType(boolean enable) Set the flag indicating that the doc type element should be included- Parameters:
enable
- Flag indicating whether the doc type element should be included
-
getPrintDocType
public boolean getPrintDocType()Return the flag indicating that the doc type element is to be included- Returns:
- Whether the doc type element is to be included
-
setPrintXML
public void setPrintXML(boolean enable) Set the flag indicating that the xml element should be included- Parameters:
enable
- Flag indicating whether the xml element should be included
-
getPrintXML
public boolean getPrintXML()Return the flag indicating that the xml element is to be included- Returns:
- Whether the xml element is to be included
-
createX3DString
Create an X3D string from an array of values- Parameters:
decl
- The declarationval
- The valuenumElements
- The number of elements which make up a single value(ie 3 for MFVec3f)- Returns:
- The value as a string
-
createX3DString
Create an X3D string from an array of values- Parameters:
decl
- The declarationval
- The valuenumElements
- The number of elements which make up a single value(ie 3 for MFVec3f)- Returns:
- The value as a string
-
createX3DString
Create an X3D string from an array of values- Parameters:
decl
- The declarationval
- The valuenumElements
- The number of elements which make up a single value(ie 3 for MFVec3f)- Returns:
- The value as a string
-
encodeFloatArray
protected void encodeFloatArray(float[] fval, int numElements, VRMLFieldDeclaration decl, String qName, com.sun.xml.fastinfoset.sax.AttributesHolder aholder, int ftype) Encode float array data. This base version will just use a string rep- Parameters:
fval
- The parsed float array valuenumElements
- The number of elements per itemdecl
- The field declaration.qName
- The qualified nameaholder
- The current attributes holderftype
- The X3D field type, defined in FieldConstants
-
encodeDoubleArray
protected void encodeDoubleArray(double[] fval, int numElements, VRMLFieldDeclaration decl, String qName, com.sun.xml.fastinfoset.sax.AttributesHolder aholder, int ftype) Encode double array data. This base version will just use a string rep.- Parameters:
fval
- The parsed double array valuenumElements
- The number of elements per itemdecl
- The field declaration.qName
- The qualified nameaholder
- The current attributes holderftype
- The X3D field type, defined in FieldConstants
-
writeScene
-
endDocument
Declaration of the end of the document. There will be no further parsing and hence events after this.- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classBaseRetainedExporter
- 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.
-
printHeader
public void printHeader(int major, int minor) Print the header.- Specified by:
printHeader
in classBaseRetainedExporter
- Parameters:
major
- The major versionminor
- The minor version
-
printExporterInfo
public void printExporterInfo()Description copied from class:BaseRetainedExporter
Print identifying information about this exporter- Specified by:
printExporterInfo
in classBaseRetainedExporter
-
printProfile
Print the profile decl.- Specified by:
printProfile
in classBaseRetainedExporter
- Parameters:
profile
- The profile
-
printComponents
Print the component decl- Specified by:
printComponents
in classBaseRetainedExporter
- Parameters:
comps
- The component list
-
printMetaData
Print the MetaData.- Specified by:
printMetaData
in classBaseRetainedExporter
- Parameters:
meta
- The scene Metadata map
-
printROUTE
Print a ROUTE statement.- Specified by:
printROUTE
in classBaseRetainedExporter
- Parameters:
route
- The ROUTE to printdefMap
- The DEF map
-
printExports
Print Exports.- Specified by:
printExports
in classBaseRetainedExporter
- Parameters:
exports
- A map of exports(name,AS).
-
printImports
Print Imports.- Specified by:
printImports
in classBaseRetainedExporter
- Parameters:
imports
- A map of imports(exported, String[] {def, as}.
-
traverse
Print a node and its children.- Parameters:
source
- The root nodeignoreFirst
- Should we ignore the first node. Used for WorldRoot and ProtoBody
-
printStartScriptNode
public void printStartScriptNode(AbstractDynamicFieldNode node, com.sun.xml.fastinfoset.sax.AttributesHolder atts, boolean use, Map<VRMLNode, String> defMap, Map<Integer, List<ProtoFieldInfo>> isMap) Print the start of a node, and all its non node fields.- Parameters:
node
- The node to printatts
- The current attributes if applicableuse
- Is it a USEdefMap
- The current mapping of nodes to DEF namesisMap
- The current mapping of fields to IS names
-
printStartNode
public boolean printStartNode(VRMLNodeType node, boolean use, Map<VRMLNode, String> defMap, Map<Integer, List<ProtoFieldInfo>> isMap, String containerField, boolean compressed) Print the start of a node, and all its non node fields.- Parameters:
node
- The node to printuse
- Is it a USEdefMap
- The current mapping of nodes to DEF namesisMap
- The current mapping of fields to IS namescontainerField
- The container field value, null if not neededcompressed
- Is this the start of a sg compression- Returns:
- Did a protoInstance start at this level
-
printEndNode
public void printEndNode(VRMLNodeType node, boolean hadChildren, boolean compressed, Map<Integer, List<ProtoFieldInfo>> isMap) throws SAXExceptionPrint the end of a node.- Parameters:
node
- The nodehadChildren
- Where there any children nodescompressed
- Is this node compressedisMap
- The current isMap- Throws:
SAXException
-
observedNode
Notification of a child node.- Specified by:
observedNode
in interfaceSceneGraphTraversalSimpleObserver
- Parameters:
parent
- The parent node of this nodechild
- The child node that is being observedfield
- The index of the child field in its parent nodeused
- true if the node reference is actually a USE
-
printPrototypeDecl
Print a proto declaration.- Specified by:
printPrototypeDecl
in classBaseRetainedExporter
- Parameters:
proto
- The decl to print
-
printExternalPrototypeDecl
Print an external proto declaration.- Parameters:
proto
- The decl to print
-