Package org.htmlcleaner
Class Serializer
java.lang.Object
org.htmlcleaner.Serializer
- Direct Known Subclasses:
HtmlSerializer
,XmlSerializer
Basic abstract serializer - contains common logic for descendants (methods writeXXX()
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
Used to implement serialization with missing envelope - omiting open and close tags, just serialize children. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAsString
(String htmlContent) getAsString
(TagNode tagNode) getAsString
(TagNode tagNode, boolean omitEnvelope) getAsString
(TagNode tagNode, String charset) getAsString
(TagNode tagNode, String charset, boolean omitEnvelope) protected boolean
isScriptOrStyle
(TagNode tagNode) protected abstract void
void
Writes specified node using specified writer.void
Writes specified node using specified writer.void
writeToFile
(TagNode tagNode, String fileName) Writes specified TagNode to the file, using system default charset.void
writeToFile
(TagNode tagNode, String fileName, boolean omitEnvelope) Writes specified TagNode to the file, using specified charset and optionally omits node envelope (skips open and close tags of the node).void
writeToFile
(TagNode tagNode, String fileName, String charset) Writes specified TagNode to the file, using specified charset.void
writeToFile
(TagNode tagNode, String fileName, String charset, boolean omitEnvelope) Writes specified TagNode to the file, using specified charset and optionally omits node envelope (skips open and close tags of the node).void
writeToStream
(TagNode tagNode, OutputStream out) Writes specified TagNode to the output stream, using system default charset.void
writeToStream
(TagNode tagNode, OutputStream out, boolean omitEnvelope) Writes specified TagNode to the output stream, using system default charset and optionally omits node envelope (skips open and close tags of the node).void
writeToStream
(TagNode tagNode, OutputStream out, String charset) Writes specified TagNode to the output stream, using specified charset.void
writeToStream
(TagNode tagNode, OutputStream out, String charset, boolean omitEnvelope) Writes specified TagNode to the output stream, using specified charset and optionally omits node envelope (skips open and close tags of the node).
-
Field Details
-
props
-
-
Constructor Details
-
Serializer
-
-
Method Details
-
writeToStream
public void writeToStream(TagNode tagNode, OutputStream out, String charset, boolean omitEnvelope) throws IOException Writes specified TagNode to the output stream, using specified charset and optionally omits node envelope (skips open and close tags of the node).- Parameters:
tagNode
- Node to be writtenout
- Output streamcharset
- Charset of the outputomitEnvelope
- Tells whether to skip open and close tag of the node.- Throws:
IOException
-
writeToStream
Writes specified TagNode to the output stream, using specified charset.- Parameters:
tagNode
- Node to be writtenout
- Output streamcharset
- Charset of the output- Throws:
IOException
-
writeToStream
public void writeToStream(TagNode tagNode, OutputStream out, boolean omitEnvelope) throws IOException Writes specified TagNode to the output stream, using system default charset and optionally omits node envelope (skips open and close tags of the node).- Parameters:
tagNode
- Node to be writtenout
- Output streamomitEnvelope
- Tells whether to skip open and close tag of the node.- Throws:
IOException
-
writeToStream
Writes specified TagNode to the output stream, using system default charset.- Parameters:
tagNode
- Node to be writtenout
- Output stream- Throws:
IOException
-
writeToFile
public void writeToFile(TagNode tagNode, String fileName, String charset, boolean omitEnvelope) throws IOException Writes specified TagNode to the file, using specified charset and optionally omits node envelope (skips open and close tags of the node).- Parameters:
tagNode
- Node to be writtenfileName
- Output file namecharset
- Charset of the outputomitEnvelope
- Tells whether to skip open and close tag of the node.- Throws:
IOException
-
writeToFile
Writes specified TagNode to the file, using specified charset.- Parameters:
tagNode
- Node to be writtenfileName
- Output file namecharset
- Charset of the output- Throws:
IOException
-
writeToFile
Writes specified TagNode to the file, using specified charset and optionally omits node envelope (skips open and close tags of the node).- Parameters:
tagNode
- Node to be writtenfileName
- Output file nameomitEnvelope
- Tells whether to skip open and close tag of the node.- Throws:
IOException
-
writeToFile
Writes specified TagNode to the file, using system default charset.- Parameters:
tagNode
- Node to be writtenfileName
- Output file name- Throws:
IOException
-
getAsString
- Parameters:
tagNode
- Node to serialize to stringcharset
- Charset of the output - stands in xml declaration partomitEnvelope
- Tells whether to skip open and close tag of the node.- Returns:
- Output as string
-
getAsString
- Parameters:
tagNode
- Node to serialize to stringcharset
- Charset of the output - stands in xml declaration part- Returns:
- Output as string
-
getAsString
- Parameters:
tagNode
- Node to serialize to stringomitEnvelope
- Tells whether to skip open and close tag of the node.- Returns:
- Output as string
- Throws:
IOException
-
getAsString
- Parameters:
tagNode
- Node to serialize to string- Returns:
- Output as string
- Throws:
IOException
-
getAsString
-
write
Writes specified node using specified writer.- Parameters:
tagNode
- Node to serialize.writer
- Writer instancecharset
- Charset of the output- Throws:
IOException
-
write
public void write(TagNode tagNode, Writer writer, String charset, boolean omitEnvelope) throws IOException Writes specified node using specified writer.- Parameters:
tagNode
- Node to serialize.writer
- Writer instancecharset
- Charset of the outputomitEnvelope
- Tells whether to skip open and close tag of the node.- Throws:
IOException
-
isScriptOrStyle
-
serialize
- Throws:
IOException
-