public class PrettyPrinter extends Object implements ContentHandler
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
dropControlChars |
protected int |
encodeCharsFrom |
protected String |
encoding |
protected int |
level |
protected int |
offset |
protected char[] |
startline |
protected boolean[] |
subelements |
protected Writer |
writer |
| Constructor and Description |
|---|
PrettyPrinter(OutputStream stream)
Creates a PrettyPrinter that writes to the given OutputStream.
|
PrettyPrinter(OutputStream stream,
String encoding)
Creates a PrettyPrinter that writes to the given OutputStream
in the requested character encoding.
|
PrettyPrinter(Writer writer,
String encoding)
Creates a PrettyPrinter that writes to the given Writer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addUnescaped(String content)
INTERNAL: Add given text unmodified and unescaped to the output.
|
void |
characters(char[] ch,
int start,
int length) |
void |
endDocument() |
void |
endElement(String uri,
String localName,
String qName) |
void |
endPrefixMapping(String prefix) |
protected void |
escapeAttrValue(String attrval,
Writer writer) |
protected void |
flush(Writer writer) |
void |
ignorableWhitespace(char[] ch,
int start,
int length) |
protected void |
indent() |
protected void |
makeStartLineBuffer(int size) |
protected void |
makeSubelements(int size) |
void |
processingInstruction(String target,
String data) |
void |
setDocumentLocator(Locator locator) |
void |
setDropControlCharacters(boolean dropControlChars)
INTERNAL: If this property is true control characters are being
dropped from the resulting document.
|
void |
setEncodeCharactersFrom(int charnumber)
INTERNAL: Encodes element content as decimal character entitites
for characters from the given character number.
|
void |
skippedEntity(String name) |
void |
startDocument() |
void |
startElement(String uri,
String localName,
String qName,
Attributes atts) |
void |
startPrefixMapping(String prefix,
String uri) |
protected void |
write(Writer writer,
char c) |
protected void |
write(Writer writer,
char[] c,
int off,
int len) |
protected void |
write(Writer writer,
String s) |
protected Writer writer
protected String encoding
protected boolean[] subelements
protected char[] startline
protected int offset
protected int level
protected int encodeCharsFrom
protected boolean dropControlChars
public PrettyPrinter(OutputStream stream) throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic PrettyPrinter(OutputStream stream, String encoding) throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic void startDocument()
startDocument in interface ContentHandlerpublic void startElement(String uri, String localName, String qName, Attributes atts)
startElement in interface ContentHandlerpublic void endElement(String uri, String localName, String qName)
endElement in interface ContentHandlerpublic void characters(char[] ch,
int start,
int length)
characters in interface ContentHandlerpublic void ignorableWhitespace(char[] ch,
int start,
int length)
ignorableWhitespace in interface ContentHandlerpublic void processingInstruction(String target, String data)
processingInstruction in interface ContentHandlerpublic void endDocument()
endDocument in interface ContentHandlerpublic void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlerpublic void setEncodeCharactersFrom(int charnumber)
public void setDropControlCharacters(boolean dropControlChars)
public void addUnescaped(String content)
protected void write(Writer writer, char c)
protected void write(Writer writer, char[] c, int off, int len)
protected void flush(Writer writer)
protected void indent()
protected void makeStartLineBuffer(int size)
protected void makeSubelements(int size)
public void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping in interface ContentHandlerSAXExceptionpublic void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping in interface ContentHandlerSAXExceptionpublic void skippedEntity(String name) throws SAXException
skippedEntity in interface ContentHandlerSAXException