|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcds.xml.XmlGen
XmlGen : XML generation class This class has basic methods to generate XML formatted data. The class builds the XML stream in a buffer, and outputs it to an OutputStream object. It is possible to flush() the buffer out, allowing to deal with huge data sets. Flushing is independant of having closed the tags. The class keeps track of the opened tags, and is able to close them automatically, depending on the action performed. Most of the methods returns the XmlGen object itself, allowing for 'concatenating' calls : xmlgen.openTag("VOTABLE").addAttr("name","hd 1"); You can choose to indent or not the output. Indentation increases the size of the output, but makes it more readable.
Field Summary | |
private static boolean |
indentlines
|
private static int |
level
|
private static java.lang.String |
mainTag
|
private static char[] |
spaces
|
private static ArrayListStack |
tagdefstack
|
private static java.io.BufferedWriter |
wrt
|
private static java.lang.StringBuffer |
xmldata
|
Constructor Summary | |
XmlGen(java.io.OutputStream os)
Constructor. |
Method Summary | |
XmlGen |
addAttr(Attrib[] attlist)
Adds a list of attributes to the previously defined tag. |
XmlGen |
addAttr(java.lang.String name,
java.lang.String value)
Adds an attribute to the previously defined tag. |
XmlGen |
addID(java.lang.String id)
Adds an ID as attribute to the previously defined tag. |
XmlGen |
addText(java.lang.String t)
Adds text to the XML file This will add the closing character ('>') if a tag was stillopened to receive Attributes. |
XmlGen |
addText(java.lang.String t,
boolean conv)
Adds text to the XML file |
void |
close()
close : definitely closes the XML file after having closed all the tags and flushed the buffer. |
XmlGen |
closeAllTags()
Closes all remaining opened tags As an XML file must be embedded in one main tag, and as this method closes ALL tags, including the main one, this method can be called only once during an XML file creation, and at its end ! |
XmlGen |
closeTag()
Closes the current tag , without having to name it |
XmlGen |
closeTag(java.lang.String n)
Closes the opened tags with their endtag mark () until finding a tag with the same name as the one specified If several tags with the name name are opened, the process will stop after having encountered the first one. |
XmlGen |
doctype(java.lang.String maintag,
java.lang.String dtd)
Generates the DOCTYPE tag. |
XmlGen |
flush()
Empties the current XML buffer. |
java.lang.String |
getCurrentTagName()
Gets the current tag name |
void |
indent(boolean indent)
True or false if you wish or not to indent lines indentation is kept to 1 space / level |
private int |
indentVal(int level)
|
XmlGen |
openTag(java.lang.String name)
Opens a new tag. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static boolean indentlines
private static java.lang.String mainTag
private static ArrayListStack tagdefstack
private static java.lang.StringBuffer xmldata
private static char[] spaces
private static int level
private static java.io.BufferedWriter wrt
Constructor Detail |
public XmlGen(java.io.OutputStream os)
os
- OutputStream objectMethod Detail |
private final int indentVal(int level)
public XmlGen doctype(java.lang.String maintag, java.lang.String dtd)
maintag
- Main tag for the XML filedtd
- URL of the corresponding DTD
public void indent(boolean indent)
indent
- true or falsepublic XmlGen openTag(java.lang.String name)
name
- Name of the tag
public XmlGen addAttr(java.lang.String name, java.lang.String value)
name
- name of the attributevalue
- value of the attribute
public XmlGen addID(java.lang.String id)
id
- ID value
public XmlGen addAttr(Attrib[] attlist)
attlist
- array of Attrib objects
Attrib
public XmlGen addText(java.lang.String t)
t
- Text do add. Conversions ('&' into & will occur)
public XmlGen addText(java.lang.String t, boolean conv)
t
- Text do addconv
- true if conversion of special character should be done
public java.lang.String getCurrentTagName()
public XmlGen closeTag(java.lang.String n)
n
- Name of the last tag to close
public XmlGen closeTag()
public XmlGen closeAllTags()
public XmlGen flush()
close()
public void close()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |