org.htmlcleaner
Class Serializer

java.lang.Object
  extended by org.htmlcleaner.Serializer
Direct Known Subclasses:
HtmlSerializer, XmlSerializer

public abstract class Serializer
extends Object

Basic abstract serializer - contains common logic for descendants (methods writeXXX().


Field Summary
protected  CleanerProperties props
           
 
Constructor Summary
protected Serializer(CleanerProperties props)
           
 
Method Summary
 String getAsString(String htmlContent)
           
 String getAsString(TagNode tagNode)
           
 String getAsString(TagNode tagNode, boolean omitEnvelope)
           
 String getAsString(TagNode tagNode, String charset)
           
 String getAsString(TagNode tagNode, String charset, boolean omitEnvelope)
           
protected  boolean isScriptOrStyle(TagNode tagNode)
           
protected abstract  void serialize(TagNode tagNode, Writer writer)
           
 void write(TagNode tagNode, Writer writer, String charset)
          Writes specified node using specified writer.
 void write(TagNode tagNode, Writer writer, String charset, boolean omitEnvelope)
          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).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

props

protected CleanerProperties props
Constructor Detail

Serializer

protected Serializer(CleanerProperties props)
Method Detail

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 written
out - Output stream
charset - Charset of the output
omitEnvelope - Tells whether to skip open and close tag of the node.
Throws:
IOException

writeToStream

public void writeToStream(TagNode tagNode,
                          OutputStream out,
                          String charset)
                   throws IOException
Writes specified TagNode to the output stream, using specified charset.

Parameters:
tagNode - Node to be written
out - Output stream
charset - 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 written
out - Output stream
omitEnvelope - Tells whether to skip open and close tag of the node.
Throws:
IOException

writeToStream

public void writeToStream(TagNode tagNode,
                          OutputStream out)
                   throws IOException
Writes specified TagNode to the output stream, using system default charset.

Parameters:
tagNode - Node to be written
out - 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 written
fileName - Output file name
charset - Charset of the output
omitEnvelope - Tells whether to skip open and close tag of the node.
Throws:
IOException

writeToFile

public void writeToFile(TagNode tagNode,
                        String fileName,
                        String charset)
                 throws IOException
Writes specified TagNode to the file, using specified charset.

Parameters:
tagNode - Node to be written
fileName - Output file name
charset - Charset of the output
Throws:
IOException

writeToFile

public void writeToFile(TagNode tagNode,
                        String fileName,
                        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 written
fileName - Output file name
omitEnvelope - Tells whether to skip open and close tag of the node.
Throws:
IOException

writeToFile

public void writeToFile(TagNode tagNode,
                        String fileName)
                 throws IOException
Writes specified TagNode to the file, using system default charset.

Parameters:
tagNode - Node to be written
fileName - Output file name
Throws:
IOException

getAsString

public String getAsString(TagNode tagNode,
                          String charset,
                          boolean omitEnvelope)
Parameters:
tagNode - Node to serialize to string
charset - Charset of the output - stands in xml declaration part
omitEnvelope - Tells whether to skip open and close tag of the node.
Returns:
Output as string

getAsString

public String getAsString(TagNode tagNode,
                          String charset)
Parameters:
tagNode - Node to serialize to string
charset - Charset of the output - stands in xml declaration part
Returns:
Output as string

getAsString

public String getAsString(TagNode tagNode,
                          boolean omitEnvelope)
Parameters:
tagNode - Node to serialize to string
omitEnvelope - Tells whether to skip open and close tag of the node.
Returns:
Output as string
Throws:
IOException

getAsString

public String getAsString(TagNode tagNode)
Parameters:
tagNode - Node to serialize to string
Returns:
Output as string
Throws:
IOException

getAsString

public String getAsString(String htmlContent)

write

public void write(TagNode tagNode,
                  Writer writer,
                  String charset)
           throws IOException
Writes specified node using specified writer.

Parameters:
tagNode - Node to serialize.
writer - Writer instance
charset - 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 instance
charset - Charset of the output
omitEnvelope - Tells whether to skip open and close tag of the node.
Throws:
IOException

isScriptOrStyle

protected boolean isScriptOrStyle(TagNode tagNode)

serialize

protected abstract void serialize(TagNode tagNode,
                                  Writer writer)
                           throws IOException
Throws:
IOException


Copyright © 2006-2014. All Rights Reserved.