|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openpipeline.pipeline.item.Node
public class Node
A Node represents an element in a XML tree. A Node can be a tag or an attribute (name/value pair) within a tag. It can also have a block of text (a "value").
All node types can carry annotations, though it's most common to add them only to leaf nodes. An annotation is really just an arbitrary named object. It can be anything that should be attached to the node.
By convention, there are certain standard types of annotations. An object named "token" is a TokenList of the tokens in the text. An object named "skip" is a TokenList of skip tokens. (Skip tokens are spans of the text that should be skipped for text analytics purposes.)
Annotations can be helpful when passing an item from stage to stage; an earlier stage can attach some information to the node which can be consumed by a later stage. To attach information to the Item itself, attach it to the root node.
| Constructor Summary | |
|---|---|
Node(Item item,
Node parent)
|
|
| Method Summary | |
|---|---|
void |
addAttribute(Node attr)
|
Node |
addAttribute(String name,
String value)
|
Node |
addNode(String name)
|
Node |
addNode(String name,
char[] array,
int offset,
int size)
|
Node |
addNode(String name,
String value)
Add a node with the given name and value. |
void |
addValue(char[] array,
int off,
int size)
Adds a text value to this node. |
void |
addValue(String text)
Adds a text value to this node. |
void |
appendXMLtoBuffer(FastStringBuffer xmlBuf,
boolean includeAnnotations)
Append the contents of this object to the specified buffer in the form of a fragment of XML. |
TextValue |
findValue(String name)
Search for a node with the specified name and return its value. |
Object |
getAnnotations(String name)
Retrieve an object that was attached to this node by a call to putAnnotations(). |
Map |
getAnnotationsMap()
Return the object's internal map that maps names to annotations. |
int |
getAttributeCount()
|
NodeList |
getAttributes()
|
int |
getChildCount()
|
NodeList |
getChildren()
|
Item |
getItem()
|
String |
getName()
|
Node |
getParent()
|
TextValue |
getValue()
Return an underlying span of text that can be analyzed. |
boolean |
hasAttributes()
|
boolean |
hasChildren()
|
boolean |
isEmpty()
Returns true if this node has no children, attributes, or text. |
void |
putAnnotations(String name,
Object annotations)
Attach a named object to this node. |
void |
remove()
Remove this node from the parent. |
void |
setName(String name)
|
void |
setParent(Node tag)
|
void |
setValue(CharSpan text)
|
void |
setValue(String text)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Node(Item item,
Node parent)
| Method Detail |
|---|
public Node addAttribute(String name,
String value)
public void addAttribute(Node attr)
public NodeList getAttributes()
public Node addNode(String name)
public Node addNode(String name,
char[] array,
int offset,
int size)
public Node addNode(String name,
String value)
name - the name of the node. If not null, becomes a tag in the xml.value - the text underneath the tag
public void addValue(char[] array,
int off,
int size)
array - a char array that contains the text to addoff - the offset within the char array where the text to add startssize - the number of chars to addpublic void addValue(String text)
text - the text to add
public void appendXMLtoBuffer(FastStringBuffer xmlBuf,
boolean includeAnnotations)
xmlBuf - the buffer to receive the datapublic int getAttributeCount()
public boolean hasAttributes()
public Object getAnnotations(String name)
name - the name of the object
public Map getAnnotationsMap()
public int getChildCount()
public NodeList getChildren()
public Item getItem()
public Node getParent()
public TextValue getValue()
public boolean hasChildren()
public void putAnnotations(String name,
Object annotations)
name - the name of the objectannotations - any arbitrary objectpublic void setName(String name)
public void setParent(Node tag)
public void setValue(String text)
public void setValue(CharSpan text)
public String getName()
public void remove()
public boolean isEmpty()
public TextValue findValue(String name)
name - name of the node (tag) that contains the value
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||