Class ProtoInstanceObject

  • All Implemented Interfaces:
    ProtoInstance, X3DChildNode, X3DNode, X3DPrototypeInstance

    public class ProtoInstanceObject
    extends X3DConcreteNode
    implements ProtoInstance
    ProtoInstance can override field default values via fieldValue initializations. Non-recursive nested ProtoInstance and ProtoDeclare statements are allowed within a ProtoDeclare.

    X3D statement tooltip: [X3D statement] ProtoInstance creates an instance node of a locally or externally declared prototype definition. ProtoDeclare/ExternProtoDeclare definitions are abstract, corresponding ProtoInstance nodes are concrete. ProtoInstance nodes typically contain fieldValue statements to override default field values defined in the original ProtoDeclare statement.
    • Hint: the node type of a ProtoInstance exactly matches the first node in the corresponding ProtoDeclare/ProtoBody declaration.
    • Warning: be sure to correctly set the containerField value to match the intended field in the parent node.
    • Warning: do not mismatch node types when placing a ProtoInstance in a scene graph. Most validation tools will not catch this error.
    • Hint: scene authors can override default initializations of prototype fields by including contained <fieldValue> elements.
    • Hint: Nested ProtoInstance and ProtoDeclare statements are allowed within a ProtoDeclare/ProtoBody.
    • Hint: if contained within a ProtoDeclare, then a ProtoInstance node can also contain IS/connect statements for other defined fields.
    • Warning: a ProtoInstance node may not be instantiated inside its own ProtoDeclare or ExternProtoDeclare declaration (i.e. recursive prototypes are illegal).
    • Warning: the local context of each ProtoInstance node must match the node type of the first node in the original ProtoDeclare declaration.
    • Warning: ProtoInstance substitution for a Metadata* node might not validate. Workaround: put metadata-typed ProtoInstance nodes as contained values within a parent MetadataSet node.
    • Hint: X3D Scene Authoring Hints, Inlines and Prototypes http://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#InlinesPrototypes
    • Hint: X3D Architecture 4.4.4 Prototype semantics, http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/concepts.html#PROTOdefinitionsemantics Examples: X3D Example Archives, X3D for Web Authors, Chapter 14 Prototypes https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes

    Package hint: This org.web3d.x3d.jsail concrete class is used for implementing a standalone X3D object as a Plain Old Java Object (POJO). If you are writing Java code for use inside an X3D Script node, compile separate code using only the org.web3d.x3d.sai package instead.
    See Also:
    X3D Abstract Specification: ProtoInstance, X3D Tooltips: ProtoInstance, X3D Scene Authoring Hints: InlinesPrototypes
    • Field Detail

      • NAME

        public static final java.lang.String NAME
        String constant NAME provides name of this element: ProtoInstance.
        See Also:
        Constant Field Values
      • COMPONENT

        public static final java.lang.String COMPONENT
        String constant COMPONENT defines X3D component for the ProtoInstance element: Core
        See Also:
        Constant Field Values
      • LEVEL

        public static final int LEVEL
        Integer constant LEVEL provides default X3D Core component level for this element: 2
        See Also:
        Constant Field Values
      • IS_DEFAULT_VALUE

        public static final ISObject IS_DEFAULT_VALUE
        SFNode field named IS has default value null (Java syntax) or NULL (XML syntax).
      • METADATA_DEFAULT_VALUE

        public static final X3DMetadataObject METADATA_DEFAULT_VALUE
        SFNode field named metadata has default value null (Java syntax) or NULL (XML syntax).
      • NAME_DEFAULT_VALUE

        public static final java.lang.String NAME_DEFAULT_VALUE
        SFString field named name has default value equal to an empty string.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ProtoInstanceObject

        public ProtoInstanceObject()
        Constructor for ProtoInstanceObject to initialize member variables with default values.
      • ProtoInstanceObject

        public ProtoInstanceObject​(java.lang.String prototypeName)
        Utility constructor that assigns ProtoInstanceObject name after initializing member variables with default values.
        Parameters:
        prototypeName - initial name for this ProtoInstanceObject statement
      • ProtoInstanceObject

        public ProtoInstanceObject​(java.lang.String prototypeName,
                                   java.lang.String DEFlabel)
        Utility constructor that assigns ProtoInstanceObject prototypeName and DEF after initializing member variables with default values.
        Parameters:
        prototypeName - initial name for this ProtoInstanceObject statement
        DEFlabel - unique DEF name for this X3D node
    • Method Detail

      • getElementName

        public final java.lang.String getElementName()
        Provides name of this element: ProtoInstance
        Specified by:
        getElementName in class X3DConcreteElement
        Returns:
        name of this element
      • getComponent

        public final java.lang.String getComponent()
        Defines X3D component for the ProtoInstance element: Core
        Specified by:
        getComponent in class X3DConcreteElement
        Returns:
        X3D component for this element
      • getComponentLevel

        public final int getComponentLevel()
        Provides default X3D component level for this element: 2
        Specified by:
        getComponentLevel in class X3DConcreteElement
        Returns:
        default X3D component level for this element
      • getFieldType

        public java.lang.String getFieldType​(java.lang.String fieldName)
        Indicate type corresponding to given fieldName.
        Specified by:
        getFieldType in class X3DConcreteElement
        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 java.lang.String getAccessType​(java.lang.String fieldName)
        Indicate accessType corresponding to given fieldName.
        Specified by:
        getAccessType in class X3DConcreteElement
        Parameters:
        fieldName - name of field in this X3D statement
        Returns:
        X3D accessType (inputOnly etc.), otherwise ConfigurationProperties.ERROR_UNKNOWN_FIELD_ACCESSTYPE if not recognized
        See Also:
        ConfigurationProperties.ERROR_UNKNOWN_FIELD_ACCESSTYPE
      • initialize

        public final void initialize()
        Initialize all member variables to default values.
        Overrides:
        initialize in class X3DConcreteNode
      • getFieldValueList

        public java.util.ArrayList<fieldValueObject> getFieldValueList()
        Provide array of fieldValueObject results (using an array consisting of properly typed nodes or ProtoInstanceObjects) from inputOutput MFNode field fieldValue.

        Tooltip: Include fieldValue statements if this ProtoInstance overrides default values in any of the original field declarations. *


        Warning: according to X3D Unified Object Model (X3DUOM), acceptable node types are limited to fieldValue.
        Returns:
        value of fieldValue field
        See Also:
        fieldValueObject
      • setFieldValueList

        public ProtoInstanceObject setFieldValueList​(java.util.ArrayList<fieldValueObject> newValue)
        Accessor method to assign fieldValueObject array (using an array consisting of properly typed nodes or ProtoInstanceObjects) to inputOutput MFNode field fieldValue.

        Tooltip: Include fieldValue statements if this ProtoInstance overrides default values in any of the original field declarations. *


        Note: according to X3D Unified Object Model (X3DUOM), acceptable node types are limited to fieldValue.
        Parameters:
        newValue - is new value for the fieldValue field.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
      • setFieldValue

        public ProtoInstanceObject setFieldValue​(fieldValueObject newValue)
        Set single child fieldValue node, replacing prior array of existing nodes (if any).

        Note: according to X3D Unified Object Model (X3DUOM), acceptable node types are restricted to fieldValue.
        Parameters:
        newValue - is new node for the fieldValue field (restricted to fieldValue)
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
      • clearFieldValue

        public ProtoInstanceObject clearFieldValue()
        Utility method to clear MFNode value of fieldValueList field.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive setAttribute method invocations).
      • hasFieldValue

        public boolean hasFieldValue()
        Indicate whether an object is available for inputOutput MFNode field fieldValueList.
        Returns:
        whether a concrete statement array or CommentsBlock is available.
        See Also:
        getFieldValueList()
      • clearIS

        public ProtoInstanceObject clearIS()
        Utility method to clear SFNode value of IS field.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive setAttribute method invocations).
      • hasIS

        public boolean hasIS()
        Indicate whether an object is available for inputOutput SFNode field IS.
        Returns:
        whether a concrete statement or CommentsBlock is available.
        See Also:
        getIS()
      • clearMetadata

        public ProtoInstanceObject clearMetadata()
        Utility method to clear SFNode value of metadata field.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive setAttribute method invocations).
      • hasMetadata

        public boolean hasMetadata()
        Indicate whether an object is available for inputOutput SFNode field metadata.
        Returns:
        whether a properly typed node or ProtoInstance or CommentsBlock is available.
        See Also:
        getMetadata(), getMetadataProtoInstance(), X3D Scene Authoring Hints: Metadata Nodes
      • getName

        public java.lang.String getName()
        Provide String value from inputOutput SFString field named name.

        Tooltip: name of the prototype node being instanced.
        Specified by:
        getName in interface ProtoInstance
        Returns:
        value of name field
      • setName

        public ProtoInstanceObject setName​(SFStringObject newValue)
        Assign typed object value to SFString name field, similar to setName(String).
        Parameters:
        newValue - is new value for the name field.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
      • setDEF

        public final ProtoInstanceObject setDEF​(java.lang.String newValue)
        Accessor method to assign String value to inputOutput SFString field named DEF.

        Tooltip: DEF defines a unique ID name for this node, referenceable by other nodes.

        Note that setting the DEF value clears the USE value.
        Specified by:
        setDEF in class X3DConcreteNode
        Parameters:
        newValue - is new value for the DEF field.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
      • setDEF

        public ProtoInstanceObject setDEF​(SFStringObject newValue)
        Assign typed object value to SFString DEF field, similar to setDEF(String).
        Parameters:
        newValue - is new value for the DEF field.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
      • getUSE

        public java.lang.String getUSE()
        Provide String value from inputOutput SFString field named USE.

        Tooltip: USE means reuse an already DEF-ed node ID, excluding all child nodes and all other attributes (except for containerField, which can have a different value).
        • Hint: USE references to previously defined DEF geometry (instead of duplicating nodes) can improve performance.
        • Warning: do NOT include any child nodes, a DEF attribute, or any other attribute values (except for containerField) when defining a USE attribute.
        • Warning: each USE value must match a corresponding DEF value that is defined earlier in the scene.
        Overrides:
        getUSE in class X3DConcreteNode
        Returns:
        value of USE field
        See Also:
        X3D Scene Authoring Hints: Naming Conventions
      • setUSE

        public final ProtoInstanceObject setUSE​(java.lang.String newValue)
        Accessor method to assign String value to inputOutput SFString field named USE.

        Tooltip: USE means reuse an already DEF-ed node ID, excluding all child nodes and all other attributes (except for containerField, which can have a different value).
        • Hint: USE references to previously defined DEF geometry (instead of duplicating nodes) can improve performance.
        • Warning: do NOT include any child nodes, a DEF attribute, or any other attribute values (except for containerField) when defining a USE attribute.
        • Warning: each USE value must match a corresponding DEF value that is defined earlier in the scene.


        Note: each USE node is still an independent object, with the USE value matching the DEF value in the preceding object.

        Warning: invoking the setUSE() method on this node resets all other fields to their default values (except for containerField) and also releases all child nodes.

        Warning: no other operations can be performed to modify a USE node other than setting an alternate containerField value.
        Specified by:
        setUSE in class X3DConcreteNode
        Parameters:
        newValue - is new value for the USE field.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
      • setUSE

        public ProtoInstanceObject setUSE​(SFStringObject newValue)
        Assign typed object value to SFString USE field, similar to setUSE(String).
        Parameters:
        newValue - is new value for the USE field.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
      • getCssClass

        public java.lang.String getCssClass()
        Provide String value from inputOutput SFString field named class.

        Tooltip: The class attribute is a space-separated list of classes, reserved for use by CSS cascading stylesheets.
        • Warning: currently the class attribute is only supported in XML encoding of X3D scenes.
        • Hint: W3C Cascading Style Sheets https://www.w3.org/Style/CSS
        Overrides:
        getCssClass in class X3DConcreteNode
        Returns:
        value of class field
        See Also:
        W3C Cascading Style Sheets
      • setCssClass

        public final ProtoInstanceObject setCssClass​(java.lang.String newValue)
        Accessor method to assign String value to inputOutput SFString field named class.

        Tooltip: The class attribute is a space-separated list of classes, reserved for use by CSS cascading stylesheets.
        • Warning: currently the class attribute is only supported in XML encoding of X3D scenes.
        • Hint: W3C Cascading Style Sheets https://www.w3.org/Style/CSS
        Specified by:
        setCssClass in class X3DConcreteNode
        Parameters:
        newValue - is new value for the class field.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
        See Also:
        W3C Cascading Style Sheets
      • setCssClass

        public ProtoInstanceObject setCssClass​(SFStringObject newValue)
        Assign typed object value to SFString cssClass field, similar to setCssClass(String).
        Parameters:
        newValue - is new value for the class field.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
      • setUSE

        public ProtoInstanceObject setUSE​(ProtoInstanceObject DEFnode)
        Assign a USE reference to another DEF node of same node type, similar to setUSE(String).

        Warning: note that the setUSE() method on this node resets all other fields to their default values (except for containerField) and also releases all child nodes.

        Warning: no other operations can be performed to modify a USE node other than setting an alternate containerField value.
        Parameters:
        DEFnode - must have a DEF value defined
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
      • getOriginalName

        public java.lang.String getOriginalName()
        Utility method to find original ProtoInstance name if this ProtoInstance is a USE node (which does not include name).
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
      • hasExternProtoDeclare

        public boolean hasExternProtoDeclare()
        Determine whether a corresponding ExternProtoDeclare with same name is connected in this scene graph.
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).
        See Also:
        hasProtoDeclare(), getProtoDeclare(), getExternProtoDeclare()
      • addComments

        public ProtoInstanceObject addComments​(java.lang.String newComment)
        Add comment as String to contained commentsList.
        Specified by:
        addComments in class X3DConcreteElement
        Parameters:
        newComment - initial value
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive setAttribute method invocations).
      • addComments

        public ProtoInstanceObject addComments​(java.lang.String[] newComments)
        Add comments as String[] array to contained commentsList.
        Specified by:
        addComments in class X3DConcreteElement
        Parameters:
        newComments - array of comments
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive setAttribute method invocations).
      • findElementByNameValue

        public 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 findAncestorSceneObject() to check entire scene graph, or findAncestorX3DObject() 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.
        Specified by:
        findElementByNameValue in class X3DConcreteElement
        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), X3DConcreteElement.hasAncestorSceneObject(), X3DConcreteElement.findAncestorX3DObject()
      • findElementByNameValue

        public 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 findAncestorSceneObject() to check entire scene graph, or findAncestorX3DObject() 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.
        Specified by:
        findElementByNameValue in class X3DConcreteElement
        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), X3DConcreteElement.hasAncestorSceneObject(), X3DConcreteElement.findAncestorX3DObject()
      • hasElementByNameValue

        public boolean hasElementByNameValue​(java.lang.String nameValue,
                                             java.lang.String elementName)
        Recursive method to determine whether node or statement with given name attribute is found, meaning both objects are attached to same scene graph.
        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:
        whether node is found
        See Also:
        findElementByNameValue(String, String)
      • hasNodeByDEF

        public boolean hasNodeByDEF​(java.lang.String DEFvalue)
        Recursive method to determine whether node with DEFvalue is found, meaning both objects are attached to same scene graph.
        Parameters:
        DEFvalue - is value of the name field being searched for in this element and child elements(if any)
        Returns:
        whether node is found
        See Also:
        findNodeByDEF(String)
      • validate

        public 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.
        Specified by:
        validate in class X3DConcreteElement
        Returns:
        validation results (if any)
      • addFieldValue

        public ProtoInstanceObject addFieldValue​(fieldValueObject newFieldValue)
        Add fieldValue
        Parameters:
        newFieldValue - is fieldValue to add
        Returns:
        ProtoInstanceObject - namely this same object to allow sequential method pipelining (i.e. consecutive setAttribute method invocations).
      • findFieldValueByName

        public fieldValueObject findFieldValueByName​(java.lang.String fieldValueName)
        Find contained fieldValue statement by name, if present.
        Parameters:
        fieldValueName - is name attribute for fieldValue of interest
        Returns:
        fieldValueObject reference of interest, null otherwise
      • removeFieldValue

        public boolean removeFieldValue​(fieldValueObject fieldValueToRemove)
        Remove a fieldValue from contained fieldValueList
        Parameters:
        fieldValueToRemove - matching fieldValue of interest
        Returns:
        whether fieldValue was removed
        See Also:
        removeFieldValue(String)
      • removeFieldValue

        public boolean removeFieldValue​(java.lang.String fieldValueName)
        Remove a fieldValue by name from contained fieldValueList
        Parameters:
        fieldValueName - matching fieldValue of interest
        Returns:
        whether fieldValue was removed
        See Also:
        removeFieldValue(fieldValueObject)
      • clearFieldValues

        public void clearFieldValues()
        Clear all fieldValues
      • hasFieldValue

        public boolean hasFieldValue​(java.lang.String fieldValueName)
        Determine if fieldValue statement is present.
        Parameters:
        fieldValueName - is name attribute for fieldValue of interest
        Returns:
        whether fieldValue is found