# com.bea.xml
XmlObject.Factory Class

public static final class XmlObject.Factory
extends `Object`

Static factory class for creating new instances. Note that if a type can be inferred from the XML being loaded (for example, by recognizing the document element QName), then the instance returned by a factory will have the inferred type. Otherwise the Factory will returned an untyped document.

Hierarchy
  `Object`
  `XmlObject.Factory`

Enclosing interface
  `XmlObject`

## Method Summary

`public static `XmlObject`` | `newInstance`() Creates a new, completely empty instance.
`public static `XmlObject`` | `newInstance`(`XmlOptions` options) Creates a new, completely empty instance, specifying options for the root element's document type and/or whether to validate value facets as they are set.
`public static `XMLInputStream`` | `newValidatingXMLInputStream`(`XMLInputStream` xis) Returns a new validating `XMLInputStream``` that throws exceptions when the input is not valid.
`public static `XMLInputStream`` | `newValidatingXMLInputStream`(`XMLInputStream` xis, `XmlOptions` options) Returns a new validating `XMLInputStream``` that throws exceptions when the input is not valid, specifying options for the root element's document type and/or the collection object to use as an error listener while validating.
`public static `XmlObject`` | `newValue`(`Object` obj) Creates an immutable `XmlObject``` value
`public static `XmlSaxHandler`` | `newXmlSaxHandler`() Returns an `XmlSaxHandler``` that can load an XmlObject from SAX events.
`public static `XmlSaxHandler`` | `newXmlSaxHandler`(`XmlOptions` options) Returns an `XmlSaxHandler``` that can load an XmlObject from SAX events.
`public static `XmlObject`` | `parse`(`String` s) Parses the given `String``` as XML.
`public static `XmlObject`` | `parse`(`String` s, `XmlOptions` options) Parses the given `String``` as XML.
`public static `XmlObject`` | `parse`(`File` f) Parses the given `File``` as XML.
`public static `XmlObject`` | `parse`(`File` f, `XmlOptions` options) Parses the given `File``` as XML.
`public static `XmlObject`` | `parse`(`URL` u) Downloads the given `URL``` as XML.
`public static `XmlObject`` | `parse`(`URL` u, `XmlOptions` options) Downloads the given `URL``` as XML.
`public static `XmlObject`` | `parse`(`InputStream` is) Decodes and parses the given `InputStream``` as XML.
`public static `XmlObject`` | `parse`(`InputStream` is, `XmlOptions` options) Decodes and parses the given `InputStream``` as XML.
`public static `XmlObject`` | `parse`(`Reader` r) Parses the given `Reader``` as XML.
`public static `XmlObject`` | `parse`(`Reader` r, `XmlOptions` options) Parses the given `Reader``` as XML.
`public static `XmlObject`` | `parse`(`Node` node) Converts the given DOM `Node``` into an XmlObject.
`public static `XmlObject`` | `parse`(`Node` node, `XmlOptions` options) Converts the given DOM `Node``` into an XmlObject.
`public static `XmlObject`` | `parse`(`XMLInputStream` xis) Loads the given `XMLInputStream``` into an XmlObject.
`public static `XmlObject`` | `parse`(`XMLInputStream` xis, `XmlOptions` options) Loads the given `XMLInputStream``` into an XmlObject.

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Detail

### newInstance() Method

    public static XmlObject newInstance()

Creates a new, completely empty instance.

### newInstance(XmlOptions) Method

    public static XmlObject newInstance(XmlOptions options)

Creates a new, completely empty instance, specifying options for the root element's document type and/or whether to validate value facets as they are set.

Use the options parameter to specify the following:

To specify this | Use this method
--- | ---
The document type for the root element. | `XmlOptions.setDocumentType(SchemaType)```
Whether value facets should be checked as they are set. | `XmlOptions.setValidateOnSet()```

#### Parameters

options
  Options specifying root document type and/or value facet checking.

#### Returns

A new, empty instance of XmlObject.

### newValidatingXMLInputStream(XMLInputStream) Method

DEPRECATED Superceded by JSR 173

    public static XMLInputStream newValidatingXMLInputStream(XMLInputStream xis)
         throws XmlException, XMLStreamException

Returns a new validating `XMLInputStream``` that throws exceptions when the input is not valid.

#### Exceptions

``XmlException``
``XMLStreamException``

### newValidatingXMLInputStream(XMLInputStream, XmlOptions) Method

DEPRECATED Superceded by JSR 173

    public static XMLInputStream newValidatingXMLInputStream(XMLInputStream xis,
                                                             XmlOptions options)
         throws XmlException, XMLStreamException

Returns a new validating `XMLInputStream``` that throws exceptions when the input is not valid, specifying options for the root element's document type and/or the collection object to use as an error listener while validating.

Use the options parameter to specify the following:

- A collection instance that should be used as an error listener during compilation, as described in `XmlOptions.setErrorListener(Collection)```.
- The document type for the root element, as described in `XmlOptions.setDocumentType(SchemaType)```.

#### Parameters

xis
  The basis for the new XMLInputStream.

options
  Options specifying root document type and/or an error listener.

#### Returns

A new validating XMLInputStream.

#### Exceptions

``XmlException``
``XMLStreamException``

### newValue(Object) Method

    public static XmlObject newValue(Object obj)

Creates an immutable `XmlObject``` value

### newXmlSaxHandler() Method

    public static XmlSaxHandler newXmlSaxHandler()

Returns an `XmlSaxHandler``` that can load an XmlObject from SAX events.

### newXmlSaxHandler(XmlOptions) Method

    public static XmlSaxHandler newXmlSaxHandler(XmlOptions options)

Returns an `XmlSaxHandler``` that can load an XmlObject from SAX events.

### parse(String) Method

    public static XmlObject parse(String s)
         throws XmlException

Parses the given `String``` as XML.

#### Exceptions

``XmlException``

### parse(String, XmlOptions) Method

    public static XmlObject parse(String s,
                                  XmlOptions options)
         throws XmlException

Parses the given `String``` as XML. Use the options parameter to specify the following:

To specify this | Use this method
--- | ---
The document type for the root element. | `XmlOptions.setDocumentType(SchemaType)```
To place line number annotations in the store when parsing a document. | `XmlOptions.setLoadLineNumbers()```
To replace the document element with the specified QName when parsing. | `XmlOptions.setLoadReplaceDocumentElement(QName)```
To strip all insignificant whitespace when parsing a document. | `XmlOptions.setLoadStripWhitespace()```
To strip all comments when parsing a document. | `XmlOptions.setLoadStripComments()```
To strip all processing instructions when parsing a document. | `XmlOptions.setLoadStripProcinsts()```
A map of namespace URI substitutions to use when parsing a document. | `XmlOptions.setLoadSubstituteNamespaces(Map)```
Additional namespace mappings to be added when parsing a document. | `XmlOptions.setLoadAdditionalNamespaces(Map)```
To trim the underlying XML text buffer immediately after parsing a document, resulting in a smaller memory footprint. | `XmlOptions.setLoadTrimTextBuffer()```

#### Parameters

s
  The string to parse.

options
  Options as specified.

#### Returns

A new instance containing the specified XML.

#### Exceptions

``XmlException``

### parse(File) Method

    public static XmlObject parse(File f)
         throws XmlException, IOException

Parses the given `File``` as XML.

#### Exceptions

``XmlException``
``IOException``

### parse(File, XmlOptions) Method

    public static XmlObject parse(File f,
                                  XmlOptions options)
         throws XmlException, IOException

Parses the given `File``` as XML.

#### Exceptions

``XmlException``
``IOException``

### parse(URL) Method

    public static XmlObject parse(URL u)
         throws XmlException, IOException

Downloads the given `URL``` as XML.

#### Exceptions

``XmlException``
``IOException``

### parse(URL, XmlOptions) Method

    public static XmlObject parse(URL u,
                                  XmlOptions options)
         throws XmlException, IOException

Downloads the given `URL``` as XML.

#### Exceptions

``XmlException``
``IOException``

### parse(InputStream) Method

    public static XmlObject parse(InputStream is)
         throws XmlException, IOException

Decodes and parses the given `InputStream``` as XML.

#### Exceptions

``XmlException``
``IOException``

### parse(InputStream, XmlOptions) Method

    public static XmlObject parse(InputStream is,
                                  XmlOptions options)
         throws XmlException, IOException

Decodes and parses the given `InputStream``` as XML. Use the options parameter to specify the following:

To specify this | Use this method
--- | ---
The character encoding to use when parsing or writing a document. | `XmlOptions.setCharacterEncoding(String)```
The document type for the root element. | `XmlOptions.setDocumentType(SchemaType)```
Place line number annotations in the store when parsing a document. | `XmlOptions.setLoadLineNumbers()```
Replace the document element with the specified QName when parsing. | `XmlOptions.setLoadReplaceDocumentElement(QName)```
Strip all insignificant whitespace when parsing a document. | `XmlOptions.setLoadStripWhitespace()```
Strip all comments when parsing a document. | `XmlOptions.setLoadStripComments()```
Strip all processing instructions when parsing a document. | `XmlOptions.setLoadStripProcinsts()```
Set a map of namespace URI substitutions to use when parsing a document. | `XmlOptions.setLoadSubstituteNamespaces(Map)```
Set additional namespace mappings to be added when parsing a document. | `XmlOptions.setLoadAdditionalNamespaces(Map)```
Trim the underlying XML text buffer immediately after parsing a document, resulting in a smaller memory footprint. | `XmlOptions.setLoadTrimTextBuffer()```

#### Exceptions

``XmlException``
``IOException``

### parse(Reader) Method

    public static XmlObject parse(Reader r)
         throws XmlException, IOException

Parses the given `Reader``` as XML.

#### Exceptions

``XmlException``
``IOException``

### parse(Reader, XmlOptions) Method

    public static XmlObject parse(Reader r,
                                  XmlOptions options)
         throws XmlException, IOException

Parses the given `Reader``` as XML.

#### Exceptions

``XmlException``
``IOException``

### parse(Node) Method

    public static XmlObject parse(Node node)
         throws XmlException

Converts the given DOM `Node``` into an XmlObject.

#### Exceptions

``XmlException``

### parse(Node, XmlOptions) Method

    public static XmlObject parse(Node node,
                                  XmlOptions options)
         throws XmlException

Converts the given DOM `Node``` into an XmlObject.

#### Exceptions

``XmlException``

### parse(XMLInputStream) Method

DEPRECATED Superceded by JSR 173

    public static XmlObject parse(XMLInputStream xis)
         throws XmlException, XMLStreamException

Loads the given `XMLInputStream``` into an XmlObject.

#### Exceptions

``XmlException``
``XMLStreamException``

### parse(XMLInputStream, XmlOptions) Method

DEPRECATED Superceded by JSR 173

    public static XmlObject parse(XMLInputStream xis,
                                  XmlOptions options)
         throws XmlException, XMLStreamException

Loads the given `XMLInputStream``` into an XmlObject.

#### Exceptions

``XmlException``
``XMLStreamException``