Top Description Constructors Methods
org.apache.tools.ant.util

public Class DOMUtils

extends Object
Class Inheritance
Imports
org.w3c.dom.CDATASection, .Document, .Element, .Text

Some utility methods for common tasks when building DOM trees in memory.

In this documentation <a> means an Element instance with name a.

Since
Ant 1.6.3

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
appendCDATA(Element
element that will receive the new element as child.
parent
,
String
text content.
content
)

Adds a nested CDATA section.

public static void
appendCDATAElement(Element
element that will receive the new element as child.
parent
,
String
of the child element.
name
,
String
text content.
content
)

Adds a nested CDATA section in a new child element.

public static void
appendText(Element
element that will receive the new element as child.
parent
,
String
text content.
content
)

Adds nested text.

public static void
appendTextElement(Element
element that will receive the new element as child.
parent
,
String
of the child element.
name
,
String
text content.
content
)

Adds nested text in a new child element.

public static Element

Returns:

the new element.
createChildElement
(Element
element that will receive the new element as child.
parent
,
String
name of the new element.
name
)

Creates a named Element and appends it to the given element, returns it.

public static Document

Returns:

the document.
newDocument
()

Get a new Document instance,

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DOMUtilsback to summary
private DOMUtils()

Method Detail

appendCDATAback to summary
public static void appendCDATA(Element parent, String content)

Adds a nested CDATA section.

This means

appendCDATA(<a>, "b")
creates
<a><[!CDATA[b]]></a>
Parameters
parent:Element

element that will receive the new element as child.

content:String

text content.

Since
Ant 1.6.3
appendCDATAElementback to summary
public static void appendCDATAElement(Element parent, String name, String content)

Adds a nested CDATA section in a new child element.

This means

appendCDATAElement(<a>, "b", "c")
creates
<a>
  <b><![CDATA[c]]></b>
</a>
Parameters
parent:Element

element that will receive the new element as child.

name:String

of the child element.

content:String

text content.

Since
Ant 1.6.3
appendTextback to summary
public static void appendText(Element parent, String content)

Adds nested text.

This means

appendText(<a>, "b")
creates
<a>b</a>
Parameters
parent:Element

element that will receive the new element as child.

content:String

text content.

Since
Ant 1.6.3
appendTextElementback to summary
public static void appendTextElement(Element parent, String name, String content)

Adds nested text in a new child element.

This means

appendTextElement(<a>, "b", "c")
creates
<a>
  <b>c</b>
</a>
Parameters
parent:Element

element that will receive the new element as child.

name:String

of the child element.

content:String

text content.

Since
Ant 1.6.3
createChildElementback to summary
public static Element createChildElement(Element parent, String name)

Creates a named Element and appends it to the given element, returns it.

This means

createChildElement(<a>, "b")
creates
<a>
  <b/>
</a>
and returns <b>.
Parameters
parent:Element

element that will receive the new element as child.

name:String

name of the new element.

Returns:Element

the new element.

Since
Ant 1.6.3
newDocumentback to summary
public static Document newDocument()

Get a new Document instance,

Returns:Document

the document.

Since
Ant 1.6.3