|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lowagie.text.DocWriter
com.lowagie.text.xml.XmlWriter
public class XmlWriter
A DocWriter
class for XML (Remark: this class is not finished yet!).
An XmlWriter
can be added as a DocListener
to a certain Document
by getting an instance.
Every Element
added to the original Document
will be written to the OutputStream
of this XmlWriter
.
Example:
// creation of the document with a certain size and certain margins Document document = new Document(PageSize.A4, 50, 50, 50, 50); try { // this will write XML to the Standard OutputStream XmlWriter.getInstance(document, System.out); // this will write XML to a file called text.html XmlWriter.getInstance(document, new FileOutputStream("text.xml")); // this will write XML to for instance the OutputStream of a HttpServletResponse-object XmlWriter.getInstance(document, response.getOutputStream()); } catch(DocumentException de) { System.err.println(de.getMessage()); } // this will close the document and all the OutputStreams listening to it document.close();
Field Summary | |
---|---|
static byte[] |
DOCTYPE
This is the reference to the DTD. |
static byte[] |
DTD
This is the place where the DTD is located. |
static byte[] |
PROLOG
This is the first line of the XML page. |
Fields inherited from class com.lowagie.text.DocWriter |
---|
closeStream, document, EQUALS, FORWARD, GT, LT, NEWLINE, open, os, pageSize, pause, QUOTE, SPACE, TAB |
Constructor Summary | |
---|---|
protected |
XmlWriter(Document doc,
OutputStream os)
Constructs an XmlWriter . |
protected |
XmlWriter(Document doc,
OutputStream os,
String dtd)
Constructs an XmlWriter . |
Method Summary | |
---|---|
boolean |
add(Element element)
Signals that an Element was added to the Document . |
void |
close()
Signals that the Document was closed and that no other
Elements will be added. |
static XmlWriter |
getInstance(Document document,
OutputStream os)
Gets an instance of the XmlWriter . |
static XmlWriter |
getInstance(Document document,
OutputStream os,
String dtd)
Gets an instance of the XmlWriter . |
boolean |
newPage()
Signals that an new page has to be LTed. |
void |
open()
Signals that the Document has been opened and that
Elements can be added. |
Methods inherited from class com.lowagie.text.DocWriter |
---|
add, addTabs, clearTextWrap, flush, getISOBytes, hasMarkupAttributes, isCloseStream, pause, removeWatermark, resetFooter, resetHeader, resetPageCount, resume, setCloseStream, setFooter, setHeader, setMarginMirroring, setMargins, setPageCount, setPageSize, write, write, writeEnd, writeEnd, writeMarkupAttributes, writeStart |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.lowagie.text.DocListener |
---|
add, clearTextWrap, removeWatermark, resetFooter, resetHeader, resetPageCount, setFooter, setHeader, setMarginMirroring, setMargins, setPageCount, setPageSize |
Field Detail |
---|
public static final byte[] PROLOG
public static final byte[] DOCTYPE
public static final byte[] DTD
Constructor Detail |
---|
protected XmlWriter(Document doc, OutputStream os)
XmlWriter
.
doc
- The Document
that has to be written as XMLos
- The OutputStream
the writer has to write to.protected XmlWriter(Document doc, OutputStream os, String dtd)
XmlWriter
.
doc
- The Document
that has to be written as XMLos
- The OutputStream
the writer has to write to.dtd
- The DTD to useMethod Detail |
---|
public static XmlWriter getInstance(Document document, OutputStream os)
XmlWriter
.
document
- The Document
that has to be writtenos
- The OutputStream
the writer has to write to.
XmlWriter
public static XmlWriter getInstance(Document document, OutputStream os, String dtd)
XmlWriter
.
document
- The Document
that has to be writtenos
- The OutputStream
the writer has to write to.dtd
- The DTD to use
XmlWriter
public boolean add(Element element) throws DocumentException
Element
was added to the Document
.
add
in interface ElementListener
add
in class DocWriter
element
- A high level object that will be added to the XML
true
if the element was added, false
if not.
DocumentException
- when a document isn't open yet, or has been closedpublic void open()
Document
has been opened and that
Elements
can be added.
open
in interface DocListener
open
in class DocWriter
public boolean newPage() throws DocumentException
newPage
in interface DocListener
newPage
in class DocWriter
true
if the page was added, false
if not.
DocumentException
- when a document isn't open yet, or has been closedpublic void close()
Document
was closed and that no other
Elements
will be added.
close
in interface DocListener
close
in class DocWriter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |