org.htmlcleaner
Class XmlSerializer

java.lang.Object
  extended by org.htmlcleaner.Serializer
      extended by org.htmlcleaner.XmlSerializer
Direct Known Subclasses:
BrowserCompactXmlSerializer, CompactXmlSerializer, PrettyXmlSerializer, SimpleXmlSerializer

public abstract class XmlSerializer
extends Serializer

Abstract XML serializer - contains common logic for descendants.


Field Summary
static String BEGIN_CDATA
           
static String END_CDATA
           
static String SAFE_BEGIN_CDATA
           
static String SAFE_END_CDATA
           
static String XMLNS_NAMESPACE
           
 
Fields inherited from class org.htmlcleaner.Serializer
props
 
Constructor Summary
protected XmlSerializer(CleanerProperties props)
           
 
Method Summary
protected  boolean dontEscape(TagNode tagNode)
           
protected  String escapeXml(String xmlContent)
           
 String getXmlAsString(TagNode tagNode)
          Deprecated. Use getAsString() instead.
 String getXmlAsString(TagNode tagNode, String charset)
          Deprecated. Use getAsString() instead.
 boolean isCreatingHtmlDom()
           
protected  boolean isForbiddenAttribute(TagNode tagNode, String attName, String value)
          Override to add additional conditions.
protected  boolean isForbiddenTag(TagNode tagNode)
           
protected  boolean isHeadOrBody(String tagName)
           
protected  boolean isMinimizedTagSyntax(TagNode tagNode)
           
protected  void serializeAttribute(TagNode tagNode, Writer writer, String attName, String attValue)
          This allows overriding to eliminate forbidden attributes (for example javascript attributes onclick, onblur, etc.
protected  void serializeEndTag(TagNode tagNode, Writer writer)
           
protected  void serializeEndTag(TagNode tagNode, Writer writer, boolean newLine)
           
protected  void serializeOpenTag(TagNode tagNode, Writer writer)
           
protected  void serializeOpenTag(TagNode tagNode, Writer writer, boolean newLine)
           
 void setCreatingHtmlDom(boolean creatingHtmlDom)
           
 void writeXml(TagNode tagNode, Writer writer, String charset)
          Deprecated. Use write() instead.
 void writeXmlToFile(TagNode tagNode, String fileName)
          Deprecated. Use writeToFile() instead.
 void writeXmlToFile(TagNode tagNode, String fileName, String charset)
          Deprecated. Use writeToFile() instead.
 void writeXmlToStream(TagNode tagNode, OutputStream out)
          Deprecated. Use writeToStream() instead.
 void writeXmlToStream(TagNode tagNode, OutputStream out, String charset)
          Deprecated. Use writeToStream() instead.
 
Methods inherited from class org.htmlcleaner.Serializer
getAsString, getAsString, getAsString, getAsString, getAsString, isScriptOrStyle, serialize, write, write, writeToFile, writeToFile, writeToFile, writeToFile, writeToStream, writeToStream, writeToStream, writeToStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XMLNS_NAMESPACE

public static final String XMLNS_NAMESPACE
See Also:
Constant Field Values

BEGIN_CDATA

public static final String BEGIN_CDATA
See Also:
Constant Field Values

END_CDATA

public static final String END_CDATA
See Also:
Constant Field Values

SAFE_BEGIN_CDATA

public static final String SAFE_BEGIN_CDATA
See Also:
Constant Field Values

SAFE_END_CDATA

public static final String SAFE_END_CDATA
See Also:
Constant Field Values
Constructor Detail

XmlSerializer

protected XmlSerializer(CleanerProperties props)
Method Detail

setCreatingHtmlDom

public void setCreatingHtmlDom(boolean creatingHtmlDom)
Parameters:
creatingHtmlDom - the creatingHtmlDom to set

isCreatingHtmlDom

public boolean isCreatingHtmlDom()
Returns:
the creatingHtmlDom

writeXmlToStream

@Deprecated
public void writeXmlToStream(TagNode tagNode,
                                        OutputStream out,
                                        String charset)
                      throws IOException
Deprecated. Use writeToStream() instead.

Throws:
IOException

writeXmlToStream

@Deprecated
public void writeXmlToStream(TagNode tagNode,
                                        OutputStream out)
                      throws IOException
Deprecated. Use writeToStream() instead.

Throws:
IOException

writeXmlToFile

@Deprecated
public void writeXmlToFile(TagNode tagNode,
                                      String fileName,
                                      String charset)
                    throws IOException
Deprecated. Use writeToFile() instead.

Throws:
IOException

writeXmlToFile

@Deprecated
public void writeXmlToFile(TagNode tagNode,
                                      String fileName)
                    throws IOException
Deprecated. Use writeToFile() instead.

Throws:
IOException

getXmlAsString

@Deprecated
public String getXmlAsString(TagNode tagNode,
                                        String charset)
Deprecated. Use getAsString() instead.


getXmlAsString

@Deprecated
public String getXmlAsString(TagNode tagNode)
Deprecated. Use getAsString() instead.


writeXml

@Deprecated
public void writeXml(TagNode tagNode,
                                Writer writer,
                                String charset)
              throws IOException
Deprecated. Use write() instead.

Throws:
IOException

escapeXml

protected String escapeXml(String xmlContent)

dontEscape

protected boolean dontEscape(TagNode tagNode)

isMinimizedTagSyntax

protected boolean isMinimizedTagSyntax(TagNode tagNode)

serializeOpenTag

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

serializeOpenTag

protected void serializeOpenTag(TagNode tagNode,
                                Writer writer,
                                boolean newLine)
                         throws IOException
Throws:
IOException

isForbiddenTag

protected boolean isForbiddenTag(TagNode tagNode)
Parameters:
tagNode -
Returns:

isHeadOrBody

protected boolean isHeadOrBody(String tagName)

serializeAttribute

protected void serializeAttribute(TagNode tagNode,
                                  Writer writer,
                                  String attName,
                                  String attValue)
                           throws IOException
This allows overriding to eliminate forbidden attributes (for example javascript attributes onclick, onblur, etc. )

Parameters:
writer -
attName -
attValue -
Throws:
IOException

isForbiddenAttribute

protected boolean isForbiddenAttribute(TagNode tagNode,
                                       String attName,
                                       String value)
Override to add additional conditions.

Parameters:
tagNode -
attName -
value -
Returns:
true if the attribute should not be outputed.

serializeEndTag

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

serializeEndTag

protected void serializeEndTag(TagNode tagNode,
                               Writer writer,
                               boolean newLine)
                        throws IOException
Throws:
IOException


Copyright © 2006-2013. All Rights Reserved.