|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.ricebridge.xmlman.in.XmlOutputHandler
Internal Class; handles XML saving and generation operations.
This is a single use object, a new instance must be created for each operation.
Used internally by XmlManager.
| Constructor Summary | |
XmlOutputHandler()
Create a new XmlOutputHandler with empty state. |
|
| Method Summary | |
XmlOutputHandler |
copy(XmlSpec pXmlSpec)
Copy, using specified XmlSpec. |
OutNode |
createNodeTree(List pOutPathList)
Create the tree data structure of nodes that represents the XML format to generate. |
void |
endWrite(boolean pThrowClose)
End writing of record data by closing all open elements. |
void |
findChanges(OutNode pNode,
OutNode pSubNode,
OutNode pIgnoreNode)
Recursively find all data field change possibilities, starting from subnode and store them in the specified node. |
OutNode |
findRoot()
Find the root node starting from the record node. |
OutNode |
findRoot(OutNode pOutNode)
Find the root node starting from the given node. |
OutNode |
findStartNode()
Find the starting node for the current record, based on data field changes. |
OutNode |
findSubNode(OutNode pFind,
String pName)
Find named subnode of specified node, at any depth. |
BadRecordListener |
getBadRecordListener()
Get the BadRecordListener object currently in use. |
String[] |
getFieldNames()
Get the field names of the primary RecordSpec - may be null. |
RecordProvider |
getRecordProvider()
Get the RecordProvider object for the current save operation. |
MutableStats |
getStats()
Get the current Stats object used when saving XML record data. |
XmlSpec |
getXmlSpec()
Get the current XmlSpec object to use when saving XML record data. |
boolean |
isFinished()
When true, the saving process has finished. |
void |
makeChangeLists(OutNode pSourceNode)
Resolve data field change possibilities for all ancestors of source node |
void |
prepare(RecordSpec pRecordSpec)
Prepare internal data structures using the specified RecordSpec object. |
void |
run()
Start saving operation in separate Thread. |
void |
saveFile(File pXmlFile)
Save XML data to a file. |
void |
saveOutputStream(OutputStream pXmlOutputStream)
Save XML data to an OutputStream. |
void |
setBadRecordListener(BadRecordListener pBadRecordListener)
Set the BadRecordListener object to receive BadRecord description objects
as bad data records are encountered. |
void |
setRecordProvider(RecordProvider pRecordProvider)
Set the RecordProvider object for the current save operation. |
void |
setStats(MutableStats pStats)
Set the Stats object to use when saving XML record data. |
void |
setXmlSpec(XmlSpec pXmlSpec)
Set the XmlSpec object to use when saving XML record data. |
void |
setXmlWriter(XmlWriter pXmlWriter)
Set the XmlWriter object to use when saving XML record data. |
void |
startWrite()
Start writing of record data. |
void |
traverse(OutNode pStartNode,
boolean pNoRecord)
Non-recursive traversal of node structure, outputting XML at each node. |
void |
write()
Output the specified XML for each data record. |
void |
writeRecord(String[] pValues)
Output XML for record data fields in full, creating parent elements as necessary. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public XmlOutputHandler()
XmlOutputHandler with empty state.
| Method Detail |
public XmlOutputHandler copy(XmlSpec pXmlSpec)
XmlSpec.
public void run()
run in interface RunnableXmlSpec.setBackground(boolean)public boolean isFinished()
true, the saving process has finished.
When false, the saving process is still in progress.
Use this method when the saving process is running in the background as a separate thread.
See XmlSpec.setBackground(boolean) for details.
XmlSpec.setBackground(boolean)public void setXmlWriter(XmlWriter pXmlWriter)
XmlWriter object to use when saving XML record data.
The XmlWriter class handles the generation of XML content.
For full details, see the XmlWriter documentation.
pXmlWriter - the XmlWriter object to useXmlWriterpublic void setXmlSpec(XmlSpec pXmlSpec)
XmlSpec object to use when saving XML record data.
The XmlSpec class lets you set the options to use when
saving XML. For full details, see the XmlSpec documentation.
pXmlSpec - the XmlSpec object to useXmlSpecpublic XmlSpec getXmlSpec()
XmlSpec object to use when saving XML record data.
If no XmlSpec has been specified, a default one will be
created and stored.
setXmlSpec(com.ricebridge.xmlman.XmlSpec)public void setStats(MutableStats pStats)
Stats object to use when saving XML record data.
Statistics (such as number of records) are saved to this object.
pStats - Stats object to useStatspublic MutableStats getStats()
Stats object used when saving XML record data.
If no Stats object has been specified, a default one will be
created and stored.
setStats(com.ricebridge.xmlman.in.MutableStats)public void setRecordProvider(RecordProvider pRecordProvider)
RecordProvider object for the current save operation.
This RecordProvider is used by the save operation.
pRecordProvider - automatic RecordProviderpublic RecordProvider getRecordProvider()
RecordProvider object for the current save operation.
setRecordProvider(com.ricebridge.xmlman.RecordProvider)public void setBadRecordListener(BadRecordListener pBadRecordListener)
BadRecordListener object to receive BadRecord description objects
as bad data records are encountered.
If the ignore bad records option is true
then each BadRecord is reported to the BadRecordListener. If it is
false, then only the first BadRecord is reported, before processing halts.
pBadRecordListener - BadRecordListener objectpublic BadRecordListener getBadRecordListener()
BadRecordListener object currently in use.
If a BadRecordListener object has not been specified
then a default one will be created and stored.
public void prepare(RecordSpec pRecordSpec)
RecordSpec object.
The output XML is defined by the RecordSpec according to a set of simple rules.
For more information, see the RecordProvider documentation.
pRecordSpec - RecordSpec objectRecordSpec,
RecordProviderpublic String[] getFieldNames()
RecordSpec - may be null.
public void saveFile(File pXmlFile)
pXmlFile - XML file to savepublic void saveOutputStream(OutputStream pXmlOutputStream)
OutputStream.
pXmlOutputStream - OutputStream to receive XMLpublic void write()
public void startWrite()
public void endWrite(boolean pThrowClose)
public void writeRecord(String[] pValues)
pValues - record data field valuespublic OutNode findStartNode()
If a node that is an ancestor of the record node has a change, then start from that node, otherwise start from the record node.
public OutNode createNodeTree(List pOutPathList)
This method expects the OutPaths in the list to be ordered as follows:
pOutPathList - list of output paths in correct orderpublic void makeChangeLists(OutNode pSourceNode)
pSourceNode - resolve against ancestors of source node
public void findChanges(OutNode pNode,
OutNode pSubNode,
OutNode pIgnoreNode)
When a record field changes, then that node has to be restarted, by reversing back up to the last node that is affected by the change, and outputting new start elements for all the child nodes.
pNode - node to store changes inpSubNode - node to start child node recursion frompIgnoreNode - child node to ignorepublic OutNode findRoot()
public OutNode findRoot(OutNode pOutNode)
pOutNode - node to start root search from
public OutNode findSubNode(OutNode pFind,
String pName)
pFind - node to search frompName - name of subnode to find
public void traverse(OutNode pStartNode,
boolean pNoRecord)
Follows all node children, down and up tree, until record, start or root node end element is reached.
Because we normally have to end on record end tag, we output the record end tag, but not the record start tag - as the record is the start node.
pStartNode - node to start traversal atpNoRecord - do not output record node or below
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||