Package org.apache.commons.jxpath.xml

# Class DocumentContainer

java.lang.Object
org.apache.commons.jxpath.xml.XMLParser2
org.apache.commons.jxpath.xml.DocumentContainer

All Implemented Interfaces:
  `Serializable`, `Container`, `XMLParser`

public class DocumentContainer extends XMLParser2 implements Container
An XML document container reads and parses XML only when it is accessed. JXPath traverses Containers transparently - you use the same paths to access objects in containers as you do to access those objects directly. You can create XMLDocumentContainers for various XML documents that may or may not be accessed by XPaths. If they are, they will be automatically read, parsed and traversed. If they are not - they won't be read at all.

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `MODEL_DOM`
  DOM constant
  `static final String`
  `MODEL_JDOM`
  JDOM constant

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DocumentContainer(URL xmlURL)`
  Use this constructor if the desired model is DOM.
  `DocumentContainer(URL xmlUrl, String model)`
  Constructs a new DocumentContainer.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `getValue()`
  Reads XML, caches it internally and returns the Document.
  `Object`
  `parseXML(InputStream stream)`
  Parses XML using the parser for the specified model.
  `static void`
  `registerXMLParser(String model, String parserClassName)`
  Add a class of a custom XML parser.
  `static void`
  `registerXMLParser(String model, XMLParser parser)`
  Add an XML parser.
  `void`
  `setValue(Object value)`
  Throws an UnsupportedOperationException.

  ### Methods inherited from class org.apache.commons.jxpath.xml.XMLParser2

  `isCoalescing, isExpandEntityReferences, isIgnoringComments, isIgnoringElementContentWhitespace, isNamespaceAware, isValidating, setCoalescing, setExpandEntityReferences, setIgnoringComments, setIgnoringElementContentWhitespace, setNamespaceAware, setValidating`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### MODEL_DOM

    public static final String MODEL_DOM
    DOM constant
    See Also:
      - Constant Field Values

  - ### MODEL_JDOM

    public static final String MODEL_JDOM
    JDOM constant
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### DocumentContainer

    public DocumentContainer(URL xmlURL)
    Use this constructor if the desired model is DOM.
    Parameters:
      `xmlURL` - is a URL for an XML file. Use getClass().getResource(resourceName) to load XML from a resource file.

  - ### DocumentContainer

    public DocumentContainer(URL xmlUrl, String model)
    Constructs a new DocumentContainer.
    Parameters:
      `xmlUrl` - is a URL for an XML file. Use getClass().getResource (resourceName) to load XML from a resource file.
      `model` - is one of the MODEL_* constants defined in this class. It determines which parser should be used to load the XML.

- ## Method Details

  - ### registerXMLParser

    public static void registerXMLParser(String model, String parserClassName)
    Add a class of a custom XML parser. Parsers for the models "DOM" and "JDOM" are pre-registered.
    Parameters:
      `model` - model name
      `parserClassName` - parser class name

  - ### registerXMLParser

    public static void registerXMLParser(String model, XMLParser parser)
    Add an XML parser. Parsers for the models "DOM" and "JDOM" are pre-registered.
    Parameters:
      `model` - model name
      `parser` - parser

  - ### getValue

    public Object getValue()
    Reads XML, caches it internally and returns the Document.
    Specified by:
      `getValue` in interface `Container`
    Returns:
      Object

  - ### parseXML

    public Object parseXML(InputStream stream)
    Parses XML using the parser for the specified model.
    Specified by:
      `parseXML` in interface `XMLParser`
    Specified by:
      `parseXML` in class `XMLParser2`
    Parameters:
      `stream` - InputStream
    Returns:
      Object

  - ### setValue

    public void setValue(Object value)
    Throws an UnsupportedOperationException.
    Specified by:
      `setValue` in interface `Container`
    Parameters:
      `value` - value (not) to set