|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Meta-information for a NewsML session.
This interface provides a node-independent access point for getting and setting information about a NewsML session.
Method Summary | |
BaseNode |
findReference(String reference,
boolean useExternal)
Look up a reference to a NewsML node. |
String |
getBaseURL()
Get the base URL for the session. |
NewsMLFactory |
getFactory()
Get the factory for creating new NewsML documents. |
BaseNode |
getNodeByDuid(String duid)
Look up a node in the current document by Duid. |
BaseNode |
getNodeByXPath(BaseNode contextNode,
String xpath)
Get the first node matching an XPath expression. |
BaseNode[] |
getNodesByXPath(BaseNode contextNode,
String xpath)
Look up nodes in the current document by XPath. |
BaseNode |
getRootNode()
Get the root node of the current NewsML document. |
URL |
resolveHref(String href)
Resolve a reference. |
void |
setBaseURL(String baseURL)
Set the base URL for the session. |
Method Detail |
public NewsMLFactory getFactory()
public BaseNode getRootNode()
public BaseNode findReference(String reference, boolean useExternal) throws IOException
If the reference contains '#', the part following corresponds with a Duid in the target document (otherwise uses the root element); if the part preceding '#' is empty, the target document is the current document.
The getNodeByDuid(String)
method is a little
simpler and more efficient if you know for you're simply
searching for a node that matches a specific Duid.
reference
- The node reference, as a string in URI
reference format (may include a '#').useExternal
- true to follow references in external URLs,
false otherwise.IOException
- if there is an error finding the node.getNodeByDuid(String)
public BaseNode getNodeByDuid(String duid)
This is a more restrictive (and slightly more efficient)
version of findReference(java.lang.String, boolean)
; unlike findReference, this
method does not require a leading '#' on the Duid
(though it's optionally allowed), and does not throw an
IOException.
[Please note that in the current DOM implementation, only a few node types are castable; everything else must remain as BaseNode].
duid
- the document-unique identifier of the node to get.findReference(java.lang.String, boolean)
public BaseNode[] getNodesByXPath(BaseNode contextNode, String xpath) throws NewsMLException
This method looks up nodes by XPath, starting with the context node provided. Note that the XPath must match elements or no results will be returned (attribute matches are not currently supported, though attributes may be used in node tests).
contextNode
- The starting point, or context node, for
the XPath expression.xpath
- The XPath expression as a string.NewsMLException
- if the XPath expression provided
is invalid.public BaseNode getNodeByXPath(BaseNode contextNode, String xpath) throws NewsMLException
This method finds the first node matching the xpath expression provided, starting at the context node. Note that the XPath must match elements or no matching node will be found (attribute matches are not currently supported, though attributes may be used in node tests).
contextNode
- The starting point, or context node, for
the XPath expression.xpath
- The XPath expression as a string.NewsMLException
- if the XPath expression provided
is invalid.public String getBaseURL()
setBaseURL(String)
,
resolveHref(String)
public void setBaseURL(String baseURL)
Note that when a node is added as a child to another node, it adopts that node's session, and thus, may take on a different base URL.
baseURL
- The base URL for resolving references.getBaseURL()
,
resolveHref(String)
public URL resolveHref(String href) throws MalformedURLException
This method is useful for retrieving an external resource --
text or binary -- referenced from a NewsML package. See the
standard Java URL
class for information on how your
application can use the URL returned to load remote resources.
The method automatically resolves any relative hrefs against
the NewsML document's base URL.
href
- A (possibly relative) URL to resolve.MalformedURLException
- if the href cannot be resolved
into a URL (this can be caught as an IOException
).getBaseURL()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |