Class X3DConcreteElement

java.lang.Object
org.web3d.x3d.jsail.X3DConcreteElement
Direct Known Subclasses:
X3DConcreteNode, X3DConcreteStatement

public abstract class X3DConcreteElement
extends java.lang.Object
Topmost abstract parent class for concrete X3D nodes and statements, containing common methods and member variables.

See Also:
X3D Tooltips, X3D Scene Authoring Hints
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected static java.lang.String NAME
    String constant NAME provides name of this element; overridden by implementing class.
    protected java.lang.StringBuilder validationResult
    Results log of local validation.
  • Constructor Summary

    Constructors
    Constructor Description
    X3DConcreteElement()  
  • Method Summary

    Modifier and Type Method Description
    X3DConcreteElement addComments()
    Debug support: adding empty comment as CommentsBlock to children field has no effect.
    abstract X3DConcreteElement addComments​(java.lang.String newComment)
    Add comment as String to contained commentsList.
    abstract X3DConcreteElement addComments​(java.lang.String[] newComments)
    Add comments as String[] array to contained commentsList.
    abstract X3DConcreteElement addComments​(CommentsBlock newCommentsBlock)
    Add CommentsBlock to element
    void clearParent()
    Package-protected internal method to clear local reference to parent object, if any.
    X3DConcreteElement findAncestorElementByName​(java.lang.String ancestorElementName)
    Find object reference to ancestor element (i.e. node or statement), if this object is an attached child.
    ProtoBody findAncestorProtoBody()
    Find object reference to ancestor ProtoBody, if this node or statement is a child.
    Scene findAncestorScene()
    Find object reference to ancestor Scene element, assumes this object is an attached child.
    X3D findAncestorX3D()
    Find object reference to ancestor X3D element, if this node or statement is part of an X3D object.
    abstract X3DConcreteElement findElementByNameValue​(java.lang.String nameValue)
    Recursive method to provide object reference to node or statement by name attribute, if found as part of this element or in a contained element.
    abstract X3DConcreteElement findElementByNameValue​(java.lang.String nameValue, java.lang.String elementName)
    Recursive method to provide object reference to node or statement by name attribute, if found as part of this element or in a contained element.
    abstract X3DConcreteNode findNodeByDEF​(java.lang.String DEFvalue)
    Recursive method to provide object reference to node by DEF, if found as this node or in a contained node.
    abstract java.lang.String getAccessType​(java.lang.String fieldName)
    Indicate accessType corresponding to given fieldName.
    abstract java.lang.String getComponent()
    Defines X3D component for this element.
    abstract int getComponentLevel()
    Provides default X3D component level for this element
    abstract java.lang.String getElementName()
    Provides name of this element.
    abstract java.lang.String getFieldType​(java.lang.String fieldName)
    Indicate type corresponding to given fieldName.
    static java.lang.String getPackageName​(java.lang.String className)
    Provide fully qualified package for a given element object, including className.
    X3DConcreteElement getParent()
    Provide object reference to parent X3D node or statement, if any.
    java.lang.String getValidationResult()
    Get output of results from prior validation, if any
    boolean hasAncestorElementByName​(java.lang.String ancestorElementName)
    Determine whether ancestor element (i.e. node or statement) is found, meaning this object is an attached child.
    boolean hasAncestorProtoBody()
    Determine whether ancestor ProtoBody element is found, meaning this object is an attached child.
    boolean hasAncestorScene()
    Determine whether ancestor Scene element is found, meaning this object is an attached child.
    boolean hasAncestorX3D()
    Determine whether ancestor X3D element is found, meaning this object is an attached child.
    boolean hasParent()
    Whether parent object exists.
    boolean isValid()
    Recursive method to determine whether this element is valid.
    void setParent​(X3DConcreteElement newParentObject)
    Package-internal method to set parent object reference.
    java.lang.String toStringClassicVRML()
    Recursive method to provide ClassicVRML string serialization.
    abstract java.lang.String toStringClassicVRML​(int indentLevel)
    Recursive method to provide ClassicVRML string serialization.
    java.lang.String toStringVRML97()
    Recursive method to provide VRML97 string serialization.
    abstract java.lang.String toStringVRML97​(int indentLevel)
    Recursive method to provide VRML97 string serialization.
    java.lang.String toStringX3D()
    Recursive method to provide X3D string serialization of this model subgraph, utilizing XML encoding and conforming to X3D Canonical Form.
    abstract java.lang.String toStringX3D​(int indentLevel)
    Recursive method to provide X3D string serialization of this model subgraph, utilizing XML encoding and conforming to X3D Canonical Form.
    abstract java.lang.String validate()
    Recursive method to validate this element plus all contained nodes and statements, using both datatype-specification value checks and regular expression (regex) checking of corresponding string values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NAME

      protected static final java.lang.String NAME
      String constant NAME provides name of this element; overridden by implementing class.
      See Also:
      Constant Field Values
    • validationResult

      protected java.lang.StringBuilder validationResult
      Results log of local validation.
  • Constructor Details

    • X3DConcreteElement

      public X3DConcreteElement()
  • Method Details

    • getParent

      public X3DConcreteElement getParent()
      Provide object reference to parent X3D node or statement, if any. This reference is named "parentObject" rather than "parent" to avoid potential name collision with any X3D field named "parent".
      Returns:
      object reference to parent X3D node or statement, otherwise null if none
    • hasParent

      public boolean hasParent()
      Whether parent object exists. This reference is named "parentObject" rather than "parent" to avoid potential name collision with any X3D field named "parent".
      Returns:
      true if found
    • setParent

      public void setParent​(X3DConcreteElement newParentObject)
      Package-internal method to set parent object reference.
      Parameters:
      newParentObject - object reference to parent node or X3D statement that contains this node
    • clearParent

      public void clearParent()
      Package-protected internal method to clear local reference to parent object, if any.
    • findAncestorScene

      public Scene findAncestorScene()
      Find object reference to ancestor Scene element, assumes this object is an attached child.
      Returns:
      ancestor Scene child reference if attached, otherwise null
      See Also:
      hasAncestorScene(), hasAncestorX3D(), findAncestorX3D()
    • hasAncestorScene

      public boolean hasAncestorScene()
      Determine whether ancestor Scene element is found, meaning this object is an attached child.
      Returns:
      whether ancestor Scene node is found
      See Also:
      hasAncestorScene(), hasAncestorX3D(), findAncestorX3D()
    • findAncestorElementByName

      public X3DConcreteElement findAncestorElementByName​(java.lang.String ancestorElementName)
      Find object reference to ancestor element (i.e. node or statement), if this object is an attached child.
      Parameters:
      ancestorElementName - elementName of ancestor of interest (e.g. first Transform)
      Returns:
      ancestor node reference if attached and found, otherwise null
    • hasAncestorElementByName

      public boolean hasAncestorElementByName​(java.lang.String ancestorElementName)
      Determine whether ancestor element (i.e. node or statement) is found, meaning this object is an attached child.
      Parameters:
      ancestorElementName - elementName of ancestor of interest (e.g. first Transform)
      Returns:
      whether ancestor element is found
      See Also:
      findAncestorProtoBody()
    • findAncestorProtoBody

      public ProtoBody findAncestorProtoBody()
      Find object reference to ancestor ProtoBody, if this node or statement is a child.
      Returns:
      ancestor ProtoBody reference if attached and found, otherwise null
      See Also:
      hasAncestorProtoBody()
    • hasAncestorProtoBody

      public boolean hasAncestorProtoBody()
      Determine whether ancestor ProtoBody element is found, meaning this object is an attached child.
      Returns:
      whether ancestor ProtoBody element is found
      See Also:
      findAncestorProtoBody()
    • findAncestorX3D

      public X3D findAncestorX3D()
      Find object reference to ancestor X3D element, if this node or statement is part of an X3D object.
      Returns:
      ancestor X3D reference if attached, otherwise null
      See Also:
      hasAncestorX3D(), hasAncestorScene(), hasAncestorScene()
    • hasAncestorX3D

      public boolean hasAncestorX3D()
      Determine whether ancestor X3D element is found, meaning this object is an attached child.
      Returns:
      whether ancestor X3D element is found
      See Also:
      findAncestorX3D(), hasAncestorScene(), hasAncestorScene()
    • getElementName

      public abstract java.lang.String getElementName()
      Provides name of this element.
      Returns:
      name of this element
    • getComponent

      public abstract java.lang.String getComponent()
      Defines X3D component for this element.
      Returns:
      X3D component for this element
    • getComponentLevel

      public abstract int getComponentLevel()
      Provides default X3D component level for this element
      Returns:
      default X3D component level for this element
    • getFieldType

      public abstract java.lang.String getFieldType​(java.lang.String fieldName)
      Indicate type corresponding to given fieldName.
      Parameters:
      fieldName - name of field in this X3D statement
      Returns:
      X3D type (SFvec3f etc.), otherwise ConfigurationProperties.ERROR_UNKNOWN_FIELD_TYPE if not recognized
      See Also:
      ConfigurationProperties.ERROR_UNKNOWN_FIELD_TYPE
    • getAccessType

      public abstract java.lang.String getAccessType​(java.lang.String fieldName)
      Indicate accessType corresponding to given fieldName.
      Parameters:
      fieldName - name of field in this X3D statement
      Returns:
      X3D accessType (inputOnly etc.), otherwise ConfigurationProperties.ERROR_UNKNOWN_FIELD_TYPE if not recognized
      See Also:
      ConfigurationProperties.ERROR_UNKNOWN_FIELD_TYPE
    • findElementByNameValue

      public abstract X3DConcreteElement findElementByNameValue​(java.lang.String nameValue, java.lang.String elementName)
      Recursive method to provide object reference to node or statement by name attribute, if found as part of this element or in a contained element. Elements with name fields include meta, Metadata* nodes, field/fieldValue, ProtoDeclare/ExternProtoDeclare/ProtoInstance, CAD and HAnim nodes.

      Warning: first start with findAncestorScene() to check entire scene graph, or findAncestorX3D() to check entire model document.

      Parameters:
      nameValue - is value of the name field being searched for in this element and child elements(if any)
      elementName - identifies the element of interest (meta MetadataString ProtoDeclare CADassembly ProtoInstance HAnimHumanoid etc.)
      Returns:
      object reference to found element, null otherwise
      See Also:
      findNodeByDEF(String), hasAncestorScene(), findAncestorX3D(), meta, Warning: more than one element may be found that has the same name, this method does not handle that case.
    • findElementByNameValue

      public abstract X3DConcreteElement findElementByNameValue​(java.lang.String nameValue)
      Recursive method to provide object reference to node or statement by name attribute, if found as part of this element or in a contained element. Elements with name fields include meta, Metadata* nodes, field/fieldValue, ProtoDeclare/ExternProtoDeclare/ProtoInstance, CAD and HAnim nodes.

      Warning: first start with findAncestorScene() to check entire scene graph, or findAncestorX3D() to check entire model document.

      Warning: more than one element may be found that has the same name, this method does not handle that case.
      Parameters:
      nameValue - is value of the name field being searched for in this element and child elements(if any)
      Returns:
      object reference to found element, null otherwise
      See Also:
      findNodeByDEF(String), hasAncestorScene(), findAncestorX3D()
    • findNodeByDEF

      public abstract X3DConcreteNode findNodeByDEF​(java.lang.String DEFvalue)
      Recursive method to provide object reference to node by DEF, if found as this node or in a contained node.

      Warning: first start with findAncestorScene() to check entire scene graph, or findAncestorX3D() to check entire model document.

      Warning: more than one element may be found that has the same DEF, this method does not handle that case.
      Parameters:
      DEFvalue - is value of the name field being searched for in this element and child elements(if any)
      Returns:
      object reference to found node, null otherwise
      See Also:
      findElementByNameValue(String), hasAncestorScene(), findAncestorX3D()
    • getPackageName

      public static java.lang.String getPackageName​(java.lang.String className)
      Provide fully qualified package for a given element object, including className. Helpful for reflection.
      Parameters:
      className - X3D statement or node of interest
      Returns:
      fully qualified package for className
    • addComments

      public abstract X3DConcreteElement addComments​(java.lang.String newComment)
      Add comment as String to contained commentsList.
      Parameters:
      newComment - initial value
      Returns:
      this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
    • addComments

      public X3DConcreteElement addComments()
      Debug support: adding empty comment as CommentsBlock to children field has no effect.
      Returns:
      this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
    • addComments

      public abstract X3DConcreteElement addComments​(java.lang.String[] newComments)
      Add comments as String[] array to contained commentsList.
      Parameters:
      newComments - array of comments
      Returns:
      this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
    • addComments

      public abstract X3DConcreteElement addComments​(CommentsBlock newCommentsBlock)
      Add CommentsBlock to element
      Parameters:
      newCommentsBlock - block of comments to add
      Returns:
      this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
    • getValidationResult

      public java.lang.String getValidationResult()
      Get output of results from prior validation, if any
      Returns:
      validation results (if any)
    • toStringX3D

      public java.lang.String toStringX3D()
      Recursive method to provide X3D string serialization of this model subgraph, utilizing XML encoding and conforming to X3D Canonical Form.
      Returns:
      X3D string
      See Also:
      X3D.FILE_EXTENSION_X3D, X3D.FILE_EXTENSION_XML, X3D XML Encoding, X3D Compressed Binary Encoding: X3D Canonical Form, X3D Canonicalization (C14N) Tool
    • toStringX3D

      public abstract java.lang.String toStringX3D​(int indentLevel)
      Recursive method to provide X3D string serialization of this model subgraph, utilizing XML encoding and conforming to X3D Canonical Form.
      Parameters:
      indentLevel - number of levels of indentation for this element
      Returns:
      X3D string
      See Also:
      X3D.FILE_EXTENSION_X3D, X3D.FILE_EXTENSION_XML, X3D XML Encoding, X3D Compressed Binary Encoding: X3D Canonical Form, X3D Canonicalization (C14N) Tool
    • toStringClassicVRML

      public java.lang.String toStringClassicVRML()
      Recursive method to provide ClassicVRML string serialization.
      Returns:
      ClassicVRML string
      See Also:
      X3D.FILE_EXTENSION_CLASSICVRML, X3D Resources: Virtual Reality Modeling Language (VRML) 97, Extensible 3D (X3D) encodings Part 2: Classic VRML encoding, Extensible 3D (X3D) encodings Part 2: Classic VRML encoding, Annex A: Grammar
    • toStringClassicVRML

      public abstract java.lang.String toStringClassicVRML​(int indentLevel)
      Recursive method to provide ClassicVRML string serialization.
      Parameters:
      indentLevel - number of levels of indentation for this element
      Returns:
      ClassicVRML string
      See Also:
      X3D.FILE_EXTENSION_CLASSICVRML, X3D Resources: Virtual Reality Modeling Language (VRML) 97, Extensible 3D (X3D) encodings Part 2: Classic VRML encoding, Extensible 3D (X3D) encodings Part 2: Classic VRML encoding, Annex A: Grammar
    • toStringVRML97

      public java.lang.String toStringVRML97()
      Recursive method to provide VRML97 string serialization.
      Returns:
      VRML97 string
      See Also:
      X3D.FILE_EXTENSION_VRML97, X3D Resources: Virtual Reality Modeling Language (VRML) 97, Virtual Reality Modeling Language (VRML) 97 specification, VRML 97 v2.1 Amendment
    • toStringVRML97

      public abstract java.lang.String toStringVRML97​(int indentLevel)
      Recursive method to provide VRML97 string serialization.
      Parameters:
      indentLevel - number of levels of indentation for this element
      Returns:
      VRML97 string
      See Also:
      X3D.FILE_EXTENSION_VRML97, X3D Resources: Virtual Reality Modeling Language (VRML) 97, Virtual Reality Modeling Language (VRML) 97 specification, VRML 97 v2.1 Amendment
    • isValid

      public boolean isValid()
      Recursive method to determine whether this element is valid.
      Returns:
      true if validate() has no results
    • validate

      public abstract java.lang.String validate()
      Recursive method to validate this element plus all contained nodes and statements, using both datatype-specification value checks and regular expression (regex) checking of corresponding string values.
      Returns:
      validation results (if any)