|
Xj3D VRML/X3D Code API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.web3d.vrml.export.Exporter
org.web3d.vrml.export.BinaryExporter
An experimental binary format writer. Format: table describing compression method per fieldType # of table entries(8) fieldType(8), compression method(8) table describing compression method for individial nodes # of table entries(16) nodeNumber(16), compression method(8) scenegraph structure PROTO definitions Nodes NodeNumber(8 or 16) DEF #(16) or 0(8) for no DEF name. 1st bit(0 = no def) Fields fieldNumber(8) 0=end of node (Internal Xj3D index + 1) field encoding by type Compression method numbers: Seperate set of assigned numbers for fieldType and node Consortium assigned numbers are 0-127, the rest are locally defineable FieldType Compression methods implemented All field types 0 Straight IEEE Encoding MFInt32 1 Squash Range MFFloat 1 Convert to Int, squash range Goals: Enable experimentation with compression methods. Avoid having experimenters change this file Enable app writers to choose different compression methods. Design: Have a properties file saying what class implements the compression method fieldType, method, class nodeNumber, method, class Each compressor class must implement either the FieldCompressor or NodeCompressor interface ---------------------------------- Proposed New Structure Header Binary spec version Profile length(8) data Component number of components(8) length(8) data Number of Bits used for Node Number(max 16) Number of Bits used for DEF lookup(max 32) Number of Bits used for field name Node Dictionary Table num entries(32) values(UTF8) DEF Dictionary Table num entries(32) values(UTF8) Field Table num entries(32) -- Number of field table entries num fields for this node values(UTF8) Table describing compression method per fieldType # of table entries(8) fieldType(8), number of methods(8) Cannot exceed 8 entries compression method(8) -- Indexed into X3D Binary Spec Table describing compression method for individial nodes # of table entries(16) nodeNumber(16), compression method(8) Proto Definitions, assign NodeNum to each Prototype. Retain nested structures. Structure TBD Import/Export Statements Structure TBD Main File Sequence of OP Codes and Data OpCode(2 bits, 00 = Node, 01=USE, 10 = Comment, 11 = ROUTE Node NodeNum(variable) Def lookup(variable) --> Byte Alignment(OP+NodeNum+DEF divisible by 8) Field Name Id(variable) -->Look for end of fields marker Field Method used(3 bits) --> Byte Alignment(FieldNameID+FieldMethod) Field Method Params --> Byte Aligned Field Data --> Byte Aligned USE Def lookup(variable) --> Byte Aligned(OP+DEF) Comment length(14) --> Byte Aligned(OP+length) data ROUTE fromNode(Def Lookup, variable) fromField(FieldNameID,variable) toNode(Def Lookup, variable) toField(FieldNameID, variable) --> Byte Alignment(OP+fromNode+fromField+toNode+toField) NodeNum 0 is reserved as end of fields marker. NodeNum 1 is reserved for Script nodes. They will have their own format. FieldNum 0 is reserved for end of fields marker
| Field Summary | |
protected java.util.HashMap |
externProtoMap
The mapping of externproto names (key) to node instances (value) |
static int |
FIELD_METHOD_BITS
The number of Bits used for the FieldMethod |
protected static VRMLFieldReader |
fieldParser
Field Parser |
static int |
NODEOP_DYNAMIC
|
static int |
NODEOP_ENDFIELDS
|
static int |
OP_BITS
The number of Bits used for the OPCode |
static int |
OP_COMMENT
|
static int |
OP_NODE
|
static int |
OP_ROUTE
|
static int |
OP_USE
|
protected java.util.HashMap |
protoMap
The mapping of proto names (key) to node instances (value) |
| Fields inherited from class org.web3d.vrml.export.Exporter |
majorVersion, minorVersion |
| Constructor Summary | |
BinaryExporter(java.io.OutputStream os,
int major,
int minor,
StatisticsCollector stats)
Create a new exporter for binary file formats. |
|
| Method Summary | |
int |
compare(java.lang.Object a,
java.lang.Object b)
|
void |
componentDecl(java.lang.String componentName)
A component declaration has been found in the code. |
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. |
boolean |
equals(java.lang.Object a)
|
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(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 |
importDecl(java.lang.String inline,
java.lang.String exported,
java.lang.String imported)
An IMPORT declaration has been found in the document. |
void |
metaDecl(java.lang.String key,
java.lang.String value)
A META declaration has been found in the code. |
int |
numBits(int val)
Determine the number of bits needed to store this value. |
void |
printStats()
|
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. |
void |
registerFieldCompressor(int fieldType,
int method,
FieldCompressor compressor)
Register a class for a field/compression method. |
void |
registerNodeCompressor(int nodeNumber,
int method,
NodeCompressor compressor)
Register a class for a node/compression method. |
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 |
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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int OP_BITS
public static final int FIELD_METHOD_BITS
public static final int OP_NODE
public static final int OP_USE
public static final int OP_COMMENT
public static final int OP_ROUTE
public static final int NODEOP_ENDFIELDS
public static final int NODEOP_DYNAMIC
protected static VRMLFieldReader fieldParser
protected java.util.HashMap protoMap
protected java.util.HashMap externProtoMap
| Constructor Detail |
public BinaryExporter(java.io.OutputStream os,
int major,
int minor,
StatisticsCollector stats)
major - The major version number of this sceneminor - The minor version number of this scenestats - The first pass stats.| Method Detail |
public void registerFieldCompressor(int fieldType,
int method,
FieldCompressor compressor)
fieldType - For what field type, defined in FieldConstants.method - For what compression method.compressor - What class implements the FieldCompressor interface.
public void registerNodeCompressor(int nodeNumber,
int method,
NodeCompressor compressor)
nodeNumber - For what field type, defined in FieldConstants.method - For what compression method.compressor - What class implements the FieldCompressor interface.public void setDocumentLocator(Locator loc)
startDocument() has
been called, you can assume that you will not have one available.
setDocumentLocator in interface ContentHandlerloc - The locator instance to use
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
# 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.
startDocument in interface ContentHandleruri - The URI of the file.url - The base URL of the file for resolving relative URIs
contained in the fileencoding - The encoding of this document - utf8 or binarytype - The bytes of the first part of the file headerversion - The VRML version of this documentcomment - Any trailing text on this line. If there is none, this
is null.
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
public void profileDecl(java.lang.String profileName)
throws SAVException,
VRMLException
profileDecl in interface ContentHandlerprofileName - The name of the profile to use
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.
public void componentDecl(java.lang.String componentName)
throws SAVException,
VRMLException
componentDecl in interface ContentHandlercomponentName - The name of the component to use
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.
public void metaDecl(java.lang.String key,
java.lang.String value)
throws SAVException,
VRMLException
metaDecl in interface ContentHandlerkey - The value of the key stringvalue - The value of the value string
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.
public void importDecl(java.lang.String inline,
java.lang.String exported,
java.lang.String imported)
throws SAVException,
VRMLException
importDecl in interface ContentHandlerinline - The name of the inline DEF nodesexported - The exported name from the inlined fileimported - The local name to use for the exported name
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.
public void exportDecl(java.lang.String defName,
java.lang.String exported)
throws SAVException,
VRMLException
exportDecl in interface ContentHandlerdefName - The DEF name of the nodes to be exportedexported - The name to be exported as
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.
public void endDocument()
throws SAVException,
VRMLException
endDocument in interface ContentHandlerSAVException - 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.
public void startNode(java.lang.String name,
java.lang.String defName)
throws SAVException,
VRMLException
startNode in interface ContentHandlername - The name of the node that we are about to parsedefName - The string associated with the DEF name. Null if not
given for this node.
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.
public void endNode()
throws SAVException,
VRMLException
endNode in interface ContentHandlerSAVException - 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.
public void startField(java.lang.String name)
throws SAVException,
VRMLException
ScriptHandler or ProtoHandler methods are
used.
startField in interface ContentHandlername - The name of the field declared
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.
public void fieldValue(java.lang.String value)
throws SAVException,
VRMLException
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.
fieldValue in interface StringContentHandlervalue - The value of this field
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.
public void fieldValue(java.lang.String[] values)
throws SAVException,
VRMLException
fieldValue in interface StringContentHandlervalues - The list of string representing the values
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.
public void useDecl(java.lang.String defName)
throws SAVException,
VRMLException
startField() or endNode().
useDecl in interface ContentHandlerdefName - The name of the DEF string to use
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.
public void endField()
throws SAVException,
VRMLException
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.
endField in interface ContentHandlerSAVException - 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.
public void routeDecl(java.lang.String srcNode,
java.lang.String srcField,
java.lang.String destNode,
java.lang.String destField)
throws SAVException,
VRMLException
routeDecl in interface RouteHandlersrcNode - The name of the DEF of the source nodesrcField - The name of the field to route values fromdestNode - The name of the DEF of the destination nodedestField - The name of the field to route values to
SAVException - This call is taken at the wrong time in the
structure of the document.
VRMLException
public void startScriptDecl()
throws SAVException,
VRMLException
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.
startScriptDecl in interface ScriptHandlerSAVException - 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.
public void endScriptDecl()
throws SAVException,
VRMLException
endNode() callback.
endScriptDecl in interface ScriptHandlerSAVException - 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.
public void scriptFieldDecl(int access,
java.lang.String type,
java.lang.String name,
java.lang.Object value)
throws SAVException,
VRMLException
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.
scriptFieldDecl in interface ScriptHandleraccess - The access type (eg exposedField, field etc)type - The field type (eg SFInt32, MFVec3d etc)name - The name of the fieldvalue - The default value of the field as either String or
String[]. Null if not allowed.
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.
public void startProtoDecl(java.lang.String name)
throws SAVException,
VRMLException
startProtoDecl in interface ProtoHandlername - The name of the proto
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.
public void endProtoDecl()
throws SAVException,
VRMLException
startProtoBody() Then that method should toss an
exception.
endProtoDecl in interface ProtoHandlerSAVException - 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.
public void protoFieldDecl(int access,
java.lang.String type,
java.lang.String name,
java.lang.Object value)
throws SAVException,
VRMLException
protoFieldDecl in interface ProtoHandleraccess - The access type (eg exposedField, field etc)type - The field type (eg SFInt32, MFVec3d etc)name - The name of the fieldvalue - The default value of the field as either String or
String[]. Null if not allowed.
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.
public void protoIsDecl(java.lang.String fieldName)
throws SAVException,
VRMLException
protoIsDecl in interface ProtoHandlerfieldName - The name of the field that is being IS'd
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.
public void startProtoBody()
throws SAVException,
VRMLException
endProtoBody() statement form the body and not the normal
scenegraph information.
startProtoBody in interface ProtoHandlerSAVException - 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.
public void endProtoBody()
throws SAVException,
VRMLException
endProtoBody in interface ProtoHandlerSAVException - 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.
public void startExternProtoDecl(java.lang.String name)
throws SAVException,
VRMLException
endExternProtoDecl() call
you should only receive protoFieldDecl(int, java.lang.String, java.lang.String, java.lang.Object) calls.
startExternProtoDecl in interface ProtoHandlername - The node name of the extern proto
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.
public void endExternProtoDecl()
throws SAVException,
VRMLException
externProtoURI(java.lang.String[]) Then that method should toss an
exception.
endExternProtoDecl in interface ProtoHandlerSAVException - 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.
public void externProtoURI(java.lang.String[] values)
throws SAVException,
VRMLException
externProtoURI in interface ProtoHandlervalues - A list of strings representing all of the URI values
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.
public int compare(java.lang.Object a,
java.lang.Object b)
compare in interface java.util.Comparatorpublic boolean equals(java.lang.Object a)
equals in interface java.util.Comparatorpublic void printStats()
public int numBits(int val)
val - The maximum value
|
Xj3D VRML/X3D Code API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||