Package xj3d.filter.node
Class CommonEncodedBaseFilter
java.lang.Object
xj3d.filter.AbstractFilter
xj3d.filter.BaseFilter
xj3d.filter.node.CommonEncodedBaseFilter
- All Implemented Interfaces:
BinaryContentHandler,ContentHandler,ProtoHandler,RouteHandler,ScriptHandler,StringContentHandler
- Direct Known Subclasses:
ExportPixelTextureFilter,FlattenSelectableFilter,FlattenTextureTransformFilter,FlattenTransformFilter,ManifoldInfoFilter,RemoveUnusedDEFFilter,TriangleCountInfoFilter,USERedundantNodeFilter,ValidateIndexFilter,X3DMemoryExporter
A base filter that encodes nodes.
- Version:
- $Revision: 1.0 $
- Author:
- Rex Melton
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<String, CommonEncodable> Map of apps to defNameprotected booleanShould nodes be encodedprotected booleanShould nodes be encodedprotected SimpleStackInterfaceA stack of node wrappersprotected CommonEncodableFactoryNode wrapper factoryprotected CommonSceneScene instanceFields inherited from class xj3d.filter.BaseFilter
insideInvalidField, sceneMarker, suppressCallsFields inherited from class xj3d.filter.AbstractFilter
contentHandler, documentLocator, errorHandler, fieldHandler, fieldReader, fieldStack, lastErrorCode, majorVersion, minorVersion, nodeStack, parsingType, protoHandler, routeHandler, scriptHandler -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstruct a default instance of the field handlerprotectedCommonEncodedBaseFilter(boolean debug) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected voidencode(boolean val) Should nodes be encoded.voidDeclaration of the end of the document.voidNotification of the end of an EXTERNPROTO declaration.voidendField()Notification of the end of a field declaration.voidendNode()Notification of the end of a node declaration.voidNotification of the end of an ordinary proto body.voidNotification of the end of an ordinary proto declaration statement.voidNotification of the end of a script declaration.voidexternProtoURI(String[] values) Notification of the URI list for an EXTERNPROTO.voidfieldValue(boolean value) Set the value of the field at the given index as an boolean.voidfieldValue(boolean[] value, int len) Set the value of the field at the given index as an array of boolean.voidfieldValue(double value) Set the value of the field at the given index as an double.voidfieldValue(double[] value, int len) Set the value of the field at the given index as an array of doubles.voidfieldValue(float value) Set the value of the field at the given index as a float.voidfieldValue(float[] value, int len) Set the value of the field at the given index as an array of floats.voidfieldValue(int value) Set the value of the field at the given index as an integer.voidfieldValue(int[] value, int len) Set the value of the field at the given index as an array of integers.voidfieldValue(long value) Set the value of the field at the given index as an long.voidfieldValue(long[] value, int len) Set the value of the field at the given index as an array of longs.voidfieldValue(String value) The value of a normal field.voidfieldValue(String[] values) The value of an MFField where the underlying parser knows about how the values are broken up.voidfieldValue(String[] value, int len) Set the value of the field at the given index as an array of strings.voidprotoFieldDecl(int access, String type, String name, Object value) Notification of a proto's field declaration.voidprotoIsDecl(String fieldName) Notification of a field value uses an IS statement.voidNotification of a ROUTE declaration in the file.voidscriptFieldDecl(int access, String type, String name, Object value) Notification of a script's field declaration.voidsetDebug(boolean debug) Set the filter into debug mode.voidDeclaration of the start of the document.voidstartExternProtoDecl(String name) Notification of the start of an EXTERNPROTO declaration of the given name.voidNotification of the start of a node.voidNotification of the start of an ordinary proto body.voidstartProtoDecl(String name) Notification of the start of an ordinary (inline) proto declaration.voidNotification of the start of a script declaration.voidThe field value is a USE for the given node name.Methods inherited from class xj3d.filter.BaseFilter
componentDecl, exportDecl, getContentHandler, getErrorReporter, getLastErrorCode, getProtoHandler, getRouteHandler, getScriptHandler, importDecl, metaDecl, profileDecl, setArguments, setContentHandler, setDocumentLocator, setErrorReporter, setProtoHandler, setRouteHandler, setScriptHandler, startField, suppressCallsMethods inherited from class xj3d.filter.AbstractFilter
setParsingType
-
Field Details
-
factory
Node wrapper factory -
encMap
Map of apps to defName -
encStack
A stack of node wrappers -
scene
Scene instance -
encodeNodes
protected boolean encodeNodesShould nodes be encoded -
encodeRoutes
protected boolean encodeRoutesShould nodes be encoded
-
-
Constructor Details
-
CommonEncodedBaseFilter
protected CommonEncodedBaseFilter()Construct a default instance of the field handler -
CommonEncodedBaseFilter
protected CommonEncodedBaseFilter(boolean debug) Constructor- Parameters:
debug- Should we run in debug mode
-
-
Method Details
-
setDebug
public void setDebug(boolean debug) Set the filter into debug mode. This must be called before any filtering occurs.- Overrides:
setDebugin classBaseFilter- Parameters:
debug- True to debug
-
encode
protected void encode(boolean val) Should nodes be encoded. Default is to encode.- Parameters:
val- The new value
-
startDocument
public void startDocument(String uri, String url, String encoding, String type, String version, 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.0and the second is#X3D V1.0even though this second header represents a later spec.- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classBaseFilter- Parameters:
uri- 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.- Throws:
SAVException- This call is taken at the wrong time in the structure of the documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-
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 classBaseFilter- Throws:
SAVException- This call is taken at the wrong time in the structure of the documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-
startNode
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:
startNodein interfaceContentHandler- Overrides:
startNodein classBaseFilter- Parameters:
name- 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.- Throws:
SAVException- This call is taken at the wrong time in the structure of the documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-
endNode
Notification of the end of a node declaration.- Specified by:
endNodein interfaceContentHandler- Overrides:
endNodein classBaseFilter- Throws:
SAVException- This call is taken at the wrong time in the structure of the documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-
useDecl
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 anotherstartField()orendNode().- Specified by:
useDeclin interfaceContentHandler- Overrides:
useDeclin classBaseFilter- 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 documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-
endField
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 eitheruseDecl(String)orfieldValue(String).- Specified by:
endFieldin interfaceContentHandler- Overrides:
endFieldin classBaseFilter- Throws:
SAVException- This call is taken at the wrong time in the structure of the documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-
fieldValue
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 anotherstartField()orendNode().If this field is an SFNode with a USE declaration you will have the
useDecl(String)method called rather than this method.- Specified by:
fieldValuein interfaceBinaryContentHandler- Specified by:
fieldValuein interfaceStringContentHandler- Overrides:
fieldValuein classBaseFilter- Parameters:
value- The value of this field- Throws:
SAVException- This call is taken at the wrong time in the structure of the documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-
fieldValue
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:
fieldValuein interfaceStringContentHandler- Overrides:
fieldValuein classBaseFilter- Parameters:
values- The list of string representing the values- Throws:
SAVException- This call is taken at the wrong time in the structure of the documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-
fieldValue
Set the value of the field at the given index as an integer. This would be used to set SFInt32 field types.- Specified by:
fieldValuein interfaceBinaryContentHandler- Overrides:
fieldValuein classBaseFilter- 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
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:
fieldValuein interfaceBinaryContentHandler- Overrides:
fieldValuein classBaseFilter- Parameters:
value- The new value to use for the nodelen- 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
Set the value of the field at the given index as an boolean. This would be used to set SFBool field types.- Specified by:
fieldValuein interfaceBinaryContentHandler- Overrides:
fieldValuein classBaseFilter- 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
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:
fieldValuein interfaceBinaryContentHandler- Overrides:
fieldValuein classBaseFilter- Parameters:
value- The new value to use for the nodelen- 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
Set the value of the field at the given index as a float. This would be used to set SFFloat field types.- Specified by:
fieldValuein interfaceBinaryContentHandler- Overrides:
fieldValuein classBaseFilter- 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
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:
fieldValuein interfaceBinaryContentHandler- Overrides:
fieldValuein classBaseFilter- Parameters:
value- The new value to use for the nodelen- 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
Set the value of the field at the given index as an long. This would be used to set SFTime field types.- Specified by:
fieldValuein interfaceBinaryContentHandler- Overrides:
fieldValuein classBaseFilter- 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
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:
fieldValuein interfaceBinaryContentHandler- Overrides:
fieldValuein classBaseFilter- Parameters:
value- The new value to use for the nodelen- 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
Set the value of the field at the given index as an double. This would be used to set SFDouble field types.- Specified by:
fieldValuein interfaceBinaryContentHandler- Overrides:
fieldValuein classBaseFilter- 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
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:
fieldValuein interfaceBinaryContentHandler- Overrides:
fieldValuein classBaseFilter- Parameters:
value- The new value to use for the nodelen- 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
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:
fieldValuein interfaceBinaryContentHandler- Overrides:
fieldValuein classBaseFilter- Parameters:
value- The new value to use for the nodelen- 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.
-
routeDecl
public void routeDecl(String srcNodeName, String srcFieldName, String destNodeName, String destFieldName) 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:
routeDeclin interfaceRouteHandler- Overrides:
routeDeclin classBaseFilter- Parameters:
srcNodeName- The name of the DEF of the source nodesrcFieldName- The name of the field to route values fromdestNodeName- The name of the DEF of the destination nodedestFieldName- The name of the field to route values to- Throws:
SAVException- This call is taken at the wrong time in the structure of the documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-
startProtoDecl
Notification of the start of an ordinary (inline) proto declaration. The proto has the given node name.- Specified by:
startProtoDeclin interfaceProtoHandler- Overrides:
startProtoDeclin classBaseFilter- Parameters:
name- The name of the proto- Throws:
SAVException- Always thrownVRMLException- Never thrown
-
endProtoDecl
Notification of the end of an ordinary proto declaration statement.- Specified by:
endProtoDeclin interfaceProtoHandler- Overrides:
endProtoDeclin classBaseFilter- Throws:
SAVException- Always thrownVRMLException- Never thrown
-
protoFieldDecl
public void protoFieldDecl(int access, String type, String name, 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:
protoFieldDeclin interfaceProtoHandler- Overrides:
protoFieldDeclin classBaseFilter- Parameters:
access- 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. Null if not allowed.- Throws:
SAVException- Always thrownVRMLException- Never thrown
-
protoIsDecl
Notification of a field value uses an IS statement. If we are running in VRML97 mode, this will throw an exception if the field access types do not match.- Specified by:
protoIsDeclin interfaceProtoHandler- Overrides:
protoIsDeclin classBaseFilter- Parameters:
fieldName- The name of the field that is being IS'd- Throws:
SAVException- Always thrownVRMLException- Never thrown
-
startProtoBody
Notification of the start of an ordinary proto body. All nodes contained between here and the correspondingendProtoBody()statement form the body and not the normal scenegraph information.- Specified by:
startProtoBodyin interfaceProtoHandler- Overrides:
startProtoBodyin classBaseFilter- Throws:
SAVException- Always thrownVRMLException- Never thrown
-
endProtoBody
Notification of the end of an ordinary proto body. Parsing now returns to ordinary node declarations.- Specified by:
endProtoBodyin interfaceProtoHandler- Overrides:
endProtoBodyin classBaseFilter- Throws:
SAVException- Always thrownVRMLException- Never thrown
-
startExternProtoDecl
Notification of the start of an EXTERNPROTO declaration of the given name. Between here and the matchingendExternProtoDecl()call you should only receiveprotoFieldDecl(int, java.lang.String, java.lang.String, java.lang.Object)calls.- Specified by:
startExternProtoDeclin interfaceProtoHandler- Overrides:
startExternProtoDeclin classBaseFilter- Parameters:
name- The node name of the extern proto- Throws:
SAVException- Always thrownVRMLException- Never thrown
-
endExternProtoDecl
Notification of the end of an EXTERNPROTO declaration.- Specified by:
endExternProtoDeclin interfaceProtoHandler- Overrides:
endExternProtoDeclin classBaseFilter- Throws:
SAVException- Always thrownVRMLException- Never thrown
-
externProtoURI
Notification of the URI list for an EXTERNPROTO. This is a complete list of URIs. The calling application is required to interpret the incoming strings. 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:
externProtoURIin interfaceProtoHandler- Overrides:
externProtoURIin classBaseFilter- Parameters:
values- A list of strings representing all of the URI values- Throws:
SAVException- Always thrownVRMLException- Never thrown
-
startScriptDecl
Notification of the start of a script declaration. All calls between now and the correspondingendScriptDecl()call belong to this script node. This method will be called after the ContentHandlerstartNode()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:
startScriptDeclin interfaceScriptHandler- Overrides:
startScriptDeclin classBaseFilter- Throws:
SAVException- This call is taken at the wrong time in the structure of the documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-
endScriptDecl
Notification of the end of a script declaration. This is guaranteed to be called before the ContentHandlerendNode()callback.- Specified by:
endScriptDeclin interfaceScriptHandler- Overrides:
endScriptDeclin classBaseFilter- Throws:
SAVException- This call is taken at the wrong time in the structure of the documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-
scriptFieldDecl
public void scriptFieldDecl(int access, String type, String name, Object value) throws SAVException, VRMLException Notification of a script's field declaration. This is used for all fields excepturl,mustEvaluateanddirectOutputfields. These fields use the normal field callbacks ofContentHandler.- Specified by:
scriptFieldDeclin interfaceScriptHandler- Overrides:
scriptFieldDeclin classBaseFilter- Parameters:
access- 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- Throws:
SAVException- This call is taken at the wrong time in the structure of the documentVRMLException- The content provided is invalid for this part of the document or can't be parsed
-