|
Open SiteSearch 4.1.1 Final |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ORG.oclc.xml.om.ElementImpl | +--ORG.oclc.xml.om.Document
This class implements an XML document, which can be thought of as the root of a tree.
Each XML tag can either represent a node or a leaf of this tree.
The Document
class allows you to load an XML document, manipulate it,
and then save it back out again. The document can be loaded by specifying
a URL or an input stream.
According to the XML specification, the root of the tree consists of any combination
of comments and processing instructions, but only one root element.
A helper method getRoot
is provided
as a short cut to finding the root element.
Element
Field Summary | |
protected DTD |
dtd
The Document Type Definition (DTD). |
protected ElementFactory |
factory
The factory used to create the elements in the document. |
Fields inherited from class ORG.oclc.xml.om.ElementImpl |
attrlist |
Constructor Summary | |
Document()
Constructs a new empty document using the default element factory. |
|
Document(ElementFactory f)
Constructs a new empty document using the given ElementFactory object when building the XML element
hierarchy. |
Method Summary | |
void |
addChild(Element elem,
Element after)
Adds a child Element to the document. |
void |
clear()
Sets the Document back to its initial empty state retaining only the ElementFactory association. |
Element |
createElement(Element parent,
int type,
Name tag,
String text)
Creates a new element for the given element type and tag name using the ElementFactory for this Document . |
Element |
createElement(int type)
Creates a new element for a given element type with a null tag name. |
Element |
createElement(int type,
String tag)
Creates a new element for the given element type and tag name. |
XMLOutputStream |
createOutputStream(OutputStream out)
Creates an XML output stream matching the format found on load() . |
Enumeration |
elementDeclarations()
Retrieves an enumeration of the element declarations from the DTD. |
Element |
findEntity(Name name)
Returns the XML-DATA specification for the named entity. |
String |
getCharset()
Retrieves the character set. |
Name |
getDocType()
Returns the name specified in the <!DOCTYPE> tag. |
DTD |
getDTD()
Retrieves the document's DTD. |
String |
getDTDURL()
Retrieves the document type URL. |
Element |
getElementDecl(Name name)
Returns the XML-DATA specification for the named element. |
String |
getEncoding()
Retrieves the character encoding information. |
long |
getFileModifiedDate()
Retrieves the last modified date on the source of the URL. |
String |
getId()
Retrieves the external identifier. |
int |
getOutputStyle()
Retrieves the current output style. |
Element |
getParent()
Retrieves the parent element. |
Element |
getRoot()
Retrieves the root node of the XML parse tree. |
String |
getStandalone()
Retrieves the standalone information. |
String |
getText()
Retrieves the document text. |
int |
getType()
Retrieves the document type. |
String |
getURL()
Retrieves the URL. |
String |
getVersion()
Retrieves the version information. |
boolean |
isCaseInsensitive()
Return whether we're case insensitive. |
void |
load(InputStream in)
Loads the document using the given input stream. |
void |
load(String urlstr)
Loads the document from the given URL string. |
void |
load(URL url)
Loads the document from the given URL. |
boolean |
loadExternal()
Return whether to load external DTD's or entities. |
void |
parsed(Element e)
Called when the given element is completely parsed. |
void |
parsedAttribute(Element e,
Name name,
Object value)
delegate to contained element factory |
void |
removeChild(Element elem)
Removes the specified child Element from the Document. |
void |
reportError(ParseException e,
OutputStream out)
Returns information about the given parse exception that was generated during the load. |
void |
save(XMLOutputStream o)
Saves the document to the given output stream. |
void |
setCaseInsensitive(boolean yes)
Switch to determine whether next XML loaded will be treated as case sensitive or not. |
void |
setCharset(String encoding)
Sets the character set. |
void |
setEncoding(String encoding)
Sets the character encoding for output. |
void |
setLoadExternal(boolean yes)
Switch to determine whether to load external DTD's or entities. |
void |
setOutputStyle(int style)
Sets the style for writing to an output stream. |
void |
setStandalone(String value)
Sets the RMD stored in the <?XML ...?> tag. |
void |
setText(String text)
Passes the text through to the root node, if there is a root node. |
void |
setURL(String urlstr)
An alias for load and is here for compatibility reasons only. |
void |
setVersion(String version)
Sets the version number stored in the <?XML ...?> tag. |
Methods inherited from class ORG.oclc.xml.om.ElementImpl |
addChild,
getAttribute,
getAttribute,
getAttributes,
getChild,
getChildren,
getElements,
getTagName,
isAttributeQualified,
numAttributes,
numElements,
qualifyName,
removeAttribute,
removeAttribute,
saveAttributes,
setAttribute,
setAttribute,
setParent,
toSchema,
toString |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected DTD dtd
protected ElementFactory factory
Constructor Detail |
public Document()
public Document(ElementFactory f)
ElementFactory
object when building the XML element
hierarchy.f
- The ElementFactory
to use.Method Detail |
public int getType()
Element.DOCUMENT
.public String getText()
public void setText(String text)
text
- The text to be set.public Element getParent()
Document
, so this method
always returns null.public void addChild(Element elem, Element after)
Element
to the document.
This is an override of the Element.addChild
method that
stores
the new child and stores the last element of type Element.ELEMENT
,
so that getRoot
can be used as a short cut to find a particular element.elem
- The child element to add.after
- The element after which to add the elem element.public void removeChild(Element elem)
Element
from the Document.elem
- The child element to remove.public final Element getRoot()
Element.ELEMENT
.public final String getVersion()
public final void setVersion(String version)
version
- The version information to set.public final String getEncoding()
public final void setEncoding(String encoding)
public final String getCharset()
setEncoding
method and exists for
compatibility
reasons only.public final void setCharset(String encoding)
getEncoding
method and exists for compatibility
reasons only.encoding
- The encoding information.public final String getStandalone()
public final void setStandalone(String value)
value
- The attribute value ('yes' or 'no').public final Name getDocType()
public final String getDTDURL()
public final String getURL()
public long getFileModifiedDate()
public final String getId()
public final Element createElement(Element parent, int type, Name tag, String text)
ElementFactory
for this Document
.
This method allows the Document
class to be used as an
ElementFactory
itself.type
- The element type.tag
- The element tag.public final Element createElement(int type, String tag)
type
- The element type.tag
- The element tag name.public final Element createElement(int type)
type
- The element type.public void parsed(Element e)
e
- The Element that has been parsed.public void parsedAttribute(Element e, Name name, Object value)
public void setCaseInsensitive(boolean yes)
public boolean isCaseInsensitive()
public void setLoadExternal(boolean yes)
public boolean loadExternal()
public void load(String urlstr) throws ParseException
urlstr
- The URL specifying the address of the document.public void setURL(String urlstr) throws ParseException
urlstr
- The URL string.public void load(URL url) throws ParseException
url
- The URL string.public void load(InputStream in) throws ParseException
in
- The input stream.public void reportError(ParseException e, OutputStream out)
e
- The exception to report on.out
- The output stream to report to.public void setOutputStyle(int style)
int
- The style to set.XMLOutputStream
public int getOutputStyle()
public XMLOutputStream createOutputStream(OutputStream out) throws IOException
load()
.out
- The output stream.public void save(XMLOutputStream o) throws IOException
o
- The output stream.public final Enumeration elementDeclarations()
ElementDecl
objects.public Element getElementDecl(Name name)
public Element findEntity(Name name)
public void clear()
ElementFactory
association.public DTD getDTD()
|
Open SiteSearch 4.1.1 Final |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |