| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.tools.ant.util.DOMElementWriter
public class DOMElementWriter
Writes a DOM tree to a given Writer. warning: this utility currently does not declare XML Namespaces.
Utility class used by XmlLogger and
 org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter
 XMLJUnitResultFormatter}.
| Nested Class Summary | |
|---|---|
| static class | DOMElementWriter.XmlNamespacePolicyWhether namespaces should be ignored for elements and attributes. | 
| Field Summary | |
|---|---|
| protected  java.lang.String[] | knownEntitiesDon't try to be too smart but at least recognize the predefined entities. | 
| Constructor Summary | |
|---|---|
| DOMElementWriter()Create an element writer. | |
| DOMElementWriter(boolean xmlDeclaration)Create an element writer XML namespaces will be ignored. | |
| DOMElementWriter(boolean xmlDeclaration,
                 DOMElementWriter.XmlNamespacePolicy namespacePolicy)Create an element writer XML namespaces will be ignored. | |
| Method Summary | |
|---|---|
|  void | closeElement(org.w3c.dom.Element element,
             java.io.Writer out,
             int indent,
             java.lang.String indentWith,
             boolean hasChildren)Writes a DOM tree to a stream. | 
|  java.lang.String | encode(java.lang.String value)Escape <, > & ', " as their entities and drop characters that are illegal in XML documents. | 
|  java.lang.String | encodeAttributeValue(java.lang.String value)Escape <, > & ', " as their entities, \n, \r and \t as numeric entities and drop characters that are illegal in XML documents. | 
|  java.lang.String | encodedata(java.lang.String value)Drop characters that are illegal in XML documents. | 
|  void | encodedata(java.io.Writer out,
           java.lang.String value)Drop characters that are illegal in XML documents and write the rest to the given writer. | 
|  boolean | isLegalCharacter(char c)Is the given character allowed inside an XML document? | 
|  boolean | isReference(java.lang.String ent)Is the given argument a character or entity reference? | 
|  void | openElement(org.w3c.dom.Element element,
            java.io.Writer out,
            int indent,
            java.lang.String indentWith)Writes the opening tag - including all attributes - corresponding to a DOM element. | 
|  void | openElement(org.w3c.dom.Element element,
            java.io.Writer out,
            int indent,
            java.lang.String indentWith,
            boolean hasChildren)Writes the opening tag - including all attributes - corresponding to a DOM element. | 
|  void | write(org.w3c.dom.Element root,
      java.io.OutputStream out)Writes a DOM tree to a stream in UTF8 encoding. | 
|  void | write(org.w3c.dom.Element element,
      java.io.Writer out,
      int indent,
      java.lang.String indentWith)Writes a DOM tree to a stream. | 
|  void | writeXMLDeclaration(java.io.Writer wri)Writes the XML declaration if xmlDeclaration is true. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
protected java.lang.String[] knownEntities
| Constructor Detail | 
|---|
public DOMElementWriter()
public DOMElementWriter(boolean xmlDeclaration)
xmlDeclaration - flag to indicate whether the ?xml? declaration
 should be included.
public DOMElementWriter(boolean xmlDeclaration,
                        DOMElementWriter.XmlNamespacePolicy namespacePolicy)
xmlDeclaration - flag to indicate whether the ?xml? declaration
 should be included.namespacePolicy - the policy to use.| Method Detail | 
|---|
public void write(org.w3c.dom.Element root,
                  java.io.OutputStream out)
           throws java.io.IOException
root - the root element of the DOM tree.out - the outputstream to write to.
java.io.IOException - if an error happens while writing to the stream.
public void writeXMLDeclaration(java.io.Writer wri)
                         throws java.io.IOException
wri - the writer to write to.
java.io.IOException - if there is an error.
public void write(org.w3c.dom.Element element,
                  java.io.Writer out,
                  int indent,
                  java.lang.String indentWith)
           throws java.io.IOException
element - the Root DOM element of the treeout - where to send the outputindent - number ofindentWith - string that should be used to indent the
 corresponding tag.
java.io.IOException - if an error happens while writing to the stream.
public void openElement(org.w3c.dom.Element element,
                        java.io.Writer out,
                        int indent,
                        java.lang.String indentWith)
                 throws java.io.IOException
element - the DOM element to writeout - where to send the outputindent - number ofindentWith - string that should be used to indent the
 corresponding tag.
java.io.IOException - if an error happens while writing to the stream.
public void openElement(org.w3c.dom.Element element,
                        java.io.Writer out,
                        int indent,
                        java.lang.String indentWith,
                        boolean hasChildren)
                 throws java.io.IOException
element - the DOM element to writeout - where to send the outputindent - number ofindentWith - string that should be used to indent the
 corresponding tag.hasChildren - whether this element has children.
java.io.IOException - if an error happens while writing to the stream.
public void closeElement(org.w3c.dom.Element element,
                         java.io.Writer out,
                         int indent,
                         java.lang.String indentWith,
                         boolean hasChildren)
                  throws java.io.IOException
element - the Root DOM element of the treeout - where to send the outputindent - number ofindentWith - string that should be used to indent the
 corresponding tag.hasChildren - if true indent.
java.io.IOException - if an error happens while writing to the stream.public java.lang.String encode(java.lang.String value)
value - the string to encode.
public java.lang.String encodeAttributeValue(java.lang.String value)
value - the string to encode.
public java.lang.String encodedata(java.lang.String value)
Also ensure that we are not including an ]]>
 marker by replacing that sequence with
 ]]>.
See XML 1.0 2.2 http://www.w3.org/TR/1998/REC-xml-19980210#charsets and 2.7 http://www.w3.org/TR/1998/REC-xml-19980210#sec-cdata-sect.
value - the value to be encoded.
public void encodedata(java.io.Writer out,
                       java.lang.String value)
                throws java.io.IOException
Also ensure that we are not including an ]]>
 marker by replacing that sequence with
 ]]>.
See XML 1.0 2.2 http://www.w3.org/TR/1998/REC-xml-19980210#charsets and 2.7 http://www.w3.org/TR/1998/REC-xml-19980210#sec-cdata-sect.
value - the value to be encoded.out - where to write the encoded data to.
java.io.IOExceptionpublic boolean isReference(java.lang.String ent)
ent - the value to be checked.
public boolean isLegalCharacter(char c)
See XML 1.0 2.2 http://www.w3.org/TR/1998/REC-xml-19980210#charsets.
c - the character to test.
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||