public class HTMLWriterFilter extends DefaultFilter
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.
| Constructor and Description |
|---|
HTMLWriterFilter()
Constructs a writer filter that prints to standard out.
|
HTMLWriterFilter(OutputStream outputStream,
String encoding)
Constructs a writer filter using the specified output stream and
encoding.
|
HTMLWriterFilter(Writer writer,
String encoding,
HTMLElements htmlElements)
Constructs a writer filter using the specified Java writer and
encoding.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(XMLString text,
Augmentations augs)
Characters.
|
void |
comment(XMLString text,
Augmentations augs)
Comment.
|
void |
emptyElement(QName element,
XMLAttributes attributes,
Augmentations augs)
Empty element.
|
void |
endElement(QName element,
Augmentations augs)
End element.
|
protected int |
getElementDepth() |
protected boolean |
getNormalize() |
protected boolean |
hasSeenRootElement() |
protected void |
print(String content) |
protected void |
printAttributeValue(String text)
Print attribute value.
|
protected void |
printCharacters(XMLString text,
boolean normalize)
Print characters.
|
protected void |
printEndElement(QName element)
Print end element.
|
protected void |
printStartElement(QName element,
XMLAttributes attributes)
Print start element.
|
void |
startDocument(XMLLocator locator,
String encoding,
NamespaceContext nscontext,
Augmentations augs)
Start document.
|
void |
startElement(QName element,
XMLAttributes attributes,
Augmentations augs)
Start element.
|
doctypeDecl, endCDATA, endDocument, getDocumentHandler, getDocumentSource, getFeatureDefault, getPropertyDefault, getRecognizedFeatures, getRecognizedProperties, merge, processingInstruction, reset, setDocumentHandler, setDocumentSource, setFeature, setProperty, startCDATA, xmlDeclpublic HTMLWriterFilter()
public HTMLWriterFilter(OutputStream outputStream, String encoding) throws UnsupportedEncodingException
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.UnsupportedEncodingExceptionpublic HTMLWriterFilter(Writer writer, String encoding, HTMLElements htmlElements)
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.public void startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs) throws XNIException
startDocument in interface XMLDocumentHandlerstartDocument in class DefaultFilterlocator - The document locator, or null if the document
location cannot be reported during the parsing of
this document. However, it is strongly
recommended that a locator be supplied that can at
least report the system identifier of the document.encoding - The auto-detected IANA encoding name of the entity
stream. This value will be null in those situations
where the entity encoding is not auto-detected (e.g.
internal entities or a document entity that is parsed
from a java.io.Reader).nscontext - The namespace context in effect at the start of this
document. This object represents the current context.
Implementors of this class are responsible for
copying the namespace bindings from the the current
context (and its parent contexts) if that information
is important.augs - Additional information that may include infoset
augmentationsXNIException - Thrown by handler to signal an error.public void comment(XMLString text, Augmentations augs) throws XNIException
comment in interface XMLDocumentHandlercomment in class DefaultFiltertext - The text in the comment.augs - Additional information that may include infoset augmentationsXNIException - Thrown by application to signal an error.public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException
startElement in interface XMLDocumentHandlerstartElement in class DefaultFilterelement - The name of the element.attributes - The element attributes.augs - Additional information that may include infoset
augmentationsXNIException - Thrown by handler to signal an error.public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException
emptyElement in interface XMLDocumentHandleremptyElement in class DefaultFilterelement - The name of the element.attributes - The element attributes.augs - Additional information that may include infoset
augmentationsXNIException - Thrown by handler to signal an error.public void characters(XMLString text, Augmentations augs) throws XNIException
characters in interface XMLDocumentHandlercharacters in class DefaultFiltertext - The content.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.public void endElement(QName element, Augmentations augs) throws XNIException
endElement in interface XMLDocumentHandlerendElement in class DefaultFilterelement - The name of the element.augs - Additional information that may include infoset augmentationsXNIException - Thrown by handler to signal an error.protected void printAttributeValue(String text)
protected void printCharacters(XMLString text, boolean normalize)
protected void printStartElement(QName element, XMLAttributes attributes)
protected void printEndElement(QName element)
protected void print(String content)
protected boolean hasSeenRootElement()
protected int getElementDepth()
protected boolean getNormalize()
Copyright © 2024 HtmlUnit. All rights reserved.