Class PrettyPrinter
- java.lang.Object
-
- org.apache.batik.transcoder.svg2svg.PrettyPrinter
-
public class PrettyPrinter extends java.lang.ObjectThis class represents an SVG source files pretty-printer.- Version:
- $Id: PrettyPrinter.java 1733416 2016-03-03 07:07:13Z gadams $
-
-
Field Summary
Fields Modifier and Type Field Description static intDOCTYPE_CHANGEstatic intDOCTYPE_KEEP_UNCHANGEDstatic intDOCTYPE_REMOVEprotected intdoctypeOptionThe doctype option.protected intdocumentWidthThe document width.protected ErrorHandlererrorHandlerThe error handler.protected booleanformatWhether the output must be formatted.protected java.lang.StringnewlineThe newline characters.protected OutputManageroutputThe output manager.protected java.lang.StringpublicIdThe public id.protected XMLScannerscannerThe document scanner.protected java.lang.StringsystemIdThe system id.protected inttabulationWidthThe tabulation width.protected inttypeThe type of the current lexical unit.protected java.io.WriterwriterThe writer used to output the document.protected java.lang.StringxmlDeclarationThe XML declaration.
-
Constructor Summary
Constructors Constructor Description PrettyPrinter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) booleanallowSpaceAtStart(java.lang.String tagName)protected TranscoderExceptionfatalError(java.lang.String key, java.lang.Object[] params)Creates a transcoder exception.protected char[]getCurrentValue()Returns the current lexical unit value.intgetDocumentWidth()Returns whether the document width.booleangetFormat()Returns whether the output must be formatted.java.lang.StringgetNewline()Returns the newline characters.intgetTabulationWidth()Returns whether the tabulation width.voidprint(java.io.Reader r, java.io.Writer w)Prints an SVG document from the given reader to the given writer.protected voidprintAttlist()Prints an ATTLIST declaration.protected voidprintChildren()Prints the children of an element declaration.protected voidprintContent(boolean spaceAtStart)Prints the content of an element.protected voidprintDoctype()Prints the doctype.protected java.lang.StringprintElement()Prints an element.protected voidprintElementDeclaration()Prints an element declaration.protected voidprintEntityDeclaration()Prints an entity declaration.protected voidprintNotation()Prints a notation declaration.protected voidprintPI()Prints a processing instruction.protected voidprintXMLDecl()Prints the XML declaration.voidsetDoctypeOption(int i)Sets the doctype option.voidsetDocumentWidth(int i)Sets the document width.voidsetFormat(boolean b)Sets the format attribute.voidsetNewline(java.lang.String s)Sets the newline characters.voidsetPublicId(java.lang.String s)Sets the public ID.voidsetSystemId(java.lang.String s)Sets the system ID.voidsetTabulationWidth(int i)Sets the tabulation width.voidsetXMLDeclaration(java.lang.String s)Sets the XML declaration text.
-
-
-
Field Detail
-
DOCTYPE_CHANGE
public static final int DOCTYPE_CHANGE
- See Also:
- Constant Field Values
-
DOCTYPE_REMOVE
public static final int DOCTYPE_REMOVE
- See Also:
- Constant Field Values
-
DOCTYPE_KEEP_UNCHANGED
public static final int DOCTYPE_KEEP_UNCHANGED
- See Also:
- Constant Field Values
-
scanner
protected XMLScanner scanner
The document scanner.
-
output
protected OutputManager output
The output manager.
-
writer
protected java.io.Writer writer
The writer used to output the document.
-
errorHandler
protected ErrorHandler errorHandler
The error handler.
-
newline
protected java.lang.String newline
The newline characters.
-
format
protected boolean format
Whether the output must be formatted.
-
tabulationWidth
protected int tabulationWidth
The tabulation width.
-
documentWidth
protected int documentWidth
The document width.
-
doctypeOption
protected int doctypeOption
The doctype option.
-
publicId
protected java.lang.String publicId
The public id.
-
systemId
protected java.lang.String systemId
The system id.
-
xmlDeclaration
protected java.lang.String xmlDeclaration
The XML declaration.
-
type
protected int type
The type of the current lexical unit.
-
-
Method Detail
-
setXMLDeclaration
public void setXMLDeclaration(java.lang.String s)
Sets the XML declaration text.
-
setDoctypeOption
public void setDoctypeOption(int i)
Sets the doctype option.
-
setPublicId
public void setPublicId(java.lang.String s)
Sets the public ID.
-
setSystemId
public void setSystemId(java.lang.String s)
Sets the system ID.
-
setNewline
public void setNewline(java.lang.String s)
Sets the newline characters.
-
getNewline
public java.lang.String getNewline()
Returns the newline characters.
-
setFormat
public void setFormat(boolean b)
Sets the format attribute.
-
getFormat
public boolean getFormat()
Returns whether the output must be formatted.
-
setTabulationWidth
public void setTabulationWidth(int i)
Sets the tabulation width.
-
getTabulationWidth
public int getTabulationWidth()
Returns whether the tabulation width.
-
setDocumentWidth
public void setDocumentWidth(int i)
Sets the document width.
-
getDocumentWidth
public int getDocumentWidth()
Returns whether the document width.
-
print
public void print(java.io.Reader r, java.io.Writer w) throws TranscoderException, java.io.IOExceptionPrints an SVG document from the given reader to the given writer.- Throws:
TranscoderExceptionjava.io.IOException
-
printXMLDecl
protected void printXMLDecl() throws TranscoderException, XMLException, java.io.IOExceptionPrints the XML declaration.- Throws:
TranscoderExceptionXMLExceptionjava.io.IOException
-
printPI
protected void printPI() throws TranscoderException, XMLException, java.io.IOExceptionPrints a processing instruction.- Throws:
TranscoderExceptionXMLExceptionjava.io.IOException
-
printDoctype
protected void printDoctype() throws TranscoderException, XMLException, java.io.IOExceptionPrints the doctype.- Throws:
TranscoderExceptionXMLExceptionjava.io.IOException
-
printElement
protected java.lang.String printElement() throws TranscoderException, XMLException, java.io.IOExceptionPrints an element.- Throws:
TranscoderExceptionXMLExceptionjava.io.IOException
-
allowSpaceAtStart
boolean allowSpaceAtStart(java.lang.String tagName)
-
printContent
protected void printContent(boolean spaceAtStart) throws TranscoderException, XMLException, java.io.IOExceptionPrints the content of an element.- Throws:
TranscoderExceptionXMLExceptionjava.io.IOException
-
printNotation
protected void printNotation() throws TranscoderException, XMLException, java.io.IOExceptionPrints a notation declaration.- Throws:
TranscoderExceptionXMLExceptionjava.io.IOException
-
printAttlist
protected void printAttlist() throws TranscoderException, XMLException, java.io.IOExceptionPrints an ATTLIST declaration.- Throws:
TranscoderExceptionXMLExceptionjava.io.IOException
-
printEntityDeclaration
protected void printEntityDeclaration() throws TranscoderException, XMLException, java.io.IOExceptionPrints an entity declaration.- Throws:
TranscoderExceptionXMLExceptionjava.io.IOException
-
printElementDeclaration
protected void printElementDeclaration() throws TranscoderException, XMLException, java.io.IOExceptionPrints an element declaration.- Throws:
TranscoderExceptionXMLExceptionjava.io.IOException
-
printChildren
protected void printChildren() throws TranscoderException, XMLException, java.io.IOExceptionPrints the children of an element declaration.- Throws:
TranscoderExceptionXMLExceptionjava.io.IOException
-
getCurrentValue
protected char[] getCurrentValue()
Returns the current lexical unit value.
-
fatalError
protected TranscoderException fatalError(java.lang.String key, java.lang.Object[] params) throws TranscoderException
Creates a transcoder exception.- Throws:
TranscoderException
-
-