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 booleanAre we exporting to binaryprotected static final intprotected booleanShould we strip all unnecessary charactersprotected booleanSwitch between methods, should go awayprotected intThe compression method to use for binaryprotected NodeCompressorThe current compressor.protected static final intprotected MapAn empty map to avoid null testingprotected WriterThe passed in writerprotected ContentHandlerThe contentHandler to write toprotected booleanShould we ignore data, its handled by the compressorprotected intThe current indent levelprotected static StringThe indent String to replicate per levelprotected org.j3d.util.IntHashMap<String> A mapping of indent to Stringprotected StringThe current indent stringstatic final intstatic final intstatic final intstatic final intprotected booleanShould we print the DOCTYPEprotected booleanShould we print the XML Elementprotected Set<PrototypeDecl> The current set of proto definitionsprotected Map<String, VRMLFieldDeclaration> Single level proto mapprotected floatThe float lossy paramprotected VRMLWorldRootNodeTypeThe world rootprotected SceneGraphTraverserTraverser for printing proto'sprotected Set<VRMLNodeType> Temporary map during traversal for use referencesprotected booleanShould 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, upgradingFields 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 StringcreateX3DString(VRMLFieldDeclaration decl, double[] val, int numElements) Create an X3D string from an array of valuesprotected StringcreateX3DString(VRMLFieldDeclaration decl, float[] val, int numElements) Create an X3D string from an array of valuesprotected StringcreateX3DString(VRMLFieldDeclaration decl, int[] val, int numElements) Create an X3D string from an array of valuesprotected voidencodeDoubleArray(double[] fval, int numElements, VRMLFieldDeclaration decl, String qName, com.sun.xml.fastinfoset.sax.AttributesHolder aholder, int ftype) Encode double array data.protected voidencodeFloatArray(float[] fval, int numElements, VRMLFieldDeclaration decl, String qName, com.sun.xml.fastinfoset.sax.AttributesHolder aholder, int ftype) Encode float array data.voidDeclaration of the end of the document.booleanReturn the flag indicating that the doc type element is to be includedbooleanReturn the flag indicating that the xml element is to be includedvoidobservedNode(VRMLNodeType parent, VRMLNodeType child, int field, boolean used) Notification of a child node.voidprintComponents(ComponentInfo[] comps) Print the component declvoidprintEndNode(VRMLNodeType node, boolean hadChildren, boolean compressed, Map<Integer, List<ProtoFieldInfo>> isMap) Print the end of a node.voidPrint identifying information about this exportervoidprintExports(Map<String, String> exports) Print Exports.voidPrint an external proto declaration.voidprintHeader(int major, int minor) Print the header.voidprintImports(Map<String, VRMLNode> imports) Print Imports.voidprintMetaData(Map<String, String> meta) Print the MetaData.voidprintProfile(String profile) Print the profile decl.voidprintPrototypeDecl(PrototypeDecl proto) Print a proto declaration.voidprintROUTE(ROUTE route, Map<VRMLNode, String> defMap) Print a ROUTE statement.booleanprintStartNode(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.voidprintStartScriptNode(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.voidsetPrintDocType(boolean enable) Set the flag indicating that the doc type element should be includedvoidsetPrintXML(boolean enable) Set the flag indicating that the xml element should be includedvoidsetX3DAttributes(Map<String, String> atts) Set attributes to be added to the X3D tag.voidPrint a node and its children.voidwriteScene(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, useDeclMethods 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:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin 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:
printHeaderin classBaseRetainedExporter- Parameters:
major- The major versionminor- The minor version
-
printExporterInfo
public void printExporterInfo()Description copied from class:BaseRetainedExporterPrint identifying information about this exporter- Specified by:
printExporterInfoin classBaseRetainedExporter
-
printProfile
Print the profile decl.- Specified by:
printProfilein classBaseRetainedExporter- Parameters:
profile- The profile
-
printComponents
Print the component decl- Specified by:
printComponentsin classBaseRetainedExporter- Parameters:
comps- The component list
-
printMetaData
Print the MetaData.- Specified by:
printMetaDatain classBaseRetainedExporter- Parameters:
meta- The scene Metadata map
-
printROUTE
Print a ROUTE statement.- Specified by:
printROUTEin classBaseRetainedExporter- Parameters:
route- The ROUTE to printdefMap- The DEF map
-
printExports
Print Exports.- Specified by:
printExportsin classBaseRetainedExporter- Parameters:
exports- A map of exports(name,AS).
-
printImports
Print Imports.- Specified by:
printImportsin 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:
observedNodein 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:
printPrototypeDeclin classBaseRetainedExporter- Parameters:
proto- The decl to print
-
printExternalPrototypeDecl
Print an external proto declaration.- Parameters:
proto- The decl to print
-