public class Document extends Node
Copyright (C) 2002 Hewlett-Packard Company. This file is part of Sparta, an XML Parser, DOM, and XPath library. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Document| 限定符和类型 | 类和说明 |
|---|---|
class |
Document.Index |
static interface |
Document.Observer
Something that is informed whenever the document changes.
|
| 构造器和说明 |
|---|
Document()
Create new empty in-memory Document with a null documentElement.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addObserver(Document.Observer observer) |
Object |
clone()
Deep copy of this document.
|
protected int |
computeHashCode()
Called whenever cached version of hashCode needs to be regenerated.
|
void |
deleteObserver(Document.Observer observer) |
boolean |
equals(Object thatO)
Two documents are equal IFF their document elements are equal.
|
Element |
getDocumentElement() |
String |
getSystemId() |
void |
setDocumentElement(Element rootElement)
Set the root element of this DOM tree.
|
void |
setSystemId(String systemId) |
String |
toString()
Same as
getSystemId |
void |
toString(Writer writer)
Accumulate text nodes hierarchically.
|
void |
toXml(Writer writer)
Write DOM to XML.
|
boolean |
xpathEnsure(String xpath)
Just like Element.xpathEnsure, but also handles case of no documentElement.
|
Document.Index |
xpathGetIndex(String xpath)
For faster lookup by XPath return (creating if necessary) an
index.
|
boolean |
xpathHasIndex(String xpath) |
Element |
xpathSelectElement(String xpath)
Select the first element that matches the absolute XPath
expression in this document, or null if
there is no match.
|
Enumeration |
xpathSelectElements(String xpath)
Select all the elements that match the absolute XPath
expression in this document.
|
String |
xpathSelectString(String xpath)
Select the first element that matches the absolute XPath
expression in this document, or null if
there is no match.
|
Enumeration |
xpathSelectStrings(String xpath)
Select all the strings that match the absolute XPath
expression in this document.
|
getAnnotation, getNextSibling, getOwnerDocument, getParentNode, getPreviousSibling, hashCode, htmlEncode, setAnnotation, toXml, xpathSetStringspublic Object clone()
public String getSystemId()
public void setSystemId(String systemId)
systemId - the filename, URL, or other ID by which this document is known.public String toString()
getSystemIdpublic Element getDocumentElement()
public void setDocumentElement(Element rootElement)
public Enumeration xpathSelectElements(String xpath) throws ParseException
xpathSelectElements 在类中 NodeParseExceptionpublic Enumeration xpathSelectStrings(String xpath) throws ParseException
xpathSelectStrings 在类中 NodeParseExceptionpublic Element xpathSelectElement(String xpath) throws ParseException
xpathSelectElement 在类中 NodeParseExceptionpublic String xpathSelectString(String xpath) throws ParseException
xpathSelectString 在类中 NodeParseExceptionpublic boolean xpathEnsure(String xpath) throws ParseException
ParseExceptionpublic boolean xpathHasIndex(String xpath)
xpathGetIndex(java.lang.String)public Document.Index xpathGetIndex(String xpath) throws ParseException
Enumeration leaders;
if( doc.xpathHasIndex( "/Team/Members[@firstName]" ){
//fast version
Document.Index index = doc.xpathGetIndex( "/Team/Members[@role]" );
leaders = index.get("leader");
}else
//slow version
leaders = doc.xpathSelectElement( "/Team/Members[@role='leader']" );
ParseExceptionpublic void addObserver(Document.Observer observer)
public void deleteObserver(Document.Observer observer)
public void toString(Writer writer) throws IOException
IOExceptionpublic void toXml(Writer writer) throws IOException
IOExceptionpublic boolean equals(Object thatO)
protected int computeHashCode()
computeHashCode 在类中 NodeCopyright © 2016. All Rights Reserved.