|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Base interface for all NewsML objects.
The base interface provides basic services for navigation and
serialization, as well as access to the NewsMLSession
,
which allows the client application to execute queries against
the NewsML object tree.
Method Summary | |
BaseNode[] |
getChild()
Get an array of child nodes. |
BaseNode |
getChild(int index)
Get a child of the node by position. |
BaseNode[] |
getChild(String xmlName)
Get an array of child nodes with the specified XML name. |
BaseNode |
getChild(String xmlName,
int index)
Get a child of the node by name and position. |
int |
getChildCount()
Count the children for this node. |
int |
getChildCount(String xmlName)
Count the children with the specified name. |
BaseNode |
getParent()
Get the parent of the node in the NewsML content tree. |
BaseNode[] |
getPath()
Get the path from the root node to this node. |
NewsMLSession |
getSession()
Get the NewsML session associated with the package. |
String |
getXMLName()
Get the XML element name associated with the node. |
String |
getXPath()
Get the XPath from the document root to this node. |
void |
removeSelf()
Remove this node from the NewsML tree. |
String |
toXML(boolean isDocument)
Get an XML rendition of this node. |
String |
toXML(String encoding,
String internalSubset)
Get an XML document rendition of this node. |
void |
writeXML(Writer output,
boolean isDocument)
Serialize this node as XML. |
void |
writeXML(Writer output,
String encoding,
String internalSubset)
Serialize a node as an XML document. |
Method Detail |
public String getXMLName()
public String getXPath()
public NewsMLSession getSession()
public BaseNode getParent()
getChild(int)
public int getChildCount()
See getChild(int)
for information on what is and is
not counted as a child here.
getChildCount(String)
public int getChildCount(String xmlName)
See getChild(int)
for information on what
is and is not counted as a child here.
xmlName
- The XML name of the children to count.getXMLName()
,
getChildCount()
public BaseNode getChild(int index)
This method uses the XML notion of parent/child, not the NewsML notion. That difference can matter quite a bit; for example, while the get* methods for information in subelements and information in attributes are indistinguishable in the NewsML Toolkit API, this method will deal only with the element children.
Some elements in the XML are not represented directly in the NewsML toolkit; in that case, the element will be counted, but invoking this method (or any other getChild method) will return null. Currently, the following XML elements do not map directly to a NewsML Toolkit interface: Delete, InsertAfter, InsertBefore, SizeInBytes (the toolkit treats it as an int), and Update.
Since the result of invoking this method can be
unpredictable in so many ways, it is recommend to use the named
getChild(String, int)
method whenever possible.
index
- The index of the child, zero-based, numbered
sequentially.getParent()
,
getChild(String,int)
public BaseNode getChild(String xmlName, int index)
See getChild(int)
for information on what
is and is not counted as a child here.
xmlName
- The XML name of the children to use.index
- The index of the child, zero-based, numbered
sequentially, counting only children with the given XML name.getChild(int)
public BaseNode[] getChild()
See getChild(int)
for information on what
is and is not counted as a child here.
public BaseNode[] getChild(String xmlName)
See getChild(int)
for information on what
is and is not counted as a child here.
xmlName
- The XML name of the child nodes to return.public void removeSelf() throws NewsMLException
WARNING: removing a node may result in an invalid NewsML tree. Don't use this method unless you know what you're doing.
This method will work for nodes represented as XML elements, but not for nodes represented as XML attributes. It will also fail for the root node of the NewsML tree (often, but not always "NewsML") and will throw a NewsMLException for all failures.
If the implementation does not support modification, it may also throw an exception.
NewsMLException
- if the implementation cannot remove
this node for any reason.public BaseNode[] getPath()
public void writeXML(Writer output, boolean isDocument) throws IOException
This method will create XML markup representing the current node and all of its descendants. It will not reproduct the original XML markup character-for-character, but will create a structurally-equivalent version. The method works on the raw XML level, and has no specialized knowledge of Namespaces (yet).
output
- The character stream to which the XML should
be written (this method will not close the stream).isDocument
- True if this node is to represent a complete
XML document (with DOCTYPE declaration and prolog), false
otherwise.IOException
- if there is an error writing the
document.toXML(boolean)
public void writeXML(Writer output, String encoding, String internalSubset) throws IOException
This method serializes a NewsML node like writeXML(Writer,boolean)
, except that the node is
always made into a full XML docuument, and that the
provided character encoding and internal DTD subset will be
used in place of the defaults.
output
- The character stream to which the XML should
be written (this method will not close the stream).encoding
- The encoding string to be used in the XML
declaration, or null to use the default. Note that this will
not affect the encoding actually used by the Writer -- it is
the application's responsibility to ensure that the two
correspond.internalSubset
- The internal DTD subset to use, the empty
string for an empty subset, or null to use the default.toXML(String,String)
public String toXML(boolean isDocument)
See writeXML(Writer,boolean)
for information on the
serialization.
isDocument
- True if this node is to represent a complete
XML document (with DOCTYPE declaration and prolog), false
otherwise.writeXML(Writer,boolean)
public String toXML(String encoding, String internalSubset)
See writeXML(Writer,String,String)
for details.
encoding
- The encoding to include in the XML declaration,
or null to use the default.internalSubset
- The internal DTD subset to use, the empty
string for an empty subset, or null to use the default.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |