Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.novell.nds.dirxml.driver
Class XmlDocument

    java.lang.Object
      com.novell.nds.dirxml.driver.XmlDocument

All Implemented Interfaces:
  Externalizable, Serializable

    public class XmlDocument

extends Object
implements Externalizable

The `XmlDocument` class wraps an XML document and allows that document to be accessed via DOM, SAX (v1), or a serialized form.

See Also:
  Serialized Form

Field Summary
`protected byte[]` | `documentBytes`
`protected Document` | `documentDOM`
`protected String` | `documentString`
`static int` | `DOM` Value returned from `getSource()` indicating that the XML data was set using a DOM `Document`.
`protected boolean` | `indent`
`protected InputSource` | `inputSource`
`static int` | `NOT_SET` Value returned from `getSource()` indicating that the XML data has not been set in the `XmlDocument` instance.
`static int` | `SAX` Value returned from `getSource()` indicating that the XML data was set using a SAX `Parser` and `InputSource`.
`protected Parser` | `saxParser`
`static int` | `SERIALIZED` Value returned from `getSource()` indicating that the XML data was set using a `String` or a `byte` array.
`protected int` | `source`
`protected XMLParser` | `xmlDocParser`

Constructor Summary
`XmlDocument()` Construct an empty XML document
`XmlDocument(byte[] document)` Construct an XML document based on an XML byte array
`XmlDocument(Document document)` Construct an XML document based on a DOM document
`XmlDocument(Parser parser, InputSource inputSource)` Construct an XML document based on a SAX Parser and InputSource
`XmlDocument(String document)` Construct an XML document based on an XML string

Method Summary
`Document` | `getDocument()` get document contents as a DOM document
`byte[]` | `getDocumentBytes(String encoding)` get document contents as a `byte` array
`InputSource` | `getDocumentInputSource()` Get SAX InputSource to use with SAX Parser returned from `getSAX()`.
`Document` | `getDocumentNS()` get document contents as a DOM Level 2 document with namespace information.
`Parser` | `getDocumentSAX()` get document contents as via a SAX Parser
`String` | `getDocumentString()` get document contents as a `String`
`boolean` | `getIndent()` Get if whitespace may be added for formatting when serializing document
`XMLParser` | `getParser()` get the parser used by this document
`Vector` | `getParserErrorMsgs()` get any pending parser error messages
`String` | `getParserErrorMsgString()` get any pending parser error messages, concatenated into one string and separated by a newline
`int` | `getSource()` Return the original source of the XML contained in this instance.
`XmlWriter` | `getXmlWriter(OutputStream outputStream, String encoding)` Return an XmlWriter instance suitable for serializing the document
`XmlWriter` | `getXmlWriter(Writer writer)` Return an XmlWriter instance suitable for serializing the document
`void` | `readDocument(InputStream document)` read document contents from an InputStream
`void` | `readDocument(InputStream document, String documentURI)`
`void` | `readDocument(Reader document)` read document contents from a Reader
`void` | `readDocument(String document)` read document contents from a URI string
`void` | `readDocument(URL document)` read document contents from a URL
`void` | `readExternal(ObjectInput in)` Mandatory readExternal method.
`void` | `setDocument(byte[] document)` set document contents based an XML byte array
`void` | `setDocument(Document document)` set document contents based a DOM document
`void` | `setDocument(Parser parser, InputSource inputSource)`
`void` | `setDocument(String document)` set document contents based an XML string
`void` | `setIndent(boolean indent)` Add whitespace for formatting to serialized document
`void` | `writeDocument(OutputStream document, String encoding)` write document content to an OutputStream
`void` | `writeDocument(Writer document)` write document contents to Writer
`void` | `writeExternal(ObjectOutput out)` Mandatory writeExernal method for object Serialization.

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

Field Detail

### NOT_SET

    public static final int NOT_SET

  Value returned from `getSource()` indicating that the XML data has not been set in the `XmlDocument` instance.

  See Also:
    Constant Field Values

### DOM

    public static final int DOM

  Value returned from `getSource()` indicating that the XML data was set using a DOM `Document`.

  See Also:
    Constant Field Values

### SAX

    public static final int SAX

  Value returned from `getSource()` indicating that the XML data was set using a SAX `Parser` and `InputSource`.

  See Also:
    Constant Field Values

### SERIALIZED

    public static final int SERIALIZED

  Value returned from `getSource()` indicating that the XML data was set using a `String` or a `byte` array.

  See Also:
    Constant Field Values

### documentDOM

    protected Document documentDOM

### documentString

    protected String documentString

### documentBytes

    protected byte[] documentBytes

### indent

    protected boolean indent

### saxParser

    protected Parser saxParser

### inputSource

    protected InputSource inputSource

### source

    protected int source

### xmlDocParser

    protected XMLParser xmlDocParser

Constructor Detail

### XmlDocument

    public XmlDocument()

  Construct an empty XML document

### XmlDocument

    public XmlDocument(Document document)

  Construct an XML document based on a DOM document

  Parameters:
    `document` - the document

### XmlDocument

    public XmlDocument(String document)

  Construct an XML document based on an XML string

  Parameters:
    `document` - the document

### XmlDocument

    public XmlDocument(byte[] document)

  Construct an XML document based on an XML byte array

  Parameters:
    `document` - the document

### XmlDocument

    public XmlDocument(Parser parser,
                       InputSource inputSource)

  Construct an XML document based on a SAX Parser and InputSource

  Parameters:
    `parser` - The SAX Parser interface
    `inputSource` - The SAX InputSource interface

Method Detail

### getSource

    public int getSource()

  Return the original source of the XML contained in this instance.

  Returns:
    `NOT_SET`, `DOM`, `SAX`, or `SERIALIZED`.

### setDocument

    public void setDocument(Document document)

  set document contents based a DOM document

  Parameters:
    `document` - the document

### setDocument

    public void setDocument(String document)

  set document contents based an XML string

  Parameters:
    `document` - the document

### setDocument

    public void setDocument(byte[] document)

  set document contents based an XML byte array

  Parameters:
    `document` - the document

### setDocument

    public void setDocument(Parser parser,
                            InputSource inputSource)

### readDocument

    public void readDocument(InputStream document)

  read document contents from an InputStream

  Parameters:
    `document` - the document

### readDocument

    public void readDocument(InputStream document,
                             String documentURI)
                      throws MalformedURLException

  Throws:
    `MalformedURLException`

### readDocument

    public void readDocument(Reader document)

  read document contents from a Reader

  Parameters:
    `document` - the document

### readDocument

    public void readDocument(URL document)
                      throws IOException

  read document contents from a URL

  Parameters:
    `document` - the document URL
  Throws:
    `IOException`

### readDocument

    public void readDocument(String document)
                      throws IOException

  read document contents from a URI string

  Parameters:
    `document` - the document URI string
  Throws:
    `IOException`

### writeDocument

    public void writeDocument(OutputStream document,
                              String encoding)
                       throws IOException,
                              UnsupportedEncodingException

  write document content to an OutputStream

  Parameters:
    `document` - the document
    `encoding` - desired encoding
  Throws:
    `IOException`
    `UnsupportedEncodingException`

### writeDocument

    public void writeDocument(Writer document)
                       throws IOException

  write document contents to Writer

  Parameters:
    `document` - the document
  Throws:
    `IOException`

### getDocument

    public Document getDocument()

  get document contents as a DOM document

  Returns:
    the document node

### getDocumentNS

    public Document getDocumentNS()

  get document contents as a DOM Level 2 document with namespace information. Note: This may replace the original DOM document with a copy if needed

  Returns:
    the document node

### getDocumentString

    public String getDocumentString()

  get document contents as a `String`

  Returns:
    the serialized document

### getDocumentBytes

    public byte[] getDocumentBytes(String encoding)

  get document contents as a `byte` array

  Parameters:
    `encoding` - desired encoding
  Returns:
    the serialized document

### getDocumentSAX

    public Parser getDocumentSAX()

  get document contents as via a SAX Parser

  Returns:
    A SAX Parser interface through which to get the document contents

### getDocumentInputSource

    public InputSource getDocumentInputSource()

  Get SAX InputSource to use with SAX Parser returned from `getSAX()`.

  Returns:
    The SAX `InputSource` to use with the returned SAX `Parser` from `getSAX()`.

### getXmlWriter

    public XmlWriter getXmlWriter(OutputStream outputStream,
                                  String encoding)
                           throws UnsupportedEncodingException

  Return an XmlWriter instance suitable for serializing the document

  Parameters:
    `outputStream` - The OutputStream to which to write.
    `encoding` - The character encoding to use in writing to the OutputStream
  Throws:
    `UnsupportedEncodingException`

### getXmlWriter

    public XmlWriter getXmlWriter(Writer writer)

  Return an XmlWriter instance suitable for serializing the document

  Parameters:
    `writer` - A Writer instance to which to serialize the document

### getParser

    public XMLParser getParser()

  get the parser used by this document

  Returns:
    the parser

### getParserErrorMsgs

    public Vector getParserErrorMsgs()

  get any pending parser error messages

  Returns:
    the messages

### getParserErrorMsgString

    public String getParserErrorMsgString()

  get any pending parser error messages, concatenated into one string and separated by a newline

  Returns:
    the messages

### setIndent

    public void setIndent(boolean indent)

  Add whitespace for formatting to serialized document

  Parameters:
    `indent` - True if whitespace may be added to serialized document

### getIndent

    public boolean getIndent()

  Get if whitespace may be added for formatting when serializing document

  Returns:
    True if whitespace may be added

### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

  Mandatory writeExernal method for object Serialization.

  Specified by:
    `writeExternal` in interface `Externalizable`
  Throws:
    `IOException`

### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

  Mandatory readExternal method. Explicitly restores the supertype's fields and then restores this class's fields

  Specified by:
    `readExternal` in interface `Externalizable`
  Throws:
    `IOException`
    `ClassNotFoundException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD