|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ximpleware.XMLModifier
public class XMLModifier
XMLModifier offers an easy-to-use interface for users to take advantage of the incremental update of VTD-XML The XML modifier assumes there is a master document on which the modification is applied: users can remove an element, update a token, replace an element name, or insert new content anywhere in the document transcoding methods are built-in The process: * The modification operations are recorded first * The output() is called to generate output document
Nested Class Summary | |
---|---|
class |
XMLModifier.ByteSegment
|
Constructor Summary | |
---|---|
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 |
Method Summary | |
---|---|
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 |
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 |
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 |
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) |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLModifier()
public XMLModifier(VTDNav masterDocument) throws ModifyException
masterDocument
- is the document on which the modification is applied
ModifyException
Method Detail |
---|
public void bind(VTDNav masterDocument) throws ModifyException
masterDocument
-
ModifyException
public int getUpdatedDocumentSize() throws com.ximpleware.TranscodeException
com.ximpleware.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, com.ximpleware.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, com.ximpleware.TranscodeException
b
- contentOffset
- contentLen
-
ModifyException
NavException
TranscodeException
public void insertAfterElement(int src_encoding, byte[] b, long l1) throws ModifyException, java.io.UnsupportedEncodingException, NavException, com.ximpleware.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 document
ModifyException
java.io.UnsupportedEncodingException
NavException
public void insertAfterElement(VTDNav vn, int contentOffset, int contentLen) throws ModifyException, java.io.UnsupportedEncodingException, NavException, com.ximpleware.TranscodeException
vn
- contentOffset
- contentLen
-
ModifyException
java.io.UnsupportedEncodingException
NavException
TranscodeException
public void insertAfterElement(VTDNav vn, long l1) throws ModifyException, java.io.UnsupportedEncodingException, NavException, com.ximpleware.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, com.ximpleware.TranscodeException
src_encoding
- b
-
ModifyException
NavException
TranscodeException
public void insertAfterHead(int src_encoding, byte[] b, int offset, int length) throws ModifyException, NavException, com.ximpleware.TranscodeException
src_encoding
- b
- offset
- length
-
ModifyException
NavException
TranscodeException
public void insertAfterHead(int src_encoding, byte[] b, long l) throws ModifyException, NavException, com.ximpleware.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, com.ximpleware.TranscodeException
vn
- contentOffset
- contentLen
-
ModifyException
NavException
TranscodeException
public void insertAfterHead(VTDNav vn, long l1) throws ModifyException, NavException, com.ximpleware.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 space
ModifyException
java.io.UnsupportedEncodingException
public void insertAttribute(int src_encoding, byte[] b) throws ModifyException, java.io.UnsupportedEncodingException, com.ximpleware.TranscodeException
b
- the byte content of e.g. " attrName='attrVal' ",notice the
starting and ending white space
ModifyException
java.io.UnsupportedEncodingException
com.ximpleware.TranscodeException
public void insertAttribute(java.lang.String attr) throws ModifyException, java.io.UnsupportedEncodingException
attr
- e.g. " attrName='attrVal' ",notice the starting and ending
white space
ModifyException
java.io.UnsupportedEncodingException
public void insertBeforeElement(byte[] b) throws ModifyException
b
- the byte array to be inserted into the master document
ModifyException
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, com.ximpleware.TranscodeException
b
- the byte array to be inserted into the master document
ModifyException
TranscodeException
public void insertBeforeElement(int src_encoding, byte[] b, int contentOffset, int contentLen) throws ModifyException, java.io.UnsupportedEncodingException, com.ximpleware.TranscodeException
b
- contentOffset
- contentLen
-
ModifyException
java.io.UnsupportedEncodingException
TranscodeException
public void insertBeforeElement(int src_encoding, byte[] b, long l1) throws ModifyException, java.io.UnsupportedEncodingException, com.ximpleware.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, com.ximpleware.TranscodeException
vn
- contentOffset
- contentLen
-
ModifyException
java.io.UnsupportedEncodingException
TranscodeException
public void insertBeforeElement(VTDNav vn, long l) throws ModifyException, java.io.UnsupportedEncodingException, com.ximpleware.TranscodeException
vn
- l
-
ModifyException
java.io.UnsupportedEncodingException
TranscodeException
public void insertBytesAt(int offset, byte[] content) throws ModifyException
offset
- 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, com.ximpleware.TranscodeException
os
-
java.io.IOException
ModifyException
com.ximpleware.TranscodeException
public void output(java.lang.String fileName) throws java.io.IOException, ModifyException, com.ximpleware.TranscodeException
fileName
-
java.io.IOException
ModifyException
com.ximpleware.TranscodeException
public void remove() throws NavException, ModifyException
NavException
ModifyException
public void remove(long l) throws NavException, ModifyException
l
-
NavException
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 content
ModifyException
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, com.ximpleware.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, com.ximpleware.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, com.ximpleware.TranscodeException
index
- vn
- contentOffset
- contentLen
-
ModifyException
java.io.UnsupportedEncodingException
TranscodeException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |