|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.mguennewig.pobjimport.XmlWriter
public class XmlWriter
Simple class to generate an XML file on the fly.
| Constructor Summary | |
|---|---|
XmlWriter(java.io.PrintWriter out)
Creates a new XML writer with mixed content for all elements. |
|
XmlWriter(java.io.PrintWriter out,
java.lang.String[] elementContent)
Creates a new XML writer with element-only content for the specified elements. |
|
| Method Summary | |
|---|---|
void |
addProlog(java.lang.String encoding,
boolean standalone,
java.lang.String doctypeDecl)
Adds the XML prolog to the stream. |
void |
addProlog(java.lang.String encoding,
boolean standalone,
java.lang.String publicId,
java.lang.String systemId)
Adds the XML prolog to the stream. |
void |
attr(java.lang.String name,
java.lang.String value)
Adds attribute name to the current open element. |
void |
cdata(java.io.InputStream in)
Generates a CDATA section from the given stream. |
void |
cdata(java.io.Reader reader)
Generates a CDATA section from the given reader. |
void |
cdata(java.lang.String cdata)
Generates a CDATA section. |
void |
close()
Closes the XML writer and the print writer. |
void |
comment(java.lang.String comment)
Generates a COMMENT section. |
void |
end()
Closes the current open tag. |
void |
end(java.lang.String tagName)
Closes the current open tag tagName. |
java.io.PrintWriter |
getPrintWriter()
Returns the used print writer. |
boolean |
isElementContent(java.lang.String name)
Tests whether the tag name uses the element-only model. |
void |
newLine()
Adds a new line into the XML document. |
void |
start(java.lang.String tagName)
Opens a tag tagName. |
void |
start(java.lang.String tagName,
boolean elementContent)
Opens a tag tagName with specified mixed content mode. |
void |
text(java.lang.String text)
Writes text data to the current open element. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XmlWriter(java.io.PrintWriter out)
public XmlWriter(java.io.PrintWriter out,
java.lang.String[] elementContent)
| Method Detail |
|---|
public void addProlog(java.lang.String encoding,
boolean standalone,
java.lang.String publicId,
java.lang.String systemId)
NOTE: This method must only be called once and before every any other data is written.
encoding - the encoding used for the XML file. This does not
change the used encoding, but only states it for others.standalone - iff true no external entities are usedpublicId - optional PUBLIC identifiersystemId - optional SYSTEM identifier. THis is mandatory if a PUBLIC
identifier is givenaddProlog(String,boolean,String)
public void addProlog(java.lang.String encoding,
boolean standalone,
java.lang.String doctypeDecl)
NOTE: This method must only be called once and before every any other data is written.
encoding - states the encoding used for the XML file.
This does not change the used encoding, but only states it for
others.standalone - iff true no external entities are useddoctypeDecl - optional DOCTYPE declarationpublic void close()
public final java.io.PrintWriter getPrintWriter()
public boolean isElementContent(java.lang.String name)
name uses the element-only model.
XmlWriter(PrintWriter,String[])
public final void start(java.lang.String tagName,
boolean elementContent)
tagName with specified mixed content mode.
tagName - the tag name that should be openedelementContent - iff true this tag uses the element-only
model and indentation will be done, otherwise mixed content is assumed.public final void start(java.lang.String tagName)
tagName.
start(String,boolean),
isElementContent(String)
public final void attr(java.lang.String name,
java.lang.String value)
name to the current open element.
java.lang.IllegalStateException - if already content has been added to the
current element, like text or sub-elements.public final void end()
java.lang.IllegalStateException - if no open tag exists.public final void end(java.lang.String tagName)
tagName.
java.lang.IllegalStateException - if no open tag exists or is not
tagNameend()public final void newLine()
public final void text(java.lang.String text)
public final void cdata(java.lang.String cdata)
java.lang.IllegalArgumentException - if cdata is
null or contains ]]>.
public final void cdata(java.io.Reader reader)
throws java.io.IOException
NOTE: The stream is not checked for the forbidden character
sequence ]]>.
java.io.IOException - if an IO error occurs
public final void cdata(java.io.InputStream in)
throws java.io.IOException
The data is encoded in hex which doubles the required size.
java.io.IOException - if an IO error occurspublic final void comment(java.lang.String comment)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||