Package xj3d.filter.node
Class CommonEncodable
java.lang.Object
xj3d.filter.node.CommonEncodable
- All Implemented Interfaces:
Encodable
- Direct Known Subclasses:
CommonScene
A generic container for X3D content parsed from a file. This representation
is minimalistic. The nodes contain only the fields extracted from the
file, no 'default' values are initialized. inputOnly and outputOnly fields
are not supported. This container is a static representation of an X3D file
and is not suited for runtime purposes.
A VRMLFieldReader instance must be set to this before initializing fields. String Field values will automatically be converted into their respective 'primitive' forms. The specific types of field data returned are:
- Primitive type field values are returned in their respective Java wrapper.
- Array type field values are returned in an ArrayData object.
- SFNode type field values are returned as CommonEncodables.
- MFNode type field values are returned in an List<CommonEncodable>.
A ContentHandler instance must be set to this to support encoding.
- Version:
- $Revision: 1.0 $
- Author:
- Rex Melton
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BinaryContentHandlerBinary Content Handler referenceThe node's DEF nameprotected VRMLFieldReaderThe field parserprotected ContentHandlerContent Handler referencestatic final intContent Handler Typesstatic final intstatic final intprotected intFlag indicating that the content handler is an instance of a BinaryContentHandler, a StringContentHandler, or nullprotected StringContentHandlerString Content Handler referenceprotected ScriptHandlerContent Handler referenceThe node's USE name -
Constructor Summary
ConstructorsConstructorDescriptionCommonEncodable(String nodeName, FieldInfo[] fieldInfo, X3DConstants.TYPE[] nodeType) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear the node fields to their initial (empty) valuesclone(boolean full) Create and return a unique copy of this object.booleandeepEquals(Encodable enc) Compares this node to another and checks if all fields are the same and that all children fields are the same.voidencode()Push the node contents to the ContentHandlervoidencodeNode(boolean full) Push the node contents to the ContentHandlervoidPush the node contents to the ContentHandler.String[]Return the array of all field names.Return the DEF name of the node. null is returned if the DEF name is not set.intgetFieldType(String fieldName) Return the field type.String[]Return the array of node type field names.Return the node nameReturn the array of X3D types that this node inherits from.Return the parent node of thisString[]Return the array of used field names.Return the USE name of the node. null is returned if the USE name is not set.Return field data.booleanisType(X3DConstants.TYPE type) Return whether this node inherits from the specified typevoidsetContentHandler(ContentHandler handler) Set the content handler.voidsetDefName(String defName) Set the DEF name of the node.voidsetFieldReader(VRMLFieldReader fieldReader) Set the reader to use for parsing field values.voidsetParent(CommonEncodable parent) Set the parent node of thisvoidsetScriptHandler(ScriptHandler handler) Set the script handler.voidsetUseName(String useName) Set the USE name of the node.voidSet the value of the named field.voidSet the value of the named field.toString()Return a String representation of this.
-
Field Details
-
HANDLER_BINARY
public static final int HANDLER_BINARYContent Handler Types- See Also:
-
HANDLER_STRING
public static final int HANDLER_STRING- See Also:
-
HANDLER_NULL
public static final int HANDLER_NULL- See Also:
-
defName
The node's DEF name -
useName
The node's USE name -
fieldReader
The field parser -
handlerType
protected int handlerTypeFlag indicating that the content handler is an instance of a BinaryContentHandler, a StringContentHandler, or null -
handler
Content Handler reference -
scriptHandler
Content Handler reference -
bch
Binary Content Handler reference -
sch
String Content Handler reference
-
-
Constructor Details
-
CommonEncodable
Constructor- Parameters:
nodeName- The node's namefieldInfo- The node's field information.nodeType- The nodes's inheritance information
-
-
Method Details
-
getNodeName
Return the node name- Specified by:
getNodeNamein interfaceEncodable- Returns:
- The node name
-
getDefName
Return the DEF name of the node. null is returned if the DEF name is not set.- Specified by:
getDefNamein interfaceEncodable- Returns:
- the DEF name of the node
-
setDefName
Set the DEF name of the node. If the DEF name is non-null, this will clear the USE name if one is set.- Specified by:
setDefNamein interfaceEncodable- Parameters:
defName- the DEF name of the node
-
getUseName
Return the USE name of the node. null is returned if the USE name is not set.- Specified by:
getUseNamein interfaceEncodable- Returns:
- the USE name of the node
-
setUseName
Set the USE name of the node. If the USE name is non-null, this will clear the DEF name if one is set. The fieldData of this node will remain unchanged by setting the USE name.- Specified by:
setUseNamein interfaceEncodable- Parameters:
useName- the USE name of the node
-
clear
-
encodeShallow
public void encodeShallow()Push the node contents to the ContentHandler. Does not push MFNode children along, caller is reponsible for those. -
encode
-
encodeNode
public void encodeNode(boolean full) Push the node contents to the ContentHandler- Parameters:
full-
-
setValue
-
setValue
-
setFieldReader
Set the reader to use for parsing field values.- Specified by:
setFieldReaderin interfaceEncodable- Parameters:
fieldReader- The reader
-
setContentHandler
Set the content handler.- Specified by:
setContentHandlerin interfaceEncodable- Parameters:
handler- The ContentHandler instance to use
-
setScriptHandler
Set the script handler.- Parameters:
handler- The ContentHandler instance to use
-
clone
Create and return a unique copy of this object. A full clone will copy the node's field data. A non-full clone will have it's field data uninitialized. Neither case will copy the defName, useName or parent. Setting these is the user's responsibility. -
deepEquals
Compares this node to another and checks if all fields are the same and that all children fields are the same.DEF / USE handling
- If both nodes are DEF'ed, they are not equal, regardless of their field values.
- If one node USE's the other, they are equal.
- If both nodes USE the same DEF'ed node, they are equal.
The parent node is not considered in the comparison. Two nodes with different parents may be equal depending on their DEF/USE names and field values.
- Specified by:
deepEqualsin interfaceEncodable- Parameters:
enc- The node to compare with- Returns:
- true if the nodes are determined to be equivalent, false if not.
-
setParent
Set the parent node of this- Parameters:
parent- The parent node of this
-
getParent
-
getNodeTypes
Return the array of X3D types that this node inherits from. If this node inherits from no known types, an empty array is returned. If this node is of an unknown type, null is returned.- Returns:
- The array of X3D types that this node implements
-
isType
Return whether this node inherits from the specified type- Parameters:
type- The type to check- Returns:
- true if this node inherits from the specified type, false if not.
-
getValue
Return field data. If none is available, or the field is unknown, return null.The specific types of field data returned are:
- Primitive type field values are returned in their respective Java wrapper.
- Array type field values are returned in an ArrayData object.
- SFNode type field values are returned as CommonEncodables.
- MFNode type field values are returned in an List<CommonEncodable>.
- Parameters:
fieldName- The field identifier- Returns:
- The field data
-
getFieldType
Return the field type. If the field does not exist for this node, -1 is returned.- Parameters:
fieldName- The field identifier- Returns:
- The field type.
-
getAllFieldNames
Return the array of all field names.- Returns:
- The array of all field names.
-
getUsedFieldNames
Return the array of used field names. If none are used, an empty String[] is returned.- Returns:
- The array of used field names.
-
getNodeFieldNames
Return the array of node type field names. If none are used, an empty String[] is returned.- Returns:
- The array of node type field names.
-
toString
-