|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Base interface for the main nodes in the NewsML content tree.
There are five basic nodes types in the NewsML content tree:
NewsML
,NewsItem
,NewsComponent
,NewsItemRef
, andContentItem
.The basic grammar of the NewsML content tree is as follows:
NewsML: NewsItem+ NewsItem: NewsComponent? NewsComponent: ((NewsItem|NewsItemRef)+ | NewsComponent+ | ContentItem+) NewsItemRef: [reference to another NewsItem] ContentItem: [actual data inline or by reference]
Field Summary | |
static int |
CONTENT_ITEM
Constant: node is a content item. |
static int |
NEWS_COMPONENT
Constant: node is a news component. |
static int |
NEWS_ITEM
Constant: node is a news item. |
static int |
NEWS_ITEM_REF
Constant: node is a reference to a news item. |
static int |
NEWSML
Constant: node is the top-level NewsML package. |
Method Summary | |
ContentItem |
asContentItem()
Cast this node to a ContentItem node. |
NewsComponent |
asNewsComponent()
Cast this node to a NewsComponent node. |
NewsItem |
asNewsItem()
Cast this node to a NewsItem node. |
NewsItemRef |
asNewsItemRef()
Cast this node to a NewsItemRef node. |
NewsML |
asNewsML()
Cast this node to a NewsML node. |
PrimaryNode[] |
getChild()
Get an array of primary child nodes. |
PrimaryNode |
getChild(int index)
Return a child of the node by position. |
int |
getChildCount()
Return the number of children for this node. |
PrimaryNode[] |
getNodePath()
Return the path of nodes from the root to this node. |
PrimaryNode |
getParent()
Get the parent of the node in the NewsML content tree. |
int |
getType()
Get the type of the node in the NewsML content tree. |
Methods inherited from interface org.newsml.toolkit.BaseNode |
getSession, getXMLName |
Methods inherited from interface org.newsml.toolkit.IdNode |
getDuid, getEuid |
Field Detail |
public static final int NEWSML
getType()
public static final int NEWS_ITEM
getType()
public static final int NEWS_COMPONENT
getType()
public static final int NEWS_ITEM_REF
getType()
public static final int CONTENT_ITEM
getType()
Method Detail |
public int getType()
Use this method to determine the type of a primary node so that you can invoke the appropriate casting method. Normally, an application will use this method in a switch statement similar to the following (assuming that the do* methods belong to the application):
switch (node.getType()) { case PrimaryNode.NEWSML: doNewsML(node.asNewsML()); break; case PrimaryNode.NEWS_ITEM: doNewsItem(node.asNewsItem()); break; case PrimaryNode.NEWS_COMPONENT: doNewsComponent(node.asNewsComponent()); break; case PrimaryNode.NEWS_ITEM_REF: doNewsItemRef(node.asNewsItemRef()); break; case PrimaryNode.CONTENT_ITEM: doContentItem(node.asContentItem()); break; default: throw new Error("Internal error: unexpected primary node type."); }
This method is redundant with BaseNode.getXMLName()
in
the BaseNode
interface, since the XML name can
unambiguously distinguish the node type.
NEWSML
,
NEWS_ITEM
,
NEWS_COMPONENT
,
NEWS_ITEM_REF
,
CONTENT_ITEM
public PrimaryNode getParent()
getChild(int)
public int getChildCount()
public PrimaryNode getChild(int index)
index
- The index of the child, zero-based, numbered
sequentially.getParent()
public PrimaryNode[] getChild()
public NewsML asNewsML()
getType()
,
NEWSML
public NewsItem asNewsItem()
getType()
,
NEWS_ITEM
public NewsComponent asNewsComponent()
getType()
,
NEWS_COMPONENT
public NewsItemRef asNewsItemRef()
getType()
,
NEWS_ITEM_REF
public ContentItem asContentItem()
getType()
,
CONTENT_ITEM
public PrimaryNode[] getNodePath()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |