Package net.ontopia.xml
Class PrettyPrinter
java.lang.Object
net.ontopia.xml.PrettyPrinter
- All Implemented Interfaces:
ContentHandler
INTERNAL: SAX document handler that writes pretty-printed XML to a
Writer.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPrettyPrinter(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUnescaped(String content) INTERNAL: Add given text unmodified and unescaped to the output.voidcharacters(char[] ch, int start, int length) voidvoidendElement(String uri, String localName, String qName) voidendPrefixMapping(String prefix) protected voidescapeAttrValue(String attrval, Writer writer) protected voidvoidignorableWhitespace(char[] ch, int start, int length) protected voidindent()protected voidmakeStartLineBuffer(int size) protected voidmakeSubelements(int size) voidprocessingInstruction(String target, String data) voidsetDocumentLocator(Locator locator) voidsetDropControlCharacters(boolean dropControlChars) INTERNAL: If this property is true control characters are being dropped from the resulting document.voidsetEncodeCharactersFrom(int charnumber) INTERNAL: Encodes element content as decimal character entitites for characters from the given character number.voidskippedEntity(String name) voidvoidstartElement(String uri, String localName, String qName, Attributes atts) voidstartPrefixMapping(String prefix, String uri) protected voidprotected voidprotected voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
writer
-
encoding
-
subelements
protected boolean[] subelements -
startline
protected char[] startline -
offset
protected int offset -
level
protected int level -
encodeCharsFrom
protected int encodeCharsFrom -
dropControlChars
protected boolean dropControlChars
-
-
Constructor Details
-
PrettyPrinter
Creates a PrettyPrinter that writes to the given OutputStream. The encoding used is always utf-8.- Throws:
UnsupportedEncodingException
-
PrettyPrinter
Creates a PrettyPrinter that writes to the given OutputStream in the requested character encoding.- Throws:
UnsupportedEncodingException
-
PrettyPrinter
Creates a PrettyPrinter that writes to the given Writer.- Parameters:
encoding- The encoding to report in the XML declaration. If null, no XML declaration will be output.
-
-
Method Details
-
startDocument
public void startDocument()- Specified by:
startDocumentin interfaceContentHandler
-
startElement
- Specified by:
startElementin interfaceContentHandler
-
endElement
- Specified by:
endElementin interfaceContentHandler
-
characters
public void characters(char[] ch, int start, int length) - Specified by:
charactersin interfaceContentHandler
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) - Specified by:
ignorableWhitespacein interfaceContentHandler
-
processingInstruction
- Specified by:
processingInstructionin interfaceContentHandler
-
endDocument
public void endDocument()- Specified by:
endDocumentin interfaceContentHandler
-
setDocumentLocator
- Specified by:
setDocumentLocatorin interfaceContentHandler
-
setEncodeCharactersFrom
public void setEncodeCharactersFrom(int charnumber) INTERNAL: Encodes element content as decimal character entitites for characters from the given character number. -
setDropControlCharacters
public void setDropControlCharacters(boolean dropControlChars) INTERNAL: If this property is true control characters are being dropped from the resulting document. -
addUnescaped
INTERNAL: Add given text unmodified and unescaped to the output. BEWARE: This makes it possible (even easy) to produce output that is not well-formed. -
write
-
write
-
write
-
flush
-
indent
protected void indent() -
escapeAttrValue
-
makeStartLineBuffer
protected void makeStartLineBuffer(int size) -
makeSubelements
protected void makeSubelements(int size) -
startPrefixMapping
- Specified by:
startPrefixMappingin interfaceContentHandler- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMappingin interfaceContentHandler- Throws:
SAXException
-
skippedEntity
- Specified by:
skippedEntityin interfaceContentHandler- Throws:
SAXException
-