|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectelectric.xml.Node
electric.xml.Child
electric.xml.Parent
electric.xml.Document
Document represents an XML document, and includes methods for parsing XML and accessing a document's root. When parsing XML, you can supply an optional Hashtable of namespace values that acts as global context.
Field Summary | |
static int |
KEEP_WHITESPACE
Keep whitespace during parsing. |
static int |
MAJOR_VERSION
The major version. |
static int |
MINOR_VERSION
The minor version. |
Fields inherited from class electric.xml.Parent |
children |
Fields inherited from class electric.xml.Child |
parent |
Fields inherited from class electric.xml.Node |
list, next, prev |
Fields inherited from interface org.w3c.dom.Node |
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE |
Fields inherited from interface electric.xml.IXMLConstants |
ATTLIST_START, ATTLIST_STOP, CDATA, CDATA_START, CDATA_STOP, CLOSE_TAG, COLON, COMMENT_START, COMMENT_STOP, DOCTYPE_START, DOCTYPE_STOP, ELEMENTDECL_START, ELEMENTDECL_STOP, ENCODING, ENTITYDECL_START, ENTITYDECL_STOP, ID, ID_CASE, INSTRUCTION_START, INSTRUCTION_STOP, NEGATIVE_INFINITY, NOT_A_NUMBER, NOTATIONDECL_START, NOTATIONDECL_STOP, NULL, OPEN_TAG, POSITIVE_INFINITY, PUBLIC, SPECIALS, STANDALONE, SUBSTITUTES, SYSTEM, UNDEFINED, VERSION, XML, XML_NAMESPACE, XMLDECL_START, XMLDECL_STOP, XMLNS, XMLNS_NAMESPACE |
Fields inherited from interface electric.xml.IDOMConstants |
CDATA_SECTION_NAME, COMMENT_NAME, CORE, DOCUMENT_FRAGMENT_NAME, DOCUMENT_NAME, HIERARCHY_REQUEST_ERR, TEXT_NAME |
Constructor Summary | |
Document()
Construct an empty Document. |
|
Document(byte[] bytes)
Construct a Document built by parsing the specified bytes. |
|
Document(byte[] bytes,
java.util.Hashtable context)
Construct a Document built by parsing the specified bytes. |
|
Document(byte[] bytes,
java.util.Hashtable context,
int flags)
Construct a Document built by parsing the specified bytes. |
|
Document(byte[] bytes,
int flags)
Construct a Document built by parsing the specified bytes. |
|
Document(Document document)
Construct a copy of the specified document. |
|
Document(Element root)
Construct a Document with the specified root element. |
|
Document(java.io.File file)
Construct a Document built by parsing the File. |
|
Document(java.io.File file,
int flags)
Construct a Document built by parsing the File. |
|
Document(java.util.Hashtable context)
Construct an empty Document. |
|
Document(java.io.InputStream stream)
Construct a Document built by parsing the InputStream. |
|
Document(java.io.InputStream stream,
int flags)
Construct a Document built by parsing the InputStream. |
|
Document(NodeReader nodeReader)
|
|
Document(NodeReader nodeReader,
java.util.Hashtable context)
|
|
Document(java.io.Reader reader)
Construct a Document built by parsing the contents of the Reader. |
|
Document(java.io.Reader reader,
java.util.Hashtable context)
Construct a Document built by parsing the contents of the Reader. |
|
Document(java.io.Reader reader,
java.util.Hashtable context,
int flags)
|
|
Document(java.io.Reader reader,
int flags)
Construct a Document built by parsing the contents of the Reader. |
|
Document(java.lang.String string)
Construct a Document built by parsing the specified string. |
|
Document(java.lang.String string,
int flags)
Construct a Document built by parsing the specified string. |
Method Summary | |
protected void |
addNamespacePrefixes(java.lang.String namespace,
java.util.Vector prefixes,
java.util.Vector matches)
Add all the prefixes that map to a particular namespace value in my context to the specified vector. |
void |
addPotentialNamespacePrefix(java.lang.String prefix,
java.lang.String namespace)
Set up a namespace to appear in the document if it is ever asked for. |
org.w3c.dom.Node |
appendChild(org.w3c.dom.Node newChild)
Adds the node newChild to the end of the list of children of this node. |
java.lang.Object |
clone()
Return a clone of this Document. |
org.w3c.dom.Attr |
createAttribute(java.lang.String name)
|
org.w3c.dom.Attr |
createAttributeNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
|
org.w3c.dom.CDATASection |
createCDATASection(java.lang.String data)
|
org.w3c.dom.Comment |
createComment(java.lang.String data)
|
org.w3c.dom.DocumentFragment |
createDocumentFragment()
|
org.w3c.dom.Element |
createElement(java.lang.String tagName)
|
org.w3c.dom.Element |
createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
|
org.w3c.dom.EntityReference |
createEntityReference(java.lang.String name)
|
org.w3c.dom.ProcessingInstruction |
createProcessingInstruction(java.lang.String target,
java.lang.String data)
|
org.w3c.dom.Text |
createTextNode(java.lang.String data)
|
java.util.Hashtable |
getContext()
Return my context. |
org.w3c.dom.DocumentType |
getDoctype()
|
DocType |
getDocType()
Return the DocType, or null if there is none. |
Document |
getDocument()
Return myself. |
org.w3c.dom.Element |
getDocumentElement()
|
org.w3c.dom.Element |
getElementById(java.lang.String elementId)
|
org.w3c.dom.NodeList |
getElementsByTagName(java.lang.String tagName)
|
org.w3c.dom.NodeList |
getElementsByTagNameNS(java.lang.String namespaceURI,
java.lang.String localName)
|
java.lang.String |
getEncoding()
Return the encoding for this document, which is UTF-8 by default. |
org.w3c.dom.DOMImplementation |
getImplementation()
|
java.lang.String |
getNamespace(java.lang.String prefix)
Return the value of the namespace with the specified prefix, or null if there is none. |
java.lang.String |
getNamespacePrefix(java.lang.String namespace)
Return a prefix that maps to a particular namespace value, searching from the current element up through its parents. |
java.lang.String |
getNodeName()
Return "#document". |
short |
getNodeType()
Return DOCUMENT_NODE. |
Element |
getRoot()
Return the top-level element in this Document. |
boolean |
getStandalone()
Return true if this document is standalone, which is false by default. |
java.lang.String |
getVersion()
Return the version of this document, which is 1.0 by default. |
boolean |
getWriteXMLDecl()
Return true if my XML declaration will be written. |
org.w3c.dom.Node |
importNode(org.w3c.dom.Node importedNode,
boolean deep)
|
boolean |
isStripped()
Return true if whitespace was stripped during parsing. |
Element |
newRoot()
Set the root to an empty element with no name. |
void |
read(NodeReader reader)
|
void |
setContext(java.util.Hashtable context)
Set my context. |
void |
setEncoding(java.lang.String encoding)
Set the encoding for this document. |
Element |
setRoot(Element element)
Set the root to the specified element. |
Element |
setRoot(java.lang.String name)
Set the root to an empty element with the specified name. |
Element |
setRoot(java.lang.String prefix,
java.lang.String name)
Set the root to an empty element with the specified namespace prefix and name. |
Element |
setRoot(java.lang.String prefix,
java.lang.String name,
java.lang.String namespace)
Set the root to an empty element with the specified namespace prefix and name. |
void |
setStandalone(boolean standalone)
Set the standalone value for this document. |
void |
setVersion(java.lang.String version)
Set the version for this document. |
void |
setWriteXMLDecl(boolean flag)
If flag is true, write my XML declaration when printing. |
int |
size()
|
void |
write(NodeWriter writer)
Write myself to the specified writer, starting at the specified indent level. |
Methods inherited from class electric.xml.Child |
cloneNode, getByteArray, getByteArray, getByteArray, getBytes, getBytes, getBytes, getNextSiblingChild, getOwnerDocument, getParent, getParentNode, getPreviousSiblingChild, replaceWith, setNextSiblingChild, setParent, setPreviousSiblingChild, toString, toString, write, write, write |
Methods inherited from class electric.xml.Node |
getAttributes, getLocalName, getNamespaceURI, getNextSibling, getNextSiblingNode, getNode, getNode, getNodes, getNodeValue, getPrefix, getPreviousSibling, getPreviousSiblingNode, hasAttributes, isSupported, normalize, remove, setNextSiblingNode, setNodeValue, setPrefix, setPreviousSiblingNode |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.w3c.dom.Node |
cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix |
Field Detail |
public static final int KEEP_WHITESPACE
public static final int MAJOR_VERSION
public static final int MINOR_VERSION
Constructor Detail |
public Document()
public Document(java.util.Hashtable context)
context
- A Hashtable of global namespaces.public Document(java.lang.String string) throws ParseException
string
- An XML document.
ParseException
- If an error occurs during parsing.public Document(java.lang.String string, int flags) throws ParseException
string
- An XML document.flags
- Parse flags.
ParseException
- If an error occurs during parsing.public Document(byte[] bytes) throws ParseException
bytes
- A byte array that is converted into a String.
ParseException
- If an error occurs during parsing.public Document(byte[] bytes, int flags) throws ParseException
bytes
- A byte array that is converted into a String.flags
- Parse flags.
ParseException
- If an error occurs during parsing.public Document(byte[] bytes, java.util.Hashtable context) throws ParseException
bytes
- A byte array that is converted into a String.context
- A Hashtable of global namespaces.
ParseException
- If an error occurs during parsing.public Document(byte[] bytes, java.util.Hashtable context, int flags) throws ParseException
bytes
- A byte array that is converted into a String.context
- A Hashtable of global namespaces.flags
- Parse flags.
ParseException
- If an error occurs during parsing.public Document(java.io.File file) throws ParseException
file
- The File to parse.
ParseException
- If an error occurs during parsing.public Document(java.io.File file, int flags) throws ParseException
file
- The File to parse.flags
- Parse flags.
ParseException
- If an error occurs during parsing.public Document(java.io.InputStream stream) throws ParseException
stream
- The InputStream to parse.
ParseException
- If an error occurs during parsing.public Document(java.io.InputStream stream, int flags) throws ParseException
stream
- The InputStream to parse.flags
- Parse flags.
ParseException
- If an error occurs during parsing.public Document(java.io.Reader reader) throws ParseException
reader
- The Reader.
ParseException
- If an error occurs during parsing.public Document(java.io.Reader reader, int flags) throws ParseException
reader
- The Reader.flags
- Parse flags.
ParseException
- If an error occurs during parsing.public Document(java.io.Reader reader, java.util.Hashtable context) throws ParseException
reader
- The Reader.context
- A Hashtable of global namespaces.
ParseException
- If an error occurs during parsing.public Document(java.io.Reader reader, java.util.Hashtable context, int flags) throws ParseException
reader
- context
- flags
-
ParseException
public Document(NodeReader nodeReader) throws ParseException
nodeReader
-
ParseException
public Document(NodeReader nodeReader, java.util.Hashtable context) throws ParseException
nodeReader
- context
-
ParseException
public Document(Element root)
root
- The root Element.public Document(Document document)
document
- The Document to copy.Method Detail |
public boolean isStripped()
public java.lang.Object clone()
clone
in class Child
public Document getDocument()
getDocument
in class Child
public Element getRoot()
getRoot
in class Child
public Element newRoot()
public Element setRoot(Element element)
element
- The new root.
public Element setRoot(java.lang.String name)
name
- The name of the new root.
public Element setRoot(java.lang.String prefix, java.lang.String name)
prefix
- The namespace prefix of the new root.name
- The name of the new root.
public Element setRoot(java.lang.String prefix, java.lang.String name, java.lang.String namespace)
prefix
- The namespace prefix of the new root.name
- The name of the new root.namespace
- The namepace the prefix should be associated with
public DocType getDocType()
public void read(NodeReader reader) throws java.io.IOException, NamespaceException
read
in class Node
reader
-
java.io.IOException
NamespaceException
public void write(NodeWriter writer) throws java.io.IOException
write
in class Node
writer
- The nodeWriter.
java.io.IOException
- If an I/O exception occurs.public java.lang.String getVersion()
public void setVersion(java.lang.String version)
version
- The new version.public java.lang.String getEncoding()
public void setEncoding(java.lang.String encoding)
encoding
- The new encoding.public boolean getStandalone()
public void setStandalone(boolean standalone)
standalone
- The new standalone value.public void setWriteXMLDecl(boolean flag)
flag
- The new setting.public boolean getWriteXMLDecl()
public java.util.Hashtable getContext()
public void setContext(java.util.Hashtable context)
context
- A Hashtable of global namespaces.public java.lang.String getNamespace(java.lang.String prefix)
getNamespace
in class Parent
prefix
- The prefix.protected void addNamespacePrefixes(java.lang.String namespace, java.util.Vector prefixes, java.util.Vector matches)
addNamespacePrefixes
in class Parent
namespace
- The namespace to matchprefixes
- All the prefixes so far.matches
- All the prefixes that matched.public java.lang.String getNamespacePrefix(java.lang.String namespace)
getNamespacePrefix
in class Parent
namespace
- The namespace to match.public void addPotentialNamespacePrefix(java.lang.String prefix, java.lang.String namespace)
prefix
- namespace
- public int size()
size
in class Parent
public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws org.w3c.dom.DOMException
appendChild
in interface org.w3c.dom.Node
appendChild
in class Parent
newChild
- The node to add. If the newChild is a ProcessingInstruction,
check to see if it's the XML decl, and deal with it appropriately to avoid
duplicate decls.
org.w3c.dom.DOMException
public short getNodeType()
getNodeType
in interface org.w3c.dom.Node
getNodeType
in class Node
public java.lang.String getNodeName()
getNodeName
in interface org.w3c.dom.Node
getNodeName
in class Node
public org.w3c.dom.Attr createAttribute(java.lang.String name)
createAttribute
in interface org.w3c.dom.Document
name
- The name.public org.w3c.dom.Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
createAttributeNS
in interface org.w3c.dom.Document
namespaceURI
- qualifiedName
- public org.w3c.dom.CDATASection createCDATASection(java.lang.String data)
createCDATASection
in interface org.w3c.dom.Document
data
- public org.w3c.dom.Comment createComment(java.lang.String data)
createComment
in interface org.w3c.dom.Document
data
- public org.w3c.dom.DocumentFragment createDocumentFragment()
createDocumentFragment
in interface org.w3c.dom.Document
public org.w3c.dom.Element createElement(java.lang.String tagName)
createElement
in interface org.w3c.dom.Document
tagName
- public org.w3c.dom.Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
createElementNS
in interface org.w3c.dom.Document
namespaceURI
- qualifiedName
- public org.w3c.dom.EntityReference createEntityReference(java.lang.String name)
createEntityReference
in interface org.w3c.dom.Document
name
- public org.w3c.dom.ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
createProcessingInstruction
in interface org.w3c.dom.Document
target
- data
- public org.w3c.dom.Text createTextNode(java.lang.String data)
createTextNode
in interface org.w3c.dom.Document
data
- public org.w3c.dom.DocumentType getDoctype()
getDoctype
in interface org.w3c.dom.Document
public org.w3c.dom.Element getDocumentElement()
getDocumentElement
in interface org.w3c.dom.Document
public org.w3c.dom.Element getElementById(java.lang.String elementId)
getElementById
in interface org.w3c.dom.Document
elementId
- public org.w3c.dom.NodeList getElementsByTagName(java.lang.String tagName)
getElementsByTagName
in interface org.w3c.dom.Document
tagName
- public org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
getElementsByTagNameNS
in interface org.w3c.dom.Document
namespaceURI
- localName
- public org.w3c.dom.DOMImplementation getImplementation()
getImplementation
in interface org.w3c.dom.Document
public org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode, boolean deep)
importNode
in interface org.w3c.dom.Document
importedNode
- deep
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |