|
||||||||||
| 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
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. |
private TreeMap |
itext
This is the meta information of the document. |
static byte[] |
PROLOG
This is the first line of the XML page. |
private static String[] |
xmlCode
This is an array containing character to XML translations. |
| 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. |
(package private) static void |
addTabs(StringBuffer buf,
int indent)
Adds a number of tabs to a StringBuffer. |
void |
close()
Signals that the Document was closed and that no other
Elements will be added. |
(package private) static String |
encode(String string,
int indent)
Encodes a String. |
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. |
private void |
write(Element element,
int indent)
Writes the XML representation of an element. |
private void |
write(Font font)
Writes the XML representation of a Font. |
private void |
write(Rectangle rectangle)
Writes the XML representation of this Rectangle. |
private void |
writeSection(Section section,
int indent)
Writes the XML representation of a section. |
| Methods inherited from class com.lowagie.text.DocWriter |
add, addTabs, clearTextWrap, flush, getISOBytes, hasMarkupAttributes, isCloseStream, pause, removeWatermark, resetFooter, resetHeader, resetPageCount, resume, setCloseStream, setFooter, setHeader, 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, setMargins, setPageCount, setPageSize |
| Field Detail |
public static final byte[] PROLOG
public static final byte[] DOCTYPE
public static final byte[] DTD
private static final String[] xmlCode
private TreeMap itext
| 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 use| Method 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 ElementListeneradd in class DocWritertrue 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 DocListeneropen in class DocWriter
public boolean newPage()
throws DocumentException
newPage in interface DocListenernewPage in class DocWritertrue 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 DocListenerclose in class DocWriter
private void write(Element element,
int indent)
throws IOException
element - the elementindent - the indentation
IOException
private void writeSection(Section section,
int indent)
throws IOException
section - the section to writeindent - the indentation
IOException
private void write(Rectangle rectangle)
throws IOException
Rectangle.
rectangle - a Rectangle
IOException
static final String encode(String string,
int indent)
String.
string - the String to encode
String
static final void addTabs(StringBuffer buf,
int indent)
StringBuffer.
buf - the stringbufferindent - the number of tabs to add
private void write(Font font)
throws IOException
Font.
font - a Font
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||