public class PrettyPrintXMLWriter extends Object implements XMLWriter
Modifier and Type | Field and Description |
---|---|
protected static String |
LS
Line separator ("\n" on UNIX)
|
Constructor and Description |
---|
PrettyPrintXMLWriter(PrintWriter writer) |
PrettyPrintXMLWriter(PrintWriter writer,
String lineIndenter) |
PrettyPrintXMLWriter(PrintWriter writer,
String encoding,
String doctype) |
PrettyPrintXMLWriter(PrintWriter writer,
String lineIndenter,
String encoding,
String doctype) |
PrettyPrintXMLWriter(PrintWriter writer,
String lineIndenter,
String lineSeparator,
String encoding,
String doctype) |
PrettyPrintXMLWriter(Writer writer) |
PrettyPrintXMLWriter(Writer writer,
String lineIndenter) |
PrettyPrintXMLWriter(Writer writer,
String encoding,
String doctype) |
PrettyPrintXMLWriter(Writer writer,
String lineIndenter,
String encoding,
String doctype) |
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(String key,
String value) |
void |
endElement() |
protected void |
endOfLine()
Write the end of line character (using specified line separator) and start new line with indentation
|
protected int |
getDepth()
Get the current depth in the xml indentation
|
protected String |
getDocType()
Get the docType in the xml
|
protected LinkedList<String> |
getElementStack() |
protected String |
getEncoding()
Get the current encoding in the xml
|
protected String |
getLineIndenter()
Get the string used as line indenter
|
protected String |
getLineSeparator()
Get the string used as line separator or LS if not set.
|
protected PrintWriter |
getWriter()
Get the underlying writer
|
protected void |
setDepth(int depth)
Set the depth in the xml indentation
|
protected void |
setDocType(String docType)
Set the docType in the xml
|
protected void |
setEncoding(String encoding)
Set the encoding in the xml
|
protected void |
setLineIndenter(String lineIndenter)
Set the string used as line indenter
|
protected void |
setLineSeparator(String lineSeparator)
Set the string used as line separator
|
protected void |
setWriter(PrintWriter writer)
Set the underlying writer
|
void |
startElement(String name) |
void |
writeMarkup(String text) |
void |
writeText(String text) |
protected static final String LS
public PrettyPrintXMLWriter(PrintWriter writer, String lineIndenter)
writer
- not nulllineIndenter
- could be null, but the normal way is some spaces.public PrettyPrintXMLWriter(Writer writer, String lineIndenter)
writer
- not nulllineIndenter
- could be null, but the normal way is some spaces.public PrettyPrintXMLWriter(PrintWriter writer)
writer
- not nullpublic PrettyPrintXMLWriter(Writer writer)
writer
- not nullpublic PrettyPrintXMLWriter(PrintWriter writer, String lineIndenter, String encoding, String doctype)
writer
- not nulllineIndenter
- could be null, but the normal way is some spaces.encoding
- could be null or invalid.doctype
- could be null.public PrettyPrintXMLWriter(Writer writer, String lineIndenter, String encoding, String doctype)
writer
- not nulllineIndenter
- could be null, but the normal way is some spaces.encoding
- could be null or invalid.doctype
- could be null.public PrettyPrintXMLWriter(PrintWriter writer, String encoding, String doctype)
writer
- not nullencoding
- could be null or invalid.doctype
- could be null.public PrettyPrintXMLWriter(Writer writer, String encoding, String doctype)
writer
- not nullencoding
- could be null or invalid.doctype
- could be null.public PrettyPrintXMLWriter(PrintWriter writer, String lineIndenter, String lineSeparator, String encoding, String doctype)
writer
- not nulllineIndenter
- could be null, but the normal way is some spaces.lineSeparator
- could be null, but the normal way is valid line separator ("\n" on UNIX).encoding
- could be null or invalid.doctype
- could be null.public void startElement(String name)
startElement
in interface XMLWriter
public void writeMarkup(String text)
writeMarkup
in interface XMLWriter
public void addAttribute(String key, String value)
addAttribute
in interface XMLWriter
public void endElement()
endElement
in interface XMLWriter
protected String getLineIndenter()
protected void setLineIndenter(String lineIndenter)
lineIndenter
- new line indenter, could be null, but the normal way is some spaces.protected String getLineSeparator()
LS
protected void setLineSeparator(String lineSeparator)
lineSeparator
- new line separator, could be null but the normal way is valid line separator ("\n" on UNIX).protected void endOfLine()
getLineIndenter()
,
getLineSeparator()
protected void setWriter(PrintWriter writer)
writer
- not null writerprotected PrintWriter getWriter()
protected void setDepth(int depth)
depth
- new depthprotected int getDepth()
protected void setEncoding(String encoding)
encoding
- new encodingprotected String getEncoding()
protected void setDocType(String docType)
docType
- new docTypeprotected String getDocType()
protected LinkedList<String> getElementStack()
Copyright © 2001–2022 The Apache Software Foundation. All rights reserved.