org.eclipse.actf.util.dom
Class DomPrintUtil

java.lang.Object
  extended by org.eclipse.actf.util.dom.DomPrintUtil

public class DomPrintUtil
extends Object

Utility class to print out DOM


Nested Class Summary
static interface DomPrintUtil.AttributeFilter
          AttributeFilter defines the behavior of a filter that is used for converting attributes of each Element into String.
 
Field Summary
static String UTF8
          Default encoding of this utility.
 
Constructor Summary
DomPrintUtil(Document document)
          Constructor of DOM print utility.
 
Method Summary
 void setAttrFilter(DomPrintUtil.AttributeFilter attrFilter)
          Set AttributeFilter to define the behavior for printing attributes of each Element.
 void setEntityReferenceExpansion(boolean entityReferenceExpansion)
          Set the entity reference expansion flag to TreeWalker used in the utility.
 void setEscapeTagBracket(boolean escapeTagBracket)
          Determine to escape Tag bracket ('<','>') or not.
 void setIndent(boolean indent)
          Set the number of space characters used for indent
 void setNodeFilter(org.w3c.dom.traversal.NodeFilter nodeFilter)
          Set NodeFilter to TreeWalker used in the utility.
 void setWhatToShow(int whatToShow)
          Set whatToShow attribute to TreeWalker used in the utility.
 String toString()
           
 String toXMLString()
          Returns XML text converted from the target DOM
 void writeToFile(File file)
          Print out the target Document.
 void writeToFile(File file, String encode)
          Print out the target Document in specified encoding
 void writeToFile(String filePath)
          Print out the target Document.
 void writeToFile(String filePath, String encode)
          Print out the target Document in specified encoding
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UTF8

public static final String UTF8
Default encoding of this utility. (UTF8)

See Also:
Constant Field Values
Constructor Detail

DomPrintUtil

public DomPrintUtil(Document document)
Constructor of DOM print utility.

Parameters:
document - the target document
Method Detail

toXMLString

public String toXMLString()
Returns XML text converted from the target DOM

Returns:
String format XML converted from the target DOM

toString

public String toString()
Overrides:
toString in class Object

setWhatToShow

public void setWhatToShow(int whatToShow)
Set whatToShow attribute to TreeWalker used in the utility.

Parameters:
whatToShow - the attribute determines which types of node are presented via the TreeWalker. The values are defined in the NodeFilter interface.
See Also:
TreeWalkerImpl

setNodeFilter

public void setNodeFilter(org.w3c.dom.traversal.NodeFilter nodeFilter)
Set NodeFilter to TreeWalker used in the utility.

Parameters:
nodeFilter - the filter used to screen nodes
See Also:
TreeWalkerImpl

setEntityReferenceExpansion

public void setEntityReferenceExpansion(boolean entityReferenceExpansion)
Set the entity reference expansion flag to TreeWalker used in the utility.

Parameters:
entityReferenceExpansion - the flag to determine whether the children of entity reference nodes are visible to TreeWalker.
See Also:
TreeWalkerImpl

setIndent

public void setIndent(boolean indent)
Set the number of space characters used for indent

Parameters:
indent - the number of space characters used for indent

setEscapeTagBracket

public void setEscapeTagBracket(boolean escapeTagBracket)
Determine to escape Tag bracket ('<','>') or not. Please set true if you want to print out DOM into <pre> section of HTML.

Parameters:
escapeTagBracket - if true, print Tag bracket as escaped format ('&lt;', '&gt;')

setAttrFilter

public void setAttrFilter(DomPrintUtil.AttributeFilter attrFilter)
Set AttributeFilter to define the behavior for printing attributes of each Element.

Parameters:
attrFilter - the AttributeFilter to set

writeToFile

public void writeToFile(String filePath)
                 throws IOException
Print out the target Document.

Parameters:
filePath - the target file path
Throws:
IOException

writeToFile

public void writeToFile(File file)
                 throws IOException
Print out the target Document.

Parameters:
file - the target File
Throws:
IOException

writeToFile

public void writeToFile(String filePath,
                        String encode)
                 throws IOException
Print out the target Document in specified encoding

Parameters:
filePath - the target file path
encode - the target encoding
Throws:
IOException

writeToFile

public void writeToFile(File file,
                        String encode)
                 throws IOException
Print out the target Document in specified encoding

Parameters:
file - the target file
encode - the target encoding
Throws:
IOException