|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openpipeline.pipeline.item.Item
public class Item
An Item is the main object that the pipeline operates on. An Item is a document,
database record, or other data structure that contains fields and text.
The pipeline passes an Item from one Stage to the next where it gets
transformed in some manner at each step.
An Item is similar to a DOM tree. It maps very closely to an XML-like
data structure. Each tag in an XML document is a Node. See the
Node class for more on the structure of Nodes.
Each item can carry a unique ID. See setItemId(String)/getItemId().
Each item can carry attribute definitions. An "attribute" in this case is a path
through the tags of the document. See AttributeDef for more.
Each item can carry an "action". An action can be ACTION_ADD, ACTION_UPDATE,
or ACTION_DELETE. The action is intended to tell the last stage in the pipeline
what to do with the item. See setAction(int).
| Field Summary | |
|---|---|
static int |
ACTION_ADD
|
static int |
ACTION_DELETE
|
static int |
ACTION_UPDATE
|
| Constructor Summary | |
|---|---|
Item()
|
|
Item(int bufSize)
Constructor |
|
| Method Summary | |
|---|---|
void |
appendXMLtoBuffer(FastStringBuffer xmlBuf)
|
void |
appendXMLtoBuffer(FastStringBuffer xmlBuf,
boolean includeAnnotations)
|
void |
clear()
|
int |
getAction()
|
Map<String,AttributeDef> |
getAttributeDefs()
Return a Map of AttributeDef objects, where the key is the attributeId and the value is the AttributeDef. |
FastStringBuffer |
getBuffer()
|
String |
getItemId()
Get the itemId, the primary key for this item. |
Node |
getRootNode()
|
boolean |
hasAttributeDefs()
Return true if this item has any AttributeDefs attached to it. |
void |
importXML(Reader in)
Parses the specified XML and populates this item, creating nodes as needed. |
void |
importXML(String xml)
Convenience method equivalent to importXML(new StringReader(xml)); |
void |
setAction(int action)
|
void |
setAttributeDefs(Map<String,AttributeDef> attributeDefs)
Set a Map of AttributeDef objects, where the key is the attributeId and the value is the AttributeDef. |
void |
setItemId(String itemId)
Set the itemId, the primary key for this item. |
void |
setRootNode(Node newRoot)
|
String |
toString()
|
void |
visitNodes(NodeVisitor visitor)
This method makes it easier for a class to process all the nodes in an item. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int ACTION_ADD
public static final int ACTION_UPDATE
public static final int ACTION_DELETE
| Constructor Detail |
|---|
public Item()
public Item(int bufSize)
bufSize - the starting size of the internal text buffer| Method Detail |
|---|
public Node getRootNode()
public void setRootNode(Node newRoot)
public void clear()
public FastStringBuffer getBuffer()
public int getAction()
public void setAction(int action)
public void setItemId(String itemId)
itemId - the itemIdpublic String getItemId()
public void importXML(String xml)
importXML(new StringReader(xml));
xml - the XML to import
IOExceptionXMLFilterpublic void importXML(Reader in)
in - a stream of characters that contains XML.
IOExceptionXMLFilterpublic String toString()
toString in class Objectpublic void appendXMLtoBuffer(FastStringBuffer xmlBuf)
public void appendXMLtoBuffer(FastStringBuffer xmlBuf,
boolean includeAnnotations)
public void visitNodes(NodeVisitor visitor)
throws PipelineException
switch (node.getType()) {
case Node.TEXT:
// deal with text node
break;
case Node.TAG:
case Node.ATTRIBUTE:
// etc
break;
}
visitor - the class that will visit each node
PipelineException - some recoverable exceptionpublic Map<String,AttributeDef> getAttributeDefs()
public void setAttributeDefs(Map<String,AttributeDef> attributeDefs)
attributeDefs - the Map of AttributeDefspublic boolean hasAttributeDefs()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||