|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.xml.io.BaseDOMFormatter | +--org.enhydra.xml.io.HTMLFormatter
Formatter for outputting a HTML DOM as a HTML text document.
Field Summary | |
protected static char |
ATTR_QUOTE_CHAR
Quote character to use for attribute values. |
protected static String |
ATTR_QUOTE_CHAR_ENTITY_REF
Entity reference for attribute value quote character. |
protected DocumentType |
fDocType
DocumentType from document. |
protected Document |
fDocument
Document being formatted. |
protected int |
fDynamicFormattedElementCount
Count of element open tags that were written not using preformatted text. |
protected OutputOptions |
fOptions
The output options. |
protected Writer |
fOut
Output writer. |
protected boolean |
fPreFormatMode
Are we doing pre-formatting? |
protected int |
fPreFormattedElementCount
Count of preformatted element open tags that were written. |
protected boolean |
fPrettyPrinting
Are we pretty-printing? |
protected String |
fPublicId
Public id to use for DOCTYPE, or null if none. |
protected String |
fSystemId
System id to use for DOCTYPE, or null if none. |
protected DOMTraversal |
fTraverser
DOM traverser. |
protected boolean |
fUsePreFormattedAttrText
Should pre-formatted text be use for descendents of attribute nodes. |
protected boolean |
fUsePreFormattedElements
Should pre-formatted Elements be written. |
protected boolean |
fUsePreFormattedText
Should pre-formatted text be written. |
protected static int |
MAX_ENTITY_QUICK_CHECK_CHAR
Maximum character value in an entity quick-check table. |
Constructor Summary | |
HTMLFormatter(Node node,
OutputOptions outputOptions,
boolean forPreFormatting)
Constructor. |
Method Summary | |
protected String |
getCharacterEntity(char textChar)
Get a character entity name for a character. |
(package private) static OutputOptions |
getDefaultOutputOptions()
Get the default OutputOptions for a document formatter with this formatter. |
int |
getDynamicFormattedElementCount()
Get the count of element open tags that were written not using preformatted text. |
int |
getDynamicFormattedTextCount()
Get the count of text nodes that were written not using preformatted text. |
String |
getMIMEEncoding()
Get the MIME-preferred encoding, determined from the OutputOptions and the formatter type. |
int |
getPreFormattedElementCount()
Get the count of preformatted element open tags that were written. |
int |
getPreFormattedTextCount()
Get the count of preformatted text nodes that were written. |
void |
handleAttr(Attr attr)
Handler called for Attr nodes. |
void |
handleCDATASection(CDATASection cdata)
Handler called for CDATASection nodes. |
void |
handleComment(Comment comment)
Handler called for Comment nodes. |
void |
handleDocument(Document document)
Handler called for Document nodes. |
void |
handleDocumentFragment(DocumentFragment documentFragment)
Handler called for DocumentFragment nodes; just process children. |
void |
handleDocumentType(DocumentType documentType)
Handler called for Document nodes; should never be called. |
void |
handleElement(Element element)
Handler called for Element nodes. |
void |
handleEntity(Entity entity)
Handler called for Entity nodes; should never be called. |
void |
handleEntityReference(EntityReference entityRef)
Handler called for EntityReference nodes. |
void |
handleNotation(Notation notation)
Handler called for Notation nodes; should never be called. |
void |
handleProcessingInstruction(ProcessingInstruction pi)
Handler called for ProcessingInstruction nodes. |
void |
handleText(Text text)
Handler called for Text nodes. |
String |
preFormatNode(Node node)
Format the contents of a node that can later be returned by a node implementing FormattedText. |
protected void |
printIndent()
Print indentation to the current level. |
boolean |
usedPreFormattedElements()
Determine if preformatted element open tags were used for the last document formatted. |
boolean |
usedPreFormattedText()
Determine if preformatted text was used for the last document formatted. |
void |
write(Node node,
Writer writer)
Format a Node and children to the specified writer. |
protected void |
writeAttributeValue(Attr attr)
Write an attribute value. |
protected void |
writeln()
Write a newline |
protected void |
writeOpenTag(Element element,
String tagName,
boolean hasChildren)
Write an element open tag. |
protected void |
writeText(String text)
Write a text string, encoding document type-specific character entities. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.enhydra.xml.io.Formatter |
getDynamicFormattedElementCount, getDynamicFormattedTextCount, getMIMEEncoding, getPreFormattedElementCount, getPreFormattedTextCount, preFormatNode, usedPreFormattedElements, usedPreFormattedText, write |
Field Detail |
protected static final int MAX_ENTITY_QUICK_CHECK_CHAR
protected static final char ATTR_QUOTE_CHAR
protected static final String ATTR_QUOTE_CHAR_ENTITY_REF
protected final OutputOptions fOptions
protected Writer fOut
protected final DOMTraversal fTraverser
protected final boolean fPreFormatMode
protected final boolean fUsePreFormattedText
protected final boolean fUsePreFormattedAttrText
protected final boolean fUsePreFormattedElements
protected int fPreFormattedElementCount
protected int fDynamicFormattedElementCount
protected final boolean fPrettyPrinting
protected final Document fDocument
protected final DocumentType fDocType
protected final String fPublicId
protected final String fSystemId
Constructor Detail |
public HTMLFormatter(Node node, OutputOptions outputOptions, boolean forPreFormatting)
Method Detail |
static OutputOptions getDefaultOutputOptions()
protected final String getCharacterEntity(char textChar)
BaseDOMFormatter
getCharacterEntity
in class BaseDOMFormatter
BaseDOMFormatter.getCharacterEntity(char)
public void handleDocument(Document document) throws IOException
handleDocument
in interface DOMTraversal.Handler
IOException
DOMTraversal.Handler.handleDocument(org.w3c.dom.Document)
public void handleDocumentType(DocumentType documentType) throws IOException
handleDocumentType
in interface DOMTraversal.Handler
IOException
DOMTraversal.Handler.handleDocumentType(org.w3c.dom.DocumentType)
public void handleDocumentFragment(DocumentFragment documentFragment)
handleDocumentFragment
in interface DOMTraversal.Handler
DOMTraversal.Handler.handleDocumentFragment(org.w3c.dom.DocumentFragment)
public void handleAttr(Attr attr) throws IOException
handleAttr
in interface DOMTraversal.Handler
IOException
DOMTraversal.Handler.handleAttr(org.w3c.dom.Attr)
protected final void writeOpenTag(Element element, String tagName, boolean hasChildren) throws IOException
writeOpenTag
in class BaseDOMFormatter
IOException
public void handleElement(Element element) throws IOException
This optionally corrects problem cases for browsers:
handleElement
in interface DOMTraversal.Handler
IOException
DOMTraversal.Handler.handleElement(org.w3c.dom.Element)
public void handleProcessingInstruction(ProcessingInstruction pi) throws IOException
handleProcessingInstruction
in interface DOMTraversal.Handler
IOException
DOMTraversal.Handler.handleProcessingInstruction(org.w3c.dom.ProcessingInstruction)
public void handleCDATASection(CDATASection cdata) throws IOException
handleCDATASection
in interface DOMTraversal.Handler
IOException
DOMTraversal.Handler.handleCDATASection(org.w3c.dom.CDATASection)
public final void handleText(Text text) throws IOException
handleText
in interface DOMTraversal.Handler
handleText
in class BaseDOMFormatter
IOException
DOMTraversal.Handler.handleText(org.w3c.dom.Text)
public final String getMIMEEncoding()
Formatter
getMIMEEncoding
in interface Formatter
Formatter.getMIMEEncoding()
public boolean usedPreFormattedText()
Formatter
usedPreFormattedText
in interface Formatter
Formatter.usedPreFormattedText()
public final int getPreFormattedTextCount()
getPreFormattedTextCount
in interface Formatter
public final int getDynamicFormattedTextCount()
getDynamicFormattedTextCount
in interface Formatter
public final boolean usedPreFormattedElements()
Formatter
usedPreFormattedElements
in interface Formatter
Formatter.usedPreFormattedElements()
public final int getPreFormattedElementCount()
getPreFormattedElementCount
in interface Formatter
public final int getDynamicFormattedElementCount()
getDynamicFormattedElementCount
in interface Formatter
protected final void writeln() throws IOException
IOException
protected final void printIndent() throws IOException
IOException
protected final void writeText(String text) throws IOException
IOException
public final void handleEntity(Entity entity)
handleEntity
in interface DOMTraversal.Handler
DOMTraversal.Handler.handleEntity(org.w3c.dom.Entity)
public final void handleNotation(Notation notation)
handleNotation
in interface DOMTraversal.Handler
DOMTraversal.Handler.handleNotation(org.w3c.dom.Notation)
public final void handleEntityReference(EntityReference entityRef) throws IOException
handleEntityReference
in interface DOMTraversal.Handler
IOException
DOMTraversal.Handler.handleEntityReference(org.w3c.dom.EntityReference)
public final void handleComment(Comment comment) throws IOException
handleComment
in interface DOMTraversal.Handler
IOException
DOMTraversal.Handler.handleComment(org.w3c.dom.Comment)
protected final void writeAttributeValue(Attr attr) throws IOException
IOException
public final String preFormatNode(Node node)
Formatter
preFormatNode
in interface Formatter
Formatter.preFormatNode(org.w3c.dom.Node)
public final void write(Node node, Writer writer) throws IOException
write
in interface Formatter
IOException
Formatter.write(org.w3c.dom.Node, java.io.Writer)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |