Class AnakiaElement
- All Implemented Interfaces:
Serializable,Cloneable,org.jdom.Parent
Element that is tailored for Anakia needs. It has
selectNodes(String) method as well as a toString() that
outputs the XML serialized form of the element. This way it acts in much the
same way as a single-element NodeList would.- Version:
- $Id: AnakiaElement.java 463298 2006-10-12 16:10:32Z henning $
- Author:
- Attila Szegedi
- See Also:
-
Field Summary
Fields inherited from class org.jdom.Element
additionalNamespaces, name, namespaceFields inherited from class org.jdom.Content
parent -
Constructor Summary
ConstructorsConstructorDescriptionAnakiaElement(String name) This will create anAnakiaElementin no.NamespaceAnakiaElement(String name, String uri) This will create a newAnakiaElementwith the supplied (local) name, and specifies the URI of thetheNamespaceElementshould be in, resulting it being unprefixed (in the default namespace).AnakiaElement(String name, String prefix, String uri) This will create a newAnakiaElementwith the supplied (local) name, and specifies the prefix and URI of thetheNamespaceElementshould be in.AnakiaElement(String name, org.jdom.Namespace namespace) This will create a newAnakiaElementwith the supplied (local) name, and define theto be used.Namespace -
Method Summary
Modifier and TypeMethodDescriptionThis returns the complete set of attributes for this element, as aNodeListofAttributeobjects in no particular order, or an empty list if there are none.This returns aNodeListof all the child elements nested directly (one level deep) within this element, asElementobjects.getChildren(String name) This returns aNodeListof all the child elements nested directly (one level deep) within this element with the given local name and belonging to no namespace, returned asElementobjects.getChildren(String name, org.jdom.Namespace ns) This returns aNodeListof all the child elements nested directly (one level deep) within this element with the given local name and belonging to the given Namespace, returned asElementobjects.This returns the full content of the element as a NodeList which may contain objects of typeString,Element,Comment,ProcessingInstruction,CDATA, andEntityRef.selectNodes(String xpathExpression) Applies an XPath expression to this element and returns the resulting node list.toString()Returns the XML serialized form of this element, as produced by the defaultXMLOutputter.Methods inherited from class org.jdom.Element
addContent, addContent, addContent, addContent, addContent, addNamespaceDeclaration, clone, cloneContent, getAdditionalNamespaces, getAttribute, getAttribute, getAttributeValue, getAttributeValue, getAttributeValue, getAttributeValue, getChild, getChild, getChildText, getChildText, getChildTextNormalize, getChildTextNormalize, getChildTextTrim, getChildTextTrim, getContent, getContent, getContentSize, getDescendants, getDescendants, getName, getNamespace, getNamespace, getNamespacePrefix, getNamespaceURI, getQualifiedName, getText, getTextNormalize, getTextTrim, getValue, indexOf, isAncestor, isRootElement, removeAttribute, removeAttribute, removeAttribute, removeChild, removeChild, removeChildren, removeChildren, removeContent, removeContent, removeContent, removeContent, removeNamespaceDeclaration, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setContent, setContent, setContent, setContent, setName, setNamespace, setTextMethods inherited from class org.jdom.Content
detach, equals, getDocument, getParent, getParentElement, hashCode, setParentMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jdom.Parent
getDocument, getParent
-
Constructor Details
-
AnakiaElement
This will create a new
AnakiaElementwith the supplied (local) name, and define theto be used. If the provided namespace is null, the element will have no namespace.Namespace- Parameters:
name-Stringname of element.namespace-Namespaceto put element in.
-
AnakiaElement
This will create an
AnakiaElementin no.Namespace- Parameters:
name-Stringname of element.
-
AnakiaElement
This will create a new
AnakiaElementwith the supplied (local) name, and specifies the URI of thetheNamespaceElementshould be in, resulting it being unprefixed (in the default namespace).- Parameters:
name-Stringname of element.uri-StringURI forNamespaceelement should be in.
-
AnakiaElement
This will create a new
AnakiaElementwith the supplied (local) name, and specifies the prefix and URI of thetheNamespaceElementshould be in.- Parameters:
name-Stringname of element.prefix- The prefix of the element.uri-StringURI forNamespaceelement should be in.
-
-
Method Details
-
selectNodes
Applies an XPath expression to this element and returns the resulting node list. In order for this method to work, your application must have access to werken.xpath library classes. The implementation does cache the parsed format of XPath expressions in a weak hash map, keyed by the string representation of the XPath expression. As the string object passed as the argument is usually kept in the parsed template, this ensures that each XPath expression is parsed only once during the lifetime of the template that first invoked it.- Parameters:
xpathExpression- the XPath expression you wish to apply- Returns:
- a NodeList representing the nodes that are the result of application of the XPath to the current element. It can be empty.
-
toString
Returns the XML serialized form of this element, as produced by the defaultXMLOutputter.- Overrides:
toStringin classorg.jdom.Element- Returns:
- The XML serialized form of this element, as produced by the default
XMLOutputter.
-
getContent
This returns the full content of the element as a NodeList which may contain objects of type
String,Element,Comment,ProcessingInstruction,CDATA, andEntityRef. The List returned is "live" in document order and modifications to it affect the element's actual contents. Whitespace content is returned in its entirety.- Specified by:
getContentin interfaceorg.jdom.Parent- Overrides:
getContentin classorg.jdom.Element- Returns:
- a
Listcontaining the mixed content of the element: may containString,,Element,Comment,ProcessingInstruction, andCDATAobjects.EntityRef
-
getChildren
This returns a
NodeListof all the child elements nested directly (one level deep) within this element, asElementobjects. If this target element has no nested elements, an empty List is returned. The returned list is "live" in document order and 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 }- Overrides:
getChildrenin classorg.jdom.Element- Returns:
- list of child
Elementobjects for this element
-
getChildren
This returns a
NodeListof all the child elements nested directly (one level deep) within this element with the given local name and belonging to no namespace, returned asElementobjects. If this target element has no nested elements with the given name outside a namespace, an empty List is returned. The returned list is "live" in document order and changes to it affect the element's actual contents.Please see the notes for
for a code example.getChildren()- Overrides:
getChildrenin classorg.jdom.Element- Parameters:
name- local name for the children to match- Returns:
- all matching child elements
-
getChildren
This returns a
NodeListof all the child elements nested directly (one level deep) within this element with the given local name and belonging to the given Namespace, returned asElementobjects. If this target element has no nested elements with the given name in the given Namespace, an empty List is returned. The returned list is "live" in document order and changes to it affect the element's actual contents.Please see the notes for
for a code example.getChildren()- Overrides:
getChildrenin classorg.jdom.Element- Parameters:
name- local name for the children to matchns-Namespaceto search within- Returns:
- all matching child elements
-
getAttributes
This returns the complete set of attributes for this element, as a
NodeListofAttributeobjects in no particular order, or an empty list if there are none. The returned list is "live" and changes to it affect the element's actual attributes.- Overrides:
getAttributesin classorg.jdom.Element- Returns:
- attributes for the element
-