| java.lang.Object org.cougaar.lib.aggagent.util.InverseSax
InverseSax | public class InverseSax (Code) | | InverseSax is a class that acts as the reverse of a SAX parser. In other
words, it creates the text of an XML document by accepting notification
of parts of the XML structure through method calls. Those parts include
opening and closing tags, attributes, and text. In the attributes and
text, encoding of special characters is handled automatically.
|
Method Summary | |
public void | addAttribute(String name, String value) Add an attribute to the current XML element. | public void | addElement(String tag) Add a new element to the document. | public void | addEltAtt(String tag, String att, String val) Convenience method for adding an element with a single attribute and
no content. | public void | addEltAttText(String tag, String att, String val, String text) Convenience method for adding an element with a single attribute and
text for content. | public void | addText(String text) Add text content to the current XML element. | public void | addTextElement(String tag, String text) Convenience method for adding an element with text but no attributes or
child elements. | public void | endDocument() This method probably shouldn't be used under normal conditions. | public void | endElement() Close the current element. | public static void | main(String[] argv) | public void | reset() Return this XML document generator to its pristine state, abandoning any
work previously in progress. | public void | setLenientMode(boolean b) Set the lenient mode on or off. | public void | setPrettyPrintMode(boolean b) | public String | toString() Return the text of the XML document. |
addAttribute | public void addAttribute(String name, String value)(Code) | | Add an attribute to the current XML element. This method is only valid
after creating an element and before adding other contents, such as text
or child elements. Use of this method at any other time will raise an
IllegalStateException. Special characters within the attribute value are
automatically replaced with the appropriate character entities. This
method also verifies that the tag name is valid (see above).
|
addElement | public void addElement(String tag)(Code) | | Add a new element to the document. This can be the document root or a
child of another element. After the root element has been closed, no
more elements may be added, and attempting to do so will result in an
IllegalStateException. This method also verifies that the tag name is
valid (see above).
|
addEltAtt | public void addEltAtt(String tag, String att, String val)(Code) | | Convenience method for adding an element with a single attribute and
no content.
|
addEltAttText | public void addEltAttText(String tag, String att, String val, String text)(Code) | | Convenience method for adding an element with a single attribute and
text for content. Specify null for no content.
|
addText | public void addText(String text)(Code) | | Add text content to the current XML element. This method is valid any
time after the root element is opened but before it is closed. This
method may be called multiple times within a single element, but the
effect is the same as calling it once with the concatenation of the text
of the many calls (in the same order).
|
addTextElement | public void addTextElement(String tag, String text)(Code) | | Convenience method for adding an element with text but no attributes or
child elements.
|
endDocument | public void endDocument()(Code) | | This method probably shouldn't be used under normal conditions. However,
in case an error or some other unexpected condition is encountered while
creating the XML document, this method can be used to end the document
gracefully. Following any call to this method, toString() is guaranteed
to return either the text of a well-formed XML document or the empty
String (and the latter only if no elements were added).
After this method is called, no more content may be added, even if the
document is empty.
|
endElement | public void endElement()(Code) | | Close the current element. Every tag must be closed explicitly by a
call to this method (or endDocument, which calls this method).
|
reset | public void reset()(Code) | | Return this XML document generator to its pristine state, abandoning any
work previously in progress.
|
setLenientMode | public void setLenientMode(boolean b)(Code) | | Set the lenient mode on or off. In lenient mode, the tag and attribute
names are not checked for invalid characters. This class accepts only
the Latin alphabet (upper- and lower-case) as letters and {0, 1, ..., 9}
as digits, and it does not allow the colon (used in XML namespaces).
There are many other sets of letters, digits, and punctuation characters
in the UNICODE spec that are allowed by standard XML. To use these
characters or XML namespaces, lenient mode must be turned on.
Use at your own risk.
|
setPrettyPrintMode | public void setPrettyPrintMode(boolean b)(Code) | | turn pretty-printing on or off
|
toString | public String toString()(Code) | | Return the text of the XML document.
|
|
|