public class XMLShredder extends Object implements Callable<Void>
XMLStreamReader
to a INodeWriteTrx
. The content of the
stream is added as a subtree.
Based on an enum which identifies the point of insertion, the subtree is
either added as first child or as right sibling.Modifier and Type | Field and Description |
---|---|
protected EShredderInsert |
mFirstChildAppend
Append as first child or not.
|
protected XMLEventReader |
mReader
|
protected INodeWriteTrx |
mWtx
INodeWriteTrx -reference |
Constructor and Description |
---|
XMLShredder(INodeWriteTrx paramWtx,
XMLEventReader paramReader,
EShredderInsert paramAddAsFirstChild)
Normal constructor to invoke a shredding process on a existing
INodeWriteTrx . |
XMLShredder(INodeWriteTrx paramWtx,
XMLEventReader paramReader,
EShredderInsert paramAddAsFirstChild,
EShredderCommit paramCommit)
Normal constructor to invoke a shredding process on a existing
INodeWriteTrx . |
Modifier and Type | Method and Description |
---|---|
protected Stack<Long> |
addNewElement(Stack<Long> paramLeftSiblingKeyStack,
StartElement paramEvent)
Add a new element node.
|
protected Stack<Long> |
addNewText(Stack<Long> paramLeftSiblingKeyStack,
String paramText)
Add a new text node.
|
Void |
call()
Invoking the shredder.
|
static XMLEventReader |
createFileReader(File paramFile)
Create a new StAX reader on a file.
|
static XMLEventReader |
createListReader(List<XMLEvent> paramEvents)
Create a new StAX reader based on a List of
XMLEvent s. |
static XMLEventReader |
createStringReader(String paramString)
Create a new StAX reader on a string.
|
CountDownLatch |
getLatch()
Get latch.
|
protected void |
insertNewContent()
Insert new content based on a StAX parser
XMLStreamReader . |
static void |
main(String... paramArgs)
Main method.
|
protected final transient INodeWriteTrx mWtx
INodeWriteTrx
-referenceprotected transient XMLEventReader mReader
protected transient EShredderInsert mFirstChildAppend
public XMLShredder(INodeWriteTrx paramWtx, XMLEventReader paramReader, EShredderInsert paramAddAsFirstChild) throws TTException
INodeWriteTrx
.paramWtx
- where the new XML Fragment should be placedparamReader
- of the XML FragmentparamAddAsFirstChild
- if the insert is occuring on a node in an existing tree. false
is not possible
when wtx is on root node.TTUsageException
- if insertasfirstChild && updateOnly is both true OR if wtx is
not pointing to doc-root and updateOnly= trueTTException
public XMLShredder(INodeWriteTrx paramWtx, XMLEventReader paramReader, EShredderInsert paramAddAsFirstChild, EShredderCommit paramCommit) throws TTException
INodeWriteTrx
.paramWtx
- INodeWriteTrx
where the new XML Fragment should be
placedparamReader
- XMLEventReader
to parse the xml fragment, which should
be insertedparamAddAsFirstChild
- determines if the insert is occuring on a node in an existing
tree. false
is not possible when wtx is on root
nodeparamCommit
- determines if inserted nodes should be commited right
afterwardsTTUsageException
- if insertasfirstChild && updateOnly is both true OR if wtx is
not pointing to doc-root and updateOnly= trueTTException
public Void call() throws TTException
call
in interface Callable<Void>
TTException
- if any kind of Treetank exception which has occuredprotected final void insertNewContent() throws TTException
XMLStreamReader
.TTException
- if something went wrong while insertingprotected final Stack<Long> addNewElement(Stack<Long> paramLeftSiblingKeyStack, StartElement paramEvent) throws TTException
paramLeftSiblingKeyStack
- stack used to determine if the new element has to be inserted
as a right sibling or as a new child (in the latter case is
NULL on top of the stack)paramEvent
- the current event from the StAX parserTTException
- if adding ElementNode
failsprotected final Stack<Long> addNewText(Stack<Long> paramLeftSiblingKeyStack, String paramText) throws TTException
paramLeftSiblingKeyStack
- stack used to determine if the new element has to be inserted
as a right sibling or as a new child (in the latter case is
NULL on top of the stack)paramText
- the text string to addTTException
- if adding text failspublic static void main(String... paramArgs) throws Exception
paramArgs
- input and output filesException
- if any exception occurspublic static XMLEventReader createFileReader(File paramFile) throws IOException, XMLStreamException
paramFile
- the XML file to parseXMLEventReader
IOException
- if I/O operation failsXMLStreamException
- if any parsing error occurspublic static XMLEventReader createStringReader(String paramString) throws IOException, XMLStreamException
paramString
- the XML file as a string to parseXMLEventReader
IOException
- if I/O operation failsXMLStreamException
- if any parsing error occurspublic static XMLEventReader createListReader(List<XMLEvent> paramEvents) throws IOException, XMLStreamException
XMLEvent
s.paramEvents
- XMLEvent
sXMLEventReader
IOException
- if I/O operation failsXMLStreamException
- if any parsing error occurspublic final CountDownLatch getLatch()
CountDownLatch
referenceCopyright © 2013. All Rights Reserved.