public class XmlDocument
extends java.lang.Object
implements java.io.Externalizable
XmlDocument
class wraps an XML document and allows that document to be
accessed via DOM, SAX (v1), or a serialized form.Modifier and Type | Field and Description |
---|---|
protected byte[] |
documentBytes |
protected org.w3c.dom.Document |
documentDOM |
protected java.lang.String |
documentString |
static int |
DOM
Value returned from
getSource() indicating that the XML data was
set using a DOM Document . |
protected boolean |
indent |
protected org.xml.sax.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 org.xml.sax.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 com.novell.xml.parser.XMLParser |
xmlDocParser |
Constructor and Description |
---|
XmlDocument()
Construct an empty XML document
|
XmlDocument(byte[] document)
Construct an XML document based on an XML byte array
|
XmlDocument(org.w3c.dom.Document document)
Construct an XML document based on a DOM document
|
XmlDocument(org.xml.sax.Parser parser,
org.xml.sax.InputSource inputSource)
Construct an XML document based on a SAX Parser and InputSource
|
XmlDocument(java.lang.String document)
Construct an XML document based on an XML string
|
Modifier and Type | Method and Description |
---|---|
org.w3c.dom.Document |
getDocument()
get document contents as a DOM document
|
byte[] |
getDocumentBytes(java.lang.String encoding)
get document contents as a
byte array |
com.novell.xml.dom.DocumentImpl |
getDocumentEx()
Get a DOM document representation using Novell's implementation.
|
org.xml.sax.InputSource |
getDocumentInputSource()
Get SAX InputSource to use with SAX Parser returned from
getSAX() . |
org.w3c.dom.Document |
getDocumentNS()
get document contents as a DOM Level 2 document with namespace information.
|
org.xml.sax.Parser |
getDocumentSAX()
get document contents as via a SAX Parser
|
java.lang.String |
getDocumentString()
get document contents as a
String |
boolean |
getIndent()
Get if whitespace may be added for formatting when serializing document
|
com.novell.xml.parser.XMLParser |
getParser()
get the parser used by this document
|
java.util.Vector |
getParserErrorMsgs()
get any pending parser error messages
|
java.lang.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.
|
com.novell.xml.util.XmlWriter |
getXmlWriter(java.io.OutputStream outputStream,
java.lang.String encoding)
Return an XmlWriter instance suitable for serializing the document
|
com.novell.xml.util.XmlWriter |
getXmlWriter(java.io.Writer writer)
Return an XmlWriter instance suitable for serializing the document
|
void |
readDocument(java.io.InputStream document)
read document contents from an InputStream
|
void |
readDocument(java.io.InputStream document,
java.lang.String documentURI) |
void |
readDocument(java.io.Reader document)
read document contents from a Reader
|
void |
readDocument(java.lang.String document)
read document contents from a URI string
|
void |
readDocument(java.net.URL document)
read document contents from a URL
|
void |
readExternal(java.io.ObjectInput in)
Mandatory readExternal method.
|
void |
setDocument(byte[] document)
set document contents based an XML byte array
|
void |
setDocument(org.w3c.dom.Document document)
set document contents based a DOM document
|
void |
setDocument(org.xml.sax.Parser parser,
org.xml.sax.InputSource inputSource) |
void |
setDocument(java.lang.String document)
set document contents based an XML string
|
void |
setIndent(boolean indent)
Add whitespace for formatting to serialized document
|
void |
writeDocument(java.io.OutputStream document,
java.lang.String encoding)
write document content to an OutputStream
|
void |
writeDocument(java.io.Writer document)
write document contents to Writer
|
void |
writeExternal(java.io.ObjectOutput out)
Mandatory writeExernal method for object Serialization.
|
public static final int NOT_SET
getSource()
indicating that the XML data has
not been set in the XmlDocument
instance.public static final int DOM
getSource()
indicating that the XML data was
set using a DOM Document
.public static final int SAX
getSource()
indicating that the XML data was
set using a SAX Parser
and InputSource
.public static final int SERIALIZED
getSource()
indicating that the XML data was
set using a String
or a byte
array.protected org.w3c.dom.Document documentDOM
protected java.lang.String documentString
protected byte[] documentBytes
protected boolean indent
protected org.xml.sax.Parser saxParser
protected org.xml.sax.InputSource inputSource
protected int source
protected com.novell.xml.parser.XMLParser xmlDocParser
public XmlDocument()
public XmlDocument(org.w3c.dom.Document document)
document
- the documentpublic XmlDocument(java.lang.String document)
document
- the documentpublic XmlDocument(byte[] document)
document
- the documentpublic XmlDocument(org.xml.sax.Parser parser, org.xml.sax.InputSource inputSource)
parser
- The SAX Parser interfaceinputSource
- The SAX InputSource interfacepublic int getSource()
NOT_SET
, DOM
, SAX
, or SERIALIZED
.public void setDocument(org.w3c.dom.Document document)
document
- the documentpublic void setDocument(java.lang.String document)
document
- the documentpublic void setDocument(byte[] document)
document
- the documentpublic void setDocument(org.xml.sax.Parser parser, org.xml.sax.InputSource inputSource)
public void readDocument(java.io.InputStream document)
document
- the documentpublic void readDocument(java.io.InputStream document, java.lang.String documentURI) throws java.net.MalformedURLException
java.net.MalformedURLException
public void readDocument(java.io.Reader document)
document
- the documentpublic void readDocument(java.net.URL document) throws java.io.IOException
document
- the document URLjava.io.IOException
public void readDocument(java.lang.String document) throws java.io.IOException
document
- the document URI stringjava.io.IOException
public void writeDocument(java.io.OutputStream document, java.lang.String encoding) throws java.io.IOException, java.io.UnsupportedEncodingException
document
- the documentencoding
- desired encodingjava.io.IOException
java.io.UnsupportedEncodingException
public void writeDocument(java.io.Writer document) throws java.io.IOException
document
- the documentjava.io.IOException
public org.w3c.dom.Document getDocument()
public org.w3c.dom.Document getDocumentNS()
public com.novell.xml.dom.DocumentImpl getDocumentEx()
public java.lang.String getDocumentString()
String
public byte[] getDocumentBytes(java.lang.String encoding)
byte
arrayencoding
- desired encodingpublic org.xml.sax.Parser getDocumentSAX()
public org.xml.sax.InputSource getDocumentInputSource()
getSAX()
.InputSource
to use with the returned SAX
Parser
from getSAX()
.public com.novell.xml.util.XmlWriter getXmlWriter(java.io.OutputStream outputStream, java.lang.String encoding) throws java.io.UnsupportedEncodingException
outputStream
- The OutputStream to which to write.encoding
- The character encoding to use in writing to the OutputStreamjava.io.UnsupportedEncodingException
public com.novell.xml.util.XmlWriter getXmlWriter(java.io.Writer writer)
writer
- A Writer instance to which to serialize the documentpublic com.novell.xml.parser.XMLParser getParser()
public java.util.Vector getParserErrorMsgs()
public java.lang.String getParserErrorMsgString()
public void setIndent(boolean indent)
indent
- True if whitespace may be added to serialized documentpublic boolean getIndent()
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException