Package org.cyberneko.html.filters
Class Writer
java.lang.Object
org.cyberneko.html.filters.DefaultFilter
org.cyberneko.html.filters.Writer
- All Implemented Interfaces:
org.apache.xerces.xni.parser.XMLComponent,org.apache.xerces.xni.parser.XMLDocumentFilter,org.apache.xerces.xni.parser.XMLDocumentSource,org.apache.xerces.xni.XMLDocumentHandler,HTMLComponent
An HTML writer written as a filter. Besides serializing the HTML
event stream, the writer also passes the document events to the next
stage in the pipeline. This allows applications to insert writer
filters between other custom filters for debugging purposes.
Since an HTML document may have specified its encoding using the <META> tag and http-equiv/content attributes, the writer will automatically change any character set specified in this tag to match the encoding of the output stream. Therefore, the character encoding name used to construct the writer should be an official IANA encoding name and not a Java encoding name.
Note: The modified character set in the <META> tag is not propagated to the next stage in the pipeline. The changed value is only output to the stream; the original value is sent to the next stage in the pipeline.
- Version:
- $Id: Writer.java,v 1.7 2005/02/14 04:01:33 andyc Exp $
- Author:
- Andy Clark
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringAugmentations feature identifier.protected intElement depth.protected StringThe encoding.protected static final StringFilters property identifier.protected booleanNormalize character content.protected booleanPrint characters.protected PrintWriterThe print writer used for serializing the document with the appropriate character encoding.protected booleanSeen http-equiv directive.protected booleanSeen root element.static final StringNotify character entity references.static final StringNotify built-in entity references.Fields inherited from class org.cyberneko.html.filters.DefaultFilter
fDocumentHandler, fDocumentSource -
Constructor Summary
ConstructorsConstructorDescriptionWriter()Constructs a writer filter that prints to standard out.Writer(OutputStream outputStream, String encoding) Constructs a writer filter using the specified output stream and encoding.Constructs a writer filter using the specified Java writer and encoding. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) Characters.voidcomment(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) Comment.voidemptyElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs) Empty element.voidendElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs) End element.voidendGeneralEntity(String name, org.apache.xerces.xni.Augmentations augs) End general entity.static voidMain.protected voidprintAttributeValue(String text) Print attribute value.protected voidprintCharacters(org.apache.xerces.xni.XMLString text, boolean normalize) Print characters.protected voidprintEndElement(org.apache.xerces.xni.QName element) Print end element.protected voidprintEntity(String name) Print entity.protected voidprintStartElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes) Print start element.voidstartDocument(org.apache.xerces.xni.XMLLocator locator, String encoding, org.apache.xerces.xni.Augmentations augs) Start document.voidstartDocument(org.apache.xerces.xni.XMLLocator locator, String encoding, org.apache.xerces.xni.NamespaceContext nscontext, org.apache.xerces.xni.Augmentations augs) Start document.voidstartElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs) Start element.voidstartGeneralEntity(String name, org.apache.xerces.xni.XMLResourceIdentifier id, String encoding, org.apache.xerces.xni.Augmentations augs) Start general entity.Methods inherited from class org.cyberneko.html.filters.DefaultFilter
doctypeDecl, endCDATA, endDocument, endPrefixMapping, getDocumentHandler, getDocumentSource, getFeatureDefault, getPropertyDefault, getRecognizedFeatures, getRecognizedProperties, ignorableWhitespace, merge, processingInstruction, reset, setDocumentHandler, setDocumentSource, setFeature, setProperty, startCDATA, startPrefixMapping, textDecl, xmlDecl
-
Field Details
-
NOTIFY_CHAR_REFS
Notify character entity references.- See Also:
-
NOTIFY_HTML_BUILTIN_REFS
Notify built-in entity references.- See Also:
-
AUGMENTATIONS
Augmentations feature identifier.- See Also:
-
FILTERS
Filters property identifier.- See Also:
-
fEncoding
The encoding. -
fPrinter
The print writer used for serializing the document with the appropriate character encoding. -
fSeenRootElement
protected boolean fSeenRootElementSeen root element. -
fSeenHttpEquiv
protected boolean fSeenHttpEquivSeen http-equiv directive. -
fElementDepth
protected int fElementDepthElement depth. -
fNormalize
protected boolean fNormalizeNormalize character content. -
fPrintChars
protected boolean fPrintCharsPrint characters.
-
-
Constructor Details
-
Writer
public Writer()Constructs a writer filter that prints to standard out. -
Writer
Constructs a writer filter using the specified output stream and encoding.- Parameters:
outputStream- The output stream to write to.encoding- The encoding to be used for the output. The encoding name should be an official IANA encoding name.- Throws:
UnsupportedEncodingException
-
Writer
Constructs a writer filter using the specified Java writer and encoding.- Parameters:
writer- The Java writer to write to.encoding- The encoding to be used for the output. The encoding name should be an official IANA encoding name.
-
-
Method Details
-
startDocument
public void startDocument(org.apache.xerces.xni.XMLLocator locator, String encoding, org.apache.xerces.xni.NamespaceContext nscontext, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Start document.- Specified by:
startDocumentin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
startDocumentin classDefaultFilter- Throws:
org.apache.xerces.xni.XNIException
-
startDocument
public void startDocument(org.apache.xerces.xni.XMLLocator locator, String encoding, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Start document.- Overrides:
startDocumentin classDefaultFilter- Throws:
org.apache.xerces.xni.XNIException
-
comment
public void comment(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Comment.- Specified by:
commentin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
commentin classDefaultFilter- Throws:
org.apache.xerces.xni.XNIException
-
startElement
public void startElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Start element.- Specified by:
startElementin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
startElementin classDefaultFilter- Throws:
org.apache.xerces.xni.XNIException
-
emptyElement
public void emptyElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Empty element.- Specified by:
emptyElementin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
emptyElementin classDefaultFilter- Throws:
org.apache.xerces.xni.XNIException
-
characters
public void characters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Characters.- Specified by:
charactersin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
charactersin classDefaultFilter- Throws:
org.apache.xerces.xni.XNIException
-
endElement
public void endElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException End element.- Specified by:
endElementin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
endElementin classDefaultFilter- Throws:
org.apache.xerces.xni.XNIException
-
startGeneralEntity
public void startGeneralEntity(String name, org.apache.xerces.xni.XMLResourceIdentifier id, String encoding, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException Start general entity.- Specified by:
startGeneralEntityin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
startGeneralEntityin classDefaultFilter- Throws:
org.apache.xerces.xni.XNIException
-
endGeneralEntity
public void endGeneralEntity(String name, org.apache.xerces.xni.Augmentations augs) throws org.apache.xerces.xni.XNIException End general entity.- Specified by:
endGeneralEntityin interfaceorg.apache.xerces.xni.XMLDocumentHandler- Overrides:
endGeneralEntityin classDefaultFilter- Throws:
org.apache.xerces.xni.XNIException
-
printAttributeValue
Print attribute value. -
printCharacters
protected void printCharacters(org.apache.xerces.xni.XMLString text, boolean normalize) Print characters. -
printStartElement
protected void printStartElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes) Print start element. -
printEndElement
protected void printEndElement(org.apache.xerces.xni.QName element) Print end element. -
printEntity
Print entity. -
main
Main.- Throws:
Exception
-