|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.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, or insert new content anywhere in the document 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(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 |
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(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(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 |
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 contentOffset,
int contentLen)
Update token with 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 |
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()
public void insertAfterElement(byte[] b) throws ModifyException, java.io.UnsupportedEncodingException, NavException
b
- the byte array to be inserted into the master document
ModifyException
java.io.UnsupportedEncodingException
NavException
public void insertAfterElement(byte[] b, int contentOffset, int contentLen) throws ModifyException, java.io.UnsupportedEncodingException, NavException
b
- contentOffset
- contentLen
-
ModifyException
java.io.UnsupportedEncodingException
NavException
public void insertAfterElement(byte[] b, long l1) throws ModifyException, java.io.UnsupportedEncodingException, NavException
b
- contentOffset
- contentLen
-
ModifyException
java.io.UnsupportedEncodingException
NavException
public void insertAfterElement(ElementFragmentNs ef) throws ModifyException, NavException
ef
- (an ElementFragmentNs object)
ModifyException
NavException
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 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(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(java.lang.String s) throws ModifyException, java.io.UnsupportedEncodingException
s
-
ModifyException
java.io.UnsupportedEncodingException
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
os
-
java.io.IOException
ModifyException
public void output(java.lang.String fileName) throws java.io.IOException, ModifyException
fileName
-
java.io.IOException
ModifyException
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 contentOffset, int contentLen) throws ModifyException, java.io.UnsupportedEncodingException
index
- newContentBytes
- contentOffset
- contentLen
-
ModifyException
java.io.UnsupportedEncodingException
public void updateToken(int index, java.lang.String newContent) throws ModifyException, java.io.UnsupportedEncodingException
index
- newContent
-
ModifyException
java.io.UnsupportedEncodingException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |