Xj3D VRML/X3D Code API

org.web3d.vrml.export
Class X3DXMLRetainedExporter

java.lang.Object
  extended byorg.web3d.vrml.export.Exporter
      extended byorg.web3d.vrml.export.BaseRetainedExporter
          extended byorg.web3d.vrml.export.X3DXMLRetainedExporter
All Implemented Interfaces:
BinaryContentHandler, ContentHandler, ProtoHandler, RouteHandler, SceneGraphTraversalSimpleObserver, ScriptHandler, StringContentHandler
Direct Known Subclasses:
X3DBinaryRetainedExporter

public class X3DXMLRetainedExporter
extends BaseRetainedExporter
implements SceneGraphTraversalSimpleObserver

X3D XML exporter using a retained Scenegraph. Known Issues: Proto node fields are copied into instances

Version:
Author:
Alan Hudson

Field Summary
protected  java.io.Writer filterWriter
          The passed in writer
protected  java.io.PrintWriter p
          The printer
protected  boolean printDocType
          Should we print the DOCTYPE
protected  java.util.HashMap protoMap
          Single level proto map
protected  boolean useNC
          Should we use node compressors
 
Fields inherited from class org.web3d.vrml.export.BaseRetainedExporter
builder, componentList, CONTAINER_PROPS_FILE, containerFields, convertOldContent, currentDefMap, currentIsMap, currentPrototypeDecl, defaultNode, defaultNodes, encodingTo, epToUrl, fieldReader, fieldRemap, geospatialFound, geospatialNodes, hanimFound, hanimNodes, isCache, majorVersion, minorVersion, nodeFactory, oldProtos, oStream, processingDocument, profile, protoCreator, scene, scriptPatterns, scriptReplacements, stripWhitespace, upgrading
 
Constructor Summary
X3DXMLRetainedExporter(java.io.OutputStream os, int major, int minor)
          Create a new exporter for the given spec version
X3DXMLRetainedExporter(java.io.Writer w, int major, int minor)
          Create a new exporter for the given spec version
 
Method Summary
 void endDocument()
          Declaration of the end of the document.
 void observedNode(VRMLNodeType parent, VRMLNodeType child, int field, boolean used)
          Notification of a child node.
 void printComponents(ComponentInfo[] comps)
          Print the component decl
 void printEndNode(VRMLNodeType node, boolean hadChildren, boolean compressed, java.util.Map isMap)
          Print the end of a node.
 void printExports(java.util.Map exports)
          Print Exports.
 void printExternalPrototypeDecl(CRExternPrototypeDecl proto)
          Print an external proto declaration.
 void printHeader(int major, int minor)
          Print the header.
 void printImports(java.util.Map imports)
          Print Imports.
 void printMetaData(java.util.Map meta)
          Print the MetaData.
 void printProfile(java.lang.String profile)
          Print the profile decl.
 void printPrototypeDecl(PrototypeDecl proto)
          Print a proto declaration.
 void printROUTE(ROUTE route, java.util.Map defMap)
          Print a ROUTE statement.
 boolean printStartNode(VRMLNodeType node, boolean use, java.util.Map defMap, java.util.Map isMap, java.lang.String containerField, boolean compressed)
          Print the start of a node, and all its non node fields.
 void printStartScriptNode(AbstractDynamicFieldNode node, boolean use, java.util.Map defMap, java.util.Map isMap)
          Print the start of a node, and all its non node fields.
 void traverse(VRMLNode source, boolean ignoreFirst)
          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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

p

protected java.io.PrintWriter p
The printer


filterWriter

protected java.io.Writer filterWriter
The passed in writer


printDocType

protected boolean printDocType
Should we print the DOCTYPE


useNC

protected boolean useNC
Should we use node compressors


protoMap

protected java.util.HashMap protoMap
Single level proto map

Constructor Detail

X3DXMLRetainedExporter

public X3DXMLRetainedExporter(java.io.OutputStream os,
                              int major,
                              int minor)
Create a new exporter for the given spec version

Parameters:
os - The stream to export the code to
major - The major version number of this scene
minor - The minor version number of this scene

X3DXMLRetainedExporter

public X3DXMLRetainedExporter(java.io.Writer w,
                              int major,
                              int minor)
Create a new exporter for the given spec version

Parameters:
w - The writer to write to
major - The major version number of this scene
minor - The minor version number of this scene
Method Detail

writeScene

public void writeScene(VRMLScene scene)
Write a scene out.

Parameters:
scene - The scene to write

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
Overrides:
endDocument in class BaseRetainedExporter
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 class BaseRetainedExporter
Parameters:
major - The major version
minor - The minor version

printProfile

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

Specified by:
printProfile in class BaseRetainedExporter
Parameters:
profile - The profile

printComponents

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

Specified by:
printComponents in class BaseRetainedExporter
Parameters:
comps - The component list

printMetaData

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

Specified by:
printMetaData in class BaseRetainedExporter
Parameters:
meta - The scene Metadata map

printROUTE

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

Specified by:
printROUTE in class BaseRetainedExporter
Parameters:
route - The ROUTE to print
defMap - The DEF map

printExports

public void printExports(java.util.Map exports)
Print Exports.

Specified by:
printExports in class BaseRetainedExporter
Parameters:
exports - A map of exports(name,AS).

printImports

public void printImports(java.util.Map imports)
Print Imports.

Specified by:
printImports in class BaseRetainedExporter
Parameters:
imports - A map of imports(exported, String[] {def, as}.

traverse

public void traverse(VRMLNode source,
                     boolean ignoreFirst)
Print a node and its children.

Parameters:
source - The root node
ignoreFirst - Should we ignore the first node. Used for WorldRoot and ProtoBody

printStartScriptNode

public void printStartScriptNode(AbstractDynamicFieldNode node,
                                 boolean use,
                                 java.util.Map defMap,
                                 java.util.Map isMap)
Print the start of a node, and all its non node fields.

Parameters:
node - The node to print
use - Is it a USE
defMap - The current mapping of nodes to DEF names
isMap - The current mapping of fields to IS names

printStartNode

public boolean printStartNode(VRMLNodeType node,
                              boolean use,
                              java.util.Map defMap,
                              java.util.Map isMap,
                              java.lang.String containerField,
                              boolean compressed)
Print the start of a node, and all its non node fields.

Parameters:
node - The node to print
use - Is it a USE
defMap - The current mapping of nodes to DEF names
isMap - The current mapping of fields to IS names
containerField - The container field value, null if not needed
compressed - 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,
                         java.util.Map isMap)
Print the end of a node.

Parameters:
node - The node
hadChildren - Where there any children nodes
compressed - Is this node compressed
isMap - The current isMap

observedNode

public void observedNode(VRMLNodeType parent,
                         VRMLNodeType child,
                         int field,
                         boolean used)
Notification of a child node.

Specified by:
observedNode in interface SceneGraphTraversalSimpleObserver
Parameters:
parent - The parent node of this node
child - The child node that is being observed
field - The index of the child field in its parent node
used - true if the node reference is actually a USE

printPrototypeDecl

public void printPrototypeDecl(PrototypeDecl proto)
Print a proto declaration.

Specified by:
printPrototypeDecl in class BaseRetainedExporter
Parameters:
proto - The decl to print

printExternalPrototypeDecl

public void printExternalPrototypeDecl(CRExternPrototypeDecl proto)
Print an external proto declaration.

Parameters:
proto - The decl to print

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium