Class X3DLoaderDOM

java.lang.Object
org.web3d.x3d.jsail.X3DLoaderDOM

public class X3DLoaderDOM
extends java.lang.Object
Concrete class for loading an X3D graphics string, file or fragment, encoded in XML, using the Document Object Model (DOM).

See Also:
Java Tutorials: Document Object Model (DOM), Java Tutorials: Reading XML Data into a DOM, X3D Abstract Specification: 7.2.5 Abstract X3D structure, X3D Scene Authoring Hints
  • Field Summary

    Fields 
    Modifier and Type Field Description
    boolean DEFAULT_DTD_VALIDATE
    Default dtdValidate value for documentBuilderFactory
    boolean DEFAULT_XSD_VALIDATE
    Default xsdValidate value for documentBuilderFactory
    protected java.lang.String indentLevel  
    protected int lineBreakWidth  
  • Constructor Summary

    Constructors 
    Constructor Description
    X3DLoaderDOM()
    Default constructor to initialize X3DLoaderDOM
  • Method Summary

    Modifier and Type Method Description
    org.w3c.dom.Document getDomDocument()
    Provide DOM document version of externally loaded X3D file
    java.lang.String getValidationResult()
    Provide detailed log of validation results following loading and serialization
    X3DConcreteElement getX3dObjectTree()
    Provide X3DJSAIL object tree if loading succeeds
    boolean isDtdValidationPerformed()
    Accessor method indicating whether DTD validation is performed when loading an X3D file
    boolean isLoadSuccessful()
    Accessor method to indicate whether loading was successful and loaded X3dObjectTree is available
    boolean isXmlSchemaValidationPerformed()
    Accessor method indicating whether DTD validation is performed when loading an X3D file
    boolean loadModelFromFileX3D​(java.io.File x3dFile)
    Load the XML X3D file using DOM, report success
    boolean loadModelFromFileX3D​(java.lang.String fileName)
    Load the XML X3D file using DOM, report whether successful.
    boolean loadModelFromFileX3D​(java.lang.String path, java.lang.String fileName)
    Load the XML X3D file using DOM, report whether successful.
    void setDtdValidationPerformed​(boolean newDtdValidationValue)
    Accessor method to set whether DTD validation is performed when loading an X3D file, reconfiguring documentBuilderFactory
    void setXmlSchemaValidation​(boolean newXmlSchemaValidationValue)
    Accessor method to set whether XML Schema validation is performed when loading an X3D file, reconfiguring documentBuilderFactory
    java.lang.String toStringX3D​(org.w3c.dom.Node node)
    Convenience method, use DOM to create X3D string from a previously loaded document with default zero indent.
    X3DConcreteElement toX3dModelInstance​(org.w3c.dom.Node node)
    Recursive method that uses DOM to create X3DJSAIL objects from a previously loaded document, taking advantage of Java Reflection and String-based field accessors with protected access that are not otherwise usable.
    X3DConcreteElement toX3dModelInstance​(org.w3c.dom.Node node, X3DConcreteElement parentElement)
    Recursive method that uses DOM to create X3DJSAIL objects from a previously loaded document, taking advantage of Java Reflection and String-based field accessors with protected access that are not otherwise usable.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • X3DLoaderDOM

      public X3DLoaderDOM()
      Default constructor to initialize X3DLoaderDOM
  • Method Details

    • loadModelFromFileX3D

      public boolean loadModelFromFileX3D​(java.lang.String fileName)
      Load the XML X3D file using DOM, report whether successful. Fails if file is empty.
      Parameters:
      fileName - path and name of .x3d or .xml file (XML encoding)
      Returns:
      whether successful
      See Also:
      loadModelFromFileX3D(File)
    • loadModelFromFileX3D

      public boolean loadModelFromFileX3D​(java.lang.String path, java.lang.String fileName)
      Load the XML X3D file using DOM, report whether successful. Fails if file is empty.
      Parameters:
      path - directory path to file of interest
      fileName - path and name of .x3d or .xml file (XML encoding)
      Returns:
      whether successful
      See Also:
      loadModelFromFileX3D(File)
    • loadModelFromFileX3D

      public boolean loadModelFromFileX3D​(java.io.File x3dFile)
      Load the XML X3D file using DOM, report success
      Parameters:
      x3dFile - existing x3d file (XML encoding)
      Returns:
      whether successful
      See Also:
      loadModelFromFileX3D(String)
    • getDomDocument

      public org.w3c.dom.Document getDomDocument()
      Provide DOM document version of externally loaded X3D file
      Returns:
      the DOM document, if XML-encoded X3D file was successfully loaded
    • toStringX3D

      public java.lang.String toStringX3D​(org.w3c.dom.Node node)
      Convenience method, use DOM to create X3D string from a previously loaded document with default zero indent. X3D output is XML encoding.
      Parameters:
      node - DOM Node to process
      Returns:
      the loaded X3D document of interest, starting with regular X3D element headers or possibly a scene fragment
      See Also:
      X3D.FILE_EXTENSION_X3D, X3D.FILE_EXTENSION_XML
    • toX3dModelInstance

      public X3DConcreteElement toX3dModelInstance​(org.w3c.dom.Node node)
      Recursive method that uses DOM to create X3DJSAIL objects from a previously loaded document, taking advantage of Java Reflection and String-based field accessors with protected access that are not otherwise usable.
      Parameters:
      node - DOM Node to process
      Returns:
      the loaded X3D objects of interest, starting with regular X3D object or possibly a scene fragment
      See Also:
      Java Tutorials: Reflection API, Java Reflection in Action
    • toX3dModelInstance

      public X3DConcreteElement toX3dModelInstance​(org.w3c.dom.Node node, X3DConcreteElement parentElement)
      Recursive method that uses DOM to create X3DJSAIL objects from a previously loaded document, taking advantage of Java Reflection and String-based field accessors with protected access that are not otherwise usable.
      Parameters:
      node - DOM Node to process
      parentElement - the parent of this scene object, if any
      Returns:
      the loaded X3D objects of interest, starting with regular X3D object or possibly a scene fragment
      See Also:
      Java Tutorials: Reflection API, Java Reflection in Action
    • isDtdValidationPerformed

      public boolean isDtdValidationPerformed()
      Accessor method indicating whether DTD validation is performed when loading an X3D file
      Returns:
      whether XML DTD validation is performed when loading an X3D file
    • setDtdValidationPerformed

      public void setDtdValidationPerformed​(boolean newDtdValidationValue)
      Accessor method to set whether DTD validation is performed when loading an X3D file, reconfiguring documentBuilderFactory
      Parameters:
      newDtdValidationValue - whether DTD validation is performed
    • isXmlSchemaValidationPerformed

      public boolean isXmlSchemaValidationPerformed()
      Accessor method indicating whether DTD validation is performed when loading an X3D file
      Returns:
      whether XML Schema validation is performed when loading an X3D file
    • setXmlSchemaValidation

      public void setXmlSchemaValidation​(boolean newXmlSchemaValidationValue)
      Accessor method to set whether XML Schema validation is performed when loading an X3D file, reconfiguring documentBuilderFactory
      Parameters:
      newXmlSchemaValidationValue - whether XML Schema validation is performed
    • getX3dObjectTree

      public X3DConcreteElement getX3dObjectTree()
      Provide X3DJSAIL object tree if loading succeeds
      Returns:
      X3D object tree if loading was successful, null otherwise
    • isLoadSuccessful

      public boolean isLoadSuccessful()
      Accessor method to indicate whether loading was successful and loaded X3dObjectTree is available
      Returns:
      whether loading was successful
    • getValidationResult

      public java.lang.String getValidationResult()
      Provide detailed log of validation results following loading and serialization
      Returns:
      validationResult log following loading and serialization