public class XMLModifier
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
XMLModifier.ByteSegment |
Modifier and Type | Field and Description |
---|---|
static short |
SEGMENT_OP_EXCLUDE_STRICT |
static short |
SEGMENT_OP_INTERSECT_STRICT |
static short |
SEGMENT_OP_UNION_STRICT |
Constructor and Description |
---|
XMLModifier()
Argument-less constructor for XMLModifier,
needs to call bind to attach the master document to an instance
of XMLModifier
|
XMLModifier(VTDNav masterDocument)
Constructor for XMLModifier that takes VTDNav object as the master document
|
Modifier and Type | Method and Description |
---|---|
void |
bind(VTDNav masterDocument)
Attach master document to this instance of XMLModifier
so all the operations occuring aftewards are based on this instance
of VTDNav
|
int |
getUpdatedDocumentSize()
Compute the size of the updated XML document without composing it
|
void |
insertAfterElement(byte[] b)
This method will first call getCurrentIndex() to get the cursor index value
then insert the byte array b after the element
|
void |
insertAfterElement(byte[] b,
int contentOffset,
int contentLen)
This method will first call getCurrentIndex() to get the cursor index value
then insert a segment of the byte array b after the element
|
void |
insertAfterElement(byte[] b,
long l1)
This method will first call getCurrentIndex() to get the cursor index value
then insert a segment of the byte array b after the element,
l1 (a long)'s upper 32 bit is length, lower 32 bit is offset
|
void |
insertAfterElement(ElementFragmentNs ef)
Insert a namespace compensated element after cursor element
|
void |
insertAfterElement(int src_encoding,
byte[] b)
Insert a byte array of given encoding into the master document
transcoding is done underneath to ensure the correctness of output
|
void |
insertAfterElement(int src_encoding,
byte[] b,
int contentOffset,
int contentLen)
This method will first call getCurrentIndex() to get the cursor index value
then insert the transcoded array of bytes of a segment of the byte array b after the element
|
void |
insertAfterElement(int src_encoding,
byte[] b,
long l1)
This method will first call getCurrentIndex() to get the cursor index value
then insert a segment of the byte array b (transcode into a byte array) after the element,
l1 (a long)'s upper 32 bit is length, lower 32 bit is offset
|
void |
insertAfterElement(java.lang.String s)
This method will first call getCurrentIndex() to get the cursor index value
then insert the byte value of s after the element
|
void |
insertAfterElement(VTDNav vn,
int contentOffset,
int contentLen)
This method will first call getCurrentIndex() to get the cursor index value
then insert the transcoded array of bytes of a segment of the byte array b after the element
the VTDNav object is the container of the XML document in byte array
|
void |
insertAfterElement(VTDNav vn,
long l1)
This method will first call getCurrentIndex() to get the cursor index value
then insert a segment of the byte array b (contained in vn, and
transcode into a byte array) after the element,
l1 (a long)'s upper 32 bit is length, lower 32 bit is offset
|
void |
insertAfterHead(byte[] b)
This method will insert byte array b after the head of cursor element,
|
void |
insertAfterHead(byte[] b,
int offset,
int len)
This method will insert a segment of the byte array b after the head of cursor element,
|
void |
insertAfterHead(byte[] b,
long l)
This method will insert a segment of the byte array b after the head of cursor element
|
void |
insertAfterHead(ElementFragmentNs ef)
This method will insert an ElementFragmentNs instance
after the head of cursor element,
|
void |
insertAfterHead(int src_encoding,
byte[] b)
This method will insert the transcoded representation of
byte array b after the head of cursor element,
|
void |
insertAfterHead(int src_encoding,
byte[] b,
int offset,
int length)
This method will insert the transcoded representation of
a segment of the byte array b after the head of cursor element,
|
void |
insertAfterHead(int src_encoding,
byte[] b,
long l)
This method will insert the transcoded representation of
a segment of the byte array b after the head of cursor element,
|
void |
insertAfterHead(java.lang.String s)
This method will insert s' byte array representation
of the string after the head of cursor element,
|
void |
insertAfterHead(VTDNav vn,
int contentOffset,
int contentLen)
This method will insert a segment of the byte array b (contained in vn, and
transcode into a byte array) after the head of cursor element,
|
void |
insertAfterHead(VTDNav vn,
long l1)
This method will insert a segment of the byte array b (contained in vn, and
transcode into a byte array) after the head of cursor element,
|
void |
insertAttribute(byte[] b)
Insert a byte arry of an attribute after the starting tag
This method will first call getCurrentIndex() to get the cursor index value
if the index is of type "starting tag", then teh attribute is inserted
after the starting tag
|
void |
insertAttribute(int src_encoding,
byte[] b)
Insert the transcoded representation of a byte arry of an attribute
after the starting tag This method will first call getCurrentIndex()
to get the cursor index value if the index is of type "starting tag",
then teh attribute is inserted after the starting tag
|
void |
insertAttribute(java.lang.String attr)
Insert an attribute after the starting tag
This method will first call getCurrentIndex() to get the cursor index value
if the index is of type "starting tag", then the attribute is inserted
after the starting tag
|
void |
insertBeforeElement(byte[] b)
This method will first call getCurrentIndex() to get the cursor index value
then insert the byte array b before the element
|
void |
insertBeforeElement(byte[] b,
int contentOffset,
int contentLen)
This method will first call getCurrentIndex() to get the cursor index value
then insert a segment of the byte array b before the element
|
void |
insertBeforeElement(byte[] b,
long l1)
This method will first call getCurrentIndex() to get the cursor index value
then insert a segment of the byte array b before the element
l1 (a long)'s upper 32 bit is length, lower 32 bit is offset
|
void |
insertBeforeElement(ElementFragmentNs ef)
Insert a namespace compensated fragment before the cursor element
|
void |
insertBeforeElement(int src_encoding,
byte[] b)
This method will first call getCurrentIndex() to get the cursor index value
then insert the transcoded representatin of the byte array b before the element
|
void |
insertBeforeElement(int src_encoding,
byte[] b,
int contentOffset,
int contentLen)
This method will first call getCurrentIndex() to get the cursor index value
then insert the transcoded representation of a segment of the byte array b
before the element
|
void |
insertBeforeElement(int src_encoding,
byte[] b,
long l1)
This method will first call getCurrentIndex() to get the cursor index value
then insert the transcoded representation of a segment of the byte array b before the element
l1 (a long)'s upper 32 bit is length, lower 32 bit is offset
|
void |
insertBeforeElement(java.lang.String s)
This method will first call getCurrentIndex() to get the cursor index value
then insert the byte value of s before the element
|
void |
insertBeforeElement(VTDNav vn,
int contentOffset,
int contentLen)
This method will first call getCurrentIndex() to get the cursor index value
then insert the transcoded representation of a segment of the byte array contained
in vn before the element
|
void |
insertBeforeElement(VTDNav vn,
long l)
This method will first call getCurrentIndex() to get the cursor index value
then insert the transcoded representation of a segment of the byte array contained in
vn before the element
l1 (a long)'s upper 32 bit is length, lower 32 bit is offset
|
void |
insertBeforeTail(byte[] b)
This method will insert byte array b right before the tail of cursor element,
|
void |
insertBeforeTail(byte[] b,
int offset,
int len)
This method will insert a segment of the byte array before the tail of cursor element,
|
void |
insertBeforeTail(byte[] b,
long l)
This method will insert a segment of the byte array before the tail of cursor element,
l1 (a long)'s upper 32 bit is length, lower 32 bit is offset
|
void |
insertBeforeTail(ElementFragmentNs ef)
This method will insert a namespace compensated fragment before the tail of cursor element,
|
void |
insertBeforeTail(int src_encoding,
byte[] b)
This method will insert the transcoded representation of byte array b right before the tail of cursor element,
|
void |
insertBeforeTail(int src_encoding,
byte[] b,
int offset,
int length)
This method will insert the transcoded representation of a segment of byte array b right before the tail of cursor element,
|
void |
insertBeforeTail(int src_encoding,
byte[] b,
long l)
This method will insert the transcoded representation of a segment of the byte array before the tail of cursor element,
l1 (a long)'s upper 32 bit is length, lower 32 bit is offset
|
void |
insertBeforeTail(java.lang.String s)
This method will insert byte content of string right before the tail of cursor element,
|
void |
insertBeforeTail(VTDNav vn,
int contentOffset,
int contentLen)
This method will insert a segment of the byte array (contained in vn, and
transcode into a byte array) before the tail of cursor element,
|
void |
insertBeforeTail(VTDNav vn,
long l1)
This method will insert a segment of the byte array (contained in vn, and
transcode into a byte array) before the tail of cursor element,
l1 (a long)'s upper 32 bit is length, lower 32 bit is offset
|
void |
insertBytesAt(int offset,
byte[] content)
insert the byte content into XML
|
void |
insertBytesAt(int offset,
byte[] content,
int contentOffset,
int contentLen)
Insert a segment of the byte content into XML
|
void |
output(java.io.OutputStream os)
This method applies the modification to the XML document
and writes the output byte content accordingly to an outputStream
Notice that output is not guaranteed to be well-formed
|
void |
output(java.lang.String fileName)
Generate the updated output XML document and write it into
a file of given name
|
VTDNav |
outputAndReparse()
outAndReparse writes updated XML content into a new byte
array, then parse and return a new VTDNav object
|
void |
remove()
Removes content from the master XML document
It first calls getCurrentIndex() if the result is
a starting tag, then the entire element referred to
by the starting tag is removed
If the result is an attribute name or ns node, then
the corresponding attribute name/value pair is removed
If the token type is one of text, CDATA or commment,
then the entire node, including the starting and ending
delimiting text surrounding the content, is removed
|
void |
remove(long l)
Remove a byte segment from XML.
|
void |
remove(long l1,
long l2,
short actionType)
Available since 2.13
Remove a byte segment from XML, the byte segment is the result of performing an operation
on two overlapping segments.
|
void |
removeAttribute(int attrNameIndex)
Remove an attribute name value pair from the master document.
|
void |
removeContent(int offset,
int len)
Remove a segment of byte content from master XML doc.
|
void |
removeToken(int i)
Remove the token content.
|
void |
reset()
This method resets the internal state of XMLModify instance so
it can be reused
|
void |
updateElementName(java.lang.String newElementName)
Replace the cursor element's name with a new name
|
void |
updateToken(int index,
byte[] newContentBytes)
Update the token with the given byte array content,
|
void |
updateToken(int index,
byte[] newContentBytes,
int src_encoding)
Update the token with the transcoded representation of
given byte array content,
|
void |
updateToken(int index,
byte[] newContentBytes,
int contentOffset,
int contentLen)
Update token with a segment of byte array (in terms of offset and length)
|
void |
updateToken(int index,
byte[] newContentBytes,
int contentOffset,
int contentLen,
int src_encoding)
Update token with the transcoded representation of
a segment of byte array (in terms of offset and length)
|
void |
updateToken(int index,
java.lang.String newContent)
Update the token with the given string value,
notice that string will be converted into byte array
according to the encoding of the master document
|
void |
updateToken(int index,
VTDNav vn,
int contentOffset,
int contentLen)
Update token with the transcoded representation of
a segment of byte array contained in vn (in terms of offset and length)
|
public static final short SEGMENT_OP_EXCLUDE_STRICT
public static final short SEGMENT_OP_INTERSECT_STRICT
public static final short SEGMENT_OP_UNION_STRICT
public XMLModifier()
public XMLModifier(VTDNav masterDocument) throws ModifyException
masterDocument
- is the document on which the modification is appliedModifyException
public void bind(VTDNav masterDocument) throws ModifyException
masterDocument
- ModifyException
public int getUpdatedDocumentSize() throws ModifyException, TranscodeException
ModifyException
TranscodeException
public void insertAfterElement(byte[] b) throws ModifyException, NavException
b
- ModifyException
NavException
public void insertAfterElement(byte[] b, int contentOffset, int contentLen) throws ModifyException, NavException
b
- contentOffset
- contentLen
- ModifyException
NavException
public void insertAfterElement(byte[] b, long l1) throws ModifyException, NavException
b
- contentOffset
- contentLen
- ModifyException
NavException
public void insertAfterElement(ElementFragmentNs ef) throws ModifyException, NavException
ef
- (an ElementFragmentNs object)ModifyException
NavException
public void insertAfterElement(int src_encoding, byte[] b) throws ModifyException, NavException, TranscodeException
encoding
- The encoding format of the byte arrayb
- ModifyException
NavException
TranscodeException
public void insertAfterElement(int src_encoding, byte[] b, int contentOffset, int contentLen) throws ModifyException, NavException, TranscodeException
b
- contentOffset
- contentLen
- ModifyException
NavException
TranscodeException
public void insertAfterElement(int src_encoding, byte[] b, long l1) throws ModifyException, java.io.UnsupportedEncodingException, NavException, TranscodeException
b
- l1
- ModifyException
java.io.UnsupportedEncodingException
NavException
TranscodeException
public void insertAfterElement(java.lang.String s) throws ModifyException, java.io.UnsupportedEncodingException, NavException
s
- the string whose byte content will be inserted into the master documentModifyException
java.io.UnsupportedEncodingException
NavException
public void insertAfterElement(VTDNav vn, int contentOffset, int contentLen) throws ModifyException, java.io.UnsupportedEncodingException, NavException, TranscodeException
vn
- contentOffset
- contentLen
- ModifyException
java.io.UnsupportedEncodingException
NavException
TranscodeException
public void insertAfterElement(VTDNav vn, long l1) throws ModifyException, java.io.UnsupportedEncodingException, NavException, TranscodeException
vn
- l1
- ModifyException
java.io.UnsupportedEncodingException
NavException
TranscodeException
public void insertAfterHead(byte[] b) throws ModifyException, NavException
b
- ModifyException
NavException
public void insertAfterHead(byte[] b, int offset, int len) throws ModifyException, NavException
b
- offset
- len
- ModifyException
NavException
public void insertAfterHead(byte[] b, long l) throws ModifyException, NavException
b
- l
- ModifyException
NavException
public void insertAfterHead(ElementFragmentNs ef) throws ModifyException, NavException
efn
- ModifyException
NavException
public void insertAfterHead(int src_encoding, byte[] b) throws ModifyException, NavException, TranscodeException
src_encoding
- b
- ModifyException
NavException
TranscodeException
public void insertAfterHead(int src_encoding, byte[] b, int offset, int length) throws ModifyException, NavException, TranscodeException
src_encoding
- b
- offset
- length
- ModifyException
NavException
TranscodeException
public void insertAfterHead(int src_encoding, byte[] b, long l) throws ModifyException, NavException, TranscodeException
src_encoding
- b
- l
- ModifyException
NavException
TranscodeException
public void insertAfterHead(java.lang.String s) throws ModifyException, java.io.UnsupportedEncodingException, NavException
s
- ModifyException
NavException
TranscodeException
java.io.UnsupportedEncodingException
public void insertAfterHead(VTDNav vn, int contentOffset, int contentLen) throws ModifyException, NavException, TranscodeException
vn
- contentOffset
- in bytecontentLen
- in byteModifyException
NavException
TranscodeException
public void insertAfterHead(VTDNav vn, long l1) throws ModifyException, NavException, TranscodeException
vn
- l1
- ModifyException
NavException
TranscodeException
public void insertAttribute(byte[] b) throws ModifyException, java.io.UnsupportedEncodingException
b
- the byte content of e.g. " attrName='attrVal' ",notice the starting and ending
white spaceModifyException
java.io.UnsupportedEncodingException
public void insertAttribute(int src_encoding, byte[] b) throws ModifyException, java.io.UnsupportedEncodingException, TranscodeException
b
- the byte content of e.g. " attrName='attrVal' ",notice the
starting and ending white spaceModifyException
java.io.UnsupportedEncodingException
TranscodeException
public void insertAttribute(java.lang.String attr) throws ModifyException, java.io.UnsupportedEncodingException
attr
- e.g. " attrName='attrVal' ",notice the starting and ending
white spaceModifyException
java.io.UnsupportedEncodingException
public void insertBeforeElement(byte[] b) throws ModifyException
b
- the byte array to be inserted into the master documentModifyException
public void insertBeforeElement(byte[] b, int contentOffset, int contentLen) throws ModifyException, java.io.UnsupportedEncodingException
b
- contentOffset
- contentLen
- ModifyException
java.io.UnsupportedEncodingException
public void insertBeforeElement(byte[] b, long l1) throws ModifyException, java.io.UnsupportedEncodingException
b
- l1
- ModifyException
java.io.UnsupportedEncodingException
public void insertBeforeElement(ElementFragmentNs ef) throws ModifyException
ef
- ModifyException
public void insertBeforeElement(int src_encoding, byte[] b) throws ModifyException, TranscodeException
b
- the byte array to be inserted into the master documentModifyException
TranscodeException
public void insertBeforeElement(int src_encoding, byte[] b, int contentOffset, int contentLen) throws ModifyException, java.io.UnsupportedEncodingException, TranscodeException
b
- contentOffset
- contentLen
- ModifyException
java.io.UnsupportedEncodingException
TranscodeException
public void insertBeforeElement(int src_encoding, byte[] b, long l1) throws ModifyException, java.io.UnsupportedEncodingException, TranscodeException
b
- l1
- ModifyException
java.io.UnsupportedEncodingException
TranscodeException
public void insertBeforeElement(java.lang.String s) throws ModifyException, java.io.UnsupportedEncodingException
s
- ModifyException
java.io.UnsupportedEncodingException
public void insertBeforeElement(VTDNav vn, int contentOffset, int contentLen) throws ModifyException, java.io.UnsupportedEncodingException, TranscodeException
vn
- contentOffset
- contentLen
- ModifyException
java.io.UnsupportedEncodingException
TranscodeException
public void insertBeforeElement(VTDNav vn, long l) throws ModifyException, java.io.UnsupportedEncodingException, TranscodeException
vn
- l
- ModifyException
java.io.UnsupportedEncodingException
TranscodeException
public void insertBeforeTail(byte[] b) throws ModifyException, NavException
b
- ModifyException
NavException
public void insertBeforeTail(byte[] b, int offset, int len) throws ModifyException, NavException
b
- offset
- len
- ModifyException
NavException
public void insertBeforeTail(byte[] b, long l) throws ModifyException, NavException
b
- l
- ModifyException
NavException
public void insertBeforeTail(ElementFragmentNs ef) throws ModifyException, NavException
ef
- ModifyException
NavException
public void insertBeforeTail(int src_encoding, byte[] b) throws ModifyException, NavException, TranscodeException
src_encoding
- b
- ModifyException
NavException
TranscodeException
public void insertBeforeTail(int src_encoding, byte[] b, int offset, int length) throws ModifyException, NavException, TranscodeException
src_encoding
- b
- offset
- length
- ModifyException
NavException
TranscodeException
public void insertBeforeTail(int src_encoding, byte[] b, long l) throws ModifyException, NavException, TranscodeException
src_encoding
- b
- l
- ModifyException
NavException
TranscodeException
public void insertBeforeTail(java.lang.String s) throws ModifyException, java.io.UnsupportedEncodingException, NavException
s
- ModifyException
NavException
java.io.UnsupportedEncodingException
public void insertBeforeTail(VTDNav vn, int contentOffset, int contentLen) throws ModifyException, NavException, TranscodeException
vn
- contentOffset
- contentLen
- ModifyException
NavException
TranscodeException
public void insertBeforeTail(VTDNav vn, long l1) throws ModifyException, NavException, TranscodeException
vn
- l1
- ModifyException
NavException
TranscodeException
public void insertBytesAt(int offset, byte[] content) throws ModifyException
offset
- (in char, not byte)content
- ModifyException
public void insertBytesAt(int offset, byte[] content, int contentOffset, int contentLen) throws ModifyException
offset
- content
- contentOffset
- contentLen
- ModifyException
public void output(java.io.OutputStream os) throws java.io.IOException, ModifyException, TranscodeException
os
- java.io.IOException
ModifyException
TranscodeException
public void output(java.lang.String fileName) throws java.io.IOException, ModifyException, TranscodeException
fileName
- java.io.IOException
ModifyException
TranscodeException
public VTDNav outputAndReparse() throws ParseException, java.io.IOException, TranscodeException, ModifyException
ParseException
java.io.IOException
TranscodeException
ModifyException
public void remove() throws NavException, ModifyException
NavException
ModifyException
public void remove(long l) throws NavException, ModifyException
l
- NavException
ModifyException
public void remove(long l1, long l2, short actionType) throws NavException, ModifyException
l1
- l2
- actionType
- SEGMENT_OP_UNION_STRICT remove the segment as union of 2 segments
SEGMENT_OP_INTERSECT_STRICT remove the segment as the intersetion of 2 segments
SEGMENT_OP_EXCLUDE_STRICT remove the segment in l1 excluding the insection of l1 and l2NavException
ModifyException
public void removeAttribute(int attrNameIndex) throws ModifyException
attrNameIndex
- ModifyException
public void removeContent(int offset, int len) throws ModifyException
offset
- len
- ModifyException
public void removeToken(int i) throws ModifyException
i
- the index for the contentModifyException
public void reset()
public void updateElementName(java.lang.String newElementName) throws ModifyException, NavException, java.io.UnsupportedEncodingException
newElementName
- ModifyException
NavException
java.io.UnsupportedEncodingException
public void updateToken(int index, byte[] newContentBytes) throws ModifyException, java.io.UnsupportedEncodingException
index
- newContentBytes
- ModifyException
java.io.UnsupportedEncodingException
public void updateToken(int index, byte[] newContentBytes, int src_encoding) throws ModifyException, java.io.UnsupportedEncodingException, TranscodeException
index
- newContentBytes
- ModifyException
java.io.UnsupportedEncodingException
TranscodeException
public void updateToken(int index, byte[] newContentBytes, int contentOffset, int contentLen) throws ModifyException, java.io.UnsupportedEncodingException
index
- newContentBytes
- contentOffset
- contentLen
- ModifyException
java.io.UnsupportedEncodingException
public void updateToken(int index, byte[] newContentBytes, int contentOffset, int contentLen, int src_encoding) throws ModifyException, java.io.UnsupportedEncodingException, TranscodeException
index
- newContentBytes
- contentOffset
- contentLen
- ModifyException
java.io.UnsupportedEncodingException
TranscodeException
public void updateToken(int index, java.lang.String newContent) throws ModifyException, java.io.UnsupportedEncodingException
index
- newContent
- ModifyException
java.io.UnsupportedEncodingException
public void updateToken(int index, VTDNav vn, int contentOffset, int contentLen) throws ModifyException, java.io.UnsupportedEncodingException, TranscodeException
index
- vn
- contentOffset
- contentLen
- ModifyException
java.io.UnsupportedEncodingException
TranscodeException