|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.xml.Element
A wrapper class that implements some functionality of
org.jdom.Element
using org.w3c.dom.Element
.
Field Summary | |
protected org.w3c.dom.Element |
m_element
|
static String |
versionId
|
Constructor Summary | |
protected |
Element()
Protected constructor to set up factories, etc. |
|
Element(String name)
Creates a new element with the given name and no assigned namespace. |
|
Element(String name,
String uri)
Creates a new element with the given name, and assigns it to the namespace defined at uri . |
Method Summary | |
Element |
addAttribute(String name,
String value)
Adds an attribute to the element. |
Element |
addAttribute(String name,
String value,
String ns)
|
Element |
addContent(Element newContent)
Adds a child element to this element. |
String |
getAttribute(String name)
Retrieves an attribute value by name. |
Map |
getAttributes()
|
String |
getCDATASection()
|
List |
getChildren()
Returns a List of all the child elements nested
directly (one level deep) within this element, as Element
objects. |
protected org.w3c.dom.Element |
getInternalElement()
Functions to allow this class to interact appropriately with the Document class (for example, allows nodes to be moved around, and so on). |
String |
getName()
|
String |
getText()
Returns the concatenation of all the text in all child nodes of the current element. |
boolean |
hasAttribute(String name)
|
protected void |
importInto(org.w3c.dom.Document doc)
Imports the internal node into another document. |
Element |
newChildElement(Element copyFrom)
Copies the passed in element and all of its children to a new Element. |
Element |
newChildElement(String name)
Creates a new element and adds it as a child to this element. |
Element |
newChildElement(String name,
Element copyFrom)
Copies the passed in element and all of its children to a new Element using the passed-in name |
Element |
newChildElement(String name,
String uri)
Creates a new element. |
Element |
newChildElement(String name,
String uri,
Element copyFrom)
Copies the passed in element and all of its children to a new Element using the passed-in name |
Element |
setCDATASection(String cdata)
|
Element |
setText(String text)
Sets the text value of the current element (the part between the tags). |
static void |
visitAllAttributes(org.w3c.dom.Node node)
Deprecated. with no replacement, 1 May 2003 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
protected org.w3c.dom.Element m_element
Constructor Detail |
protected Element()
public Element(String name)
name
- the name of the elementpublic Element(String name, String uri)
uri
. The namespace prefix is
automatically determined.
name
- the name of the elementuri
- the URI for the namespace definitionMethod Detail |
public Element newChildElement(String name)
elt.newChildElement("newElt")
is
equivalent to
Element newElt = new Element("newElt"); elt.addChild(newElt);
name
- the name of the element
public Element newChildElement(String name, String uri)
uri
.
elt.newChildElement("newElt", namespace)
is
equivalent to
Element newElt = new Element("newElt", namespace); elt.addChild(newElt);
name
- the name of the Elementuri
- the URI for the namespace definition
public Element newChildElement(Element copyFrom)
public Element newChildElement(String name, Element copyFrom)
public Element newChildElement(String name, String uri, Element copyFrom)
public Element addAttribute(String name, String value)
name
- the name of the attributevalue
- the value of the attribute
public Element addAttribute(String name, String value, String ns)
public Element addContent(Element newContent)
newContent
- the new child element
public Element setText(String text)
text
- the text to include
public String getText()
public Element setCDATASection(String cdata)
public String getCDATASection()
public List getChildren()
List
of all the child elements nested
directly (one level deep) within this element, as Element
objects. If this target element has no nested elements, an empty
List
is returned. The returned list is "live", so
changes to it affect the element's actual contents.
This performs no recursion, so elements nested two levels deep would have to be obtained with:
Iterator itr = currentElement.getChildren().iterator(); while (itr.hasNext()) { Element oneLevelDeep = (Element)nestedElements.next(); List twoLevelsDeep = oneLevelDeep.getChildren(); // Do something with these children }
Element
objects for this element.public Map getAttributes()
public String getAttribute(String name)
name
- The name of the attribute to retrieve
public boolean hasAttribute(String name)
public String getName()
protected final org.w3c.dom.Element getInternalElement()
protected void importInto(org.w3c.dom.Document doc)
doc
- the org.w3c.dom.Document to import intopublic static void visitAllAttributes(org.w3c.dom.Node node)
node
- the org.w3c.dom.Node about to be imported
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |