Package xj3d.filter.node
Class EncodedFilter
java.lang.Object
xj3d.filter.AbstractFilter
xj3d.filter.NewAbstractFilter
xj3d.filter.node.EncodedFilter
- All Implemented Interfaces:
BinaryContentHandler
,ContentHandler
,ProtoHandler
,RouteHandler
,ScriptHandler
,StringContentHandler
- Direct Known Subclasses:
AppearanceReplacerFilter
A base filter that encodes nodes.
- Version:
- $Revision: 1.5 $
- Author:
- Alan Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionMap of apps to defNameprotected boolean
Should nodes be encodedprotected SimpleStackInterface
A stack of node wrappersprotected EncodableFactory
Node wrapper factoryFields inherited from class xj3d.filter.NewAbstractFilter
fieldHasEndedImplicitly, parentTypeStack, suppressCalls
Fields inherited from class xj3d.filter.AbstractFilter
contentHandler, documentLocator, errorHandler, fieldHandler, fieldReader, fieldStack, lastErrorCode, majorVersion, minorVersion, nodeStack, parsingType, protoHandler, routeHandler, scriptHandler
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Construct a default instance of the field handlerprotected
EncodedFilter
(boolean debug) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected void
encode
(boolean val) Should nodes be encoded.void
Declaration of the end of the document.void
endField()
Notification of the end of a field declaration.void
endNode()
Notification of the end of a node declaration.void
fieldValue
(boolean value) Set the value of the field at the given index as an boolean.void
fieldValue
(boolean[] value, int len) Set the value of the field at the given index as an array of boolean.void
fieldValue
(double value) Set the value of the field at the given index as an double.void
fieldValue
(double[] value, int len) Set the value of the field at the given index as an array of doubles.void
fieldValue
(float value) Set the value of the field at the given index as a float.void
fieldValue
(float[] value, int len) Set the value of the field at the given index as an array of floats.void
fieldValue
(int value) Set the value of the field at the given index as an integer.void
fieldValue
(int[] value, int len) Set the value of the field at the given index as an array of integers.void
fieldValue
(long value) Set the value of the field at the given index as an long.void
fieldValue
(long[] value, int len) Set the value of the field at the given index as an array of longs.void
fieldValue
(String value) The value of a normal field.void
fieldValue
(String[] values) The value of an MFField where the underlying parser knows about how the values are broken up.void
fieldValue
(String[] value, int len) Set the value of the field at the given index as an array of strings.void
setDebug
(boolean debug) Set the filter into debug mode.void
Declaration of the start of the document.void
Notification of the start of a node.void
The field value is a USE for the given node name.Methods inherited from class xj3d.filter.NewAbstractFilter
componentDecl, endExternProtoDecl, endProtoBody, endProtoDecl, endScriptDecl, exportDecl, externProtoURI, getContentHandler, getErrorReporter, getLastErrorCode, getProtoHandler, getRouteHandler, getScriptHandler, importDecl, metaDecl, profileDecl, protoFieldDecl, protoIsDecl, routeDecl, scriptFieldDecl, setArguments, setContentHandler, setDocumentLocator, setErrorReporter, setProtoHandler, setRouteHandler, setScriptHandler, startExternProtoDecl, startField, startProtoBody, startProtoDecl, startScriptDecl, suppressCalls
Methods inherited from class xj3d.filter.AbstractFilter
setParsingType
-
Field Details
-
factory
Node wrapper factory -
encMap
-
encStack
A stack of node wrappers -
encodeNodes
protected boolean encodeNodesShould nodes be encoded
-
-
Constructor Details
-
EncodedFilter
protected EncodedFilter()Construct a default instance of the field handler -
EncodedFilter
protected EncodedFilter(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:
setDebug
in classNewAbstractFilter
- 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.0
and the second is#X3D V1.0
even though this second header represents a later spec.- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classNewAbstractFilter
- 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:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classNewAbstractFilter
- 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:
startNode
in interfaceContentHandler
- Overrides:
startNode
in classNewAbstractFilter
- 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:
endNode
in interfaceContentHandler
- Overrides:
endNode
in classNewAbstractFilter
- 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:
useDecl
in interfaceContentHandler
- Overrides:
useDecl
in classNewAbstractFilter
- 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:
endField
in interfaceContentHandler
- Overrides:
endField
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Specified by:
fieldValue
in interfaceStringContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceStringContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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:
fieldValue
in interfaceBinaryContentHandler
- Overrides:
fieldValue
in classNewAbstractFilter
- 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.
-