AnakiaElement (Velocity 1.4 API)
Keywords: org.apache.velocity.anakia.AnakiaElement class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.velocity.anakia
Class AnakiaElement

    java.lang.Object
      org.jdom.Element
          org.apache.velocity.anakia.AnakiaElement

All Implemented Interfaces:
  java.lang.Cloneable, java.io.Serializable

public class AnakiaElement
extends org.jdom.Element

A JDOM `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,v 1.3.4.1 2004/03/03 23:22:03 geirm Exp $
Author:
  Attila Szegedi
See Also:
  Serialized Form

Field Summary
`private static org.jdom.output.XMLOutputter` | `DEFAULT_OUTPUTTER`

Fields inherited from class org.jdom.Element
`additionalNamespaces, attributes, content, name, namespace, parent`

Constructor Summary
`AnakiaElement(java.lang.String name)` This will create an `AnakiaElement` in no ``Namespace``.
`AnakiaElement(java.lang.String name, org.jdom.Namespace namespace)` This will create a new `AnakiaElement` with the supplied (local) name, and define the ``Namespace`` to be used.
`AnakiaElement(java.lang.String name, java.lang.String uri)` This will create a new `AnakiaElement` with the supplied (local) name, and specifies the URI of the ``Namespace`` the `Element` should be in, resulting it being unprefixed (in the default namespace).
`AnakiaElement(java.lang.String name, java.lang.String prefix, java.lang.String uri)` This will create a new `AnakiaElement` with the supplied (local) name, and specifies the prefix and URI of the ``Namespace`` the `Element` should be in.

Method Summary
`java.util.List` | `getAttributes()` This returns the complete set of attributes for this element, as a `NodeList` of `Attribute` objects in no particular order, or an empty list if there are none.
`java.util.List` | `getChildren()` This returns a `NodeList` of all the child elements nested directly (one level deep) within this element, as `Element` objects.
`java.util.List` | `getChildren(java.lang.String name)` This returns a `NodeList` of all the child elements nested directly (one level deep) within this element with the given local name and belonging to no namespace, returned as `Element` objects.
`java.util.List` | `getChildren(java.lang.String name, org.jdom.Namespace ns)` This returns a `NodeList` of all the child elements nested directly (one level deep) within this element with the given local name and belonging to the given Namespace, returned as `Element` objects.
`java.util.List` | `getContent()` This returns the full content of the element as a NodeList which may contain objects of type `String`, `Element`, `Comment`, `ProcessingInstruction`, `CDATA`, and `EntityRef`.
`NodeList` | `selectNodes(java.lang.String xpathExpression)` Applies an XPath expression to this element and returns the resulting node list.
`java.lang.String` | `toString()` Returns the XML serialized form of this element, as produced by the default `XMLOutputter`.

Methods inherited from class org.jdom.Element
`addContent, addContent, addContent, addContent, addContent, addContent, addNamespaceDeclaration, clone, detach, equals, getAdditionalNamespaces, getAttribute, getAttribute, getAttributeValue, getAttributeValue, getAttributeValue, getAttributeValue, getChild, getChild, getChildText, getChildText, getChildTextNormalize, getChildTextNormalize, getChildTextTrim, getChildTextTrim, getContent, getDocument, getName, getNamespace, getNamespace, getNamespacePrefix, getNamespaceURI, getParent, getQualifiedName, getText, getTextNormalize, getTextTrim, hasChildren, hashCode, isAncestor, isRootElement, removeAttribute, removeAttribute, removeAttribute, removeChild, removeChild, removeChildren, removeChildren, removeChildren, removeContent, removeContent, removeContent, removeContent, removeContent, removeNamespaceDeclaration, setAttribute, setAttribute, setAttribute, setAttributes, setChildren, setContent, setDocument, setName, setNamespace, setParent, setText`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### DEFAULT_OUTPUTTER

    private static final org.jdom.output.XMLOutputter DEFAULT_OUTPUTTER

Constructor Detail

### AnakiaElement

    public AnakiaElement(java.lang.String name,
                         org.jdom.Namespace namespace)

  This will create a new `AnakiaElement` with the supplied (local) name, and define the ``Namespace`` to be used. If the provided namespace is null, the element will have no namespace.

Parameters:
  `name` - `String` name of element.

### AnakiaElement

    public AnakiaElement(java.lang.String name)

  This will create an `AnakiaElement` in no ``Namespace``.

Parameters:
  `name` - `String` name of element.

### AnakiaElement

    public AnakiaElement(java.lang.String name,
                         java.lang.String uri)

  This will create a new `AnakiaElement` with the supplied (local) name, and specifies the URI of the ``Namespace`` the `Element` should be in, resulting it being unprefixed (in the default namespace).

Parameters:
  `name` - `String` name of element.
  `uri` - `String` URI for `Namespace` element should be in.

### AnakiaElement

    public AnakiaElement(java.lang.String name,
                         java.lang.String prefix,
                         java.lang.String uri)

  This will create a new `AnakiaElement` with the supplied (local) name, and specifies the prefix and URI of the ``Namespace`` the `Element` should be in.

Parameters:
  `name` - `String` name of element.
  `uri` - `String` URI for `Namespace` element should be in.

Method Detail

### selectNodes

    public NodeList selectNodes(java.lang.String xpathExpression)

  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

    public java.lang.String toString()

  Returns the XML serialized form of this element, as produced by the default `XMLOutputter`.

### getContent

    public java.util.List getContent()

  This returns the full content of the element as a NodeList which may contain objects of type `String`, `Element`, `Comment`, `ProcessingInstruction`, `CDATA`, and `EntityRef`. 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.

  Returns:
    a `List` containing the mixed content of the element: may contain `String`, ``Element``, ``Comment``, ``ProcessingInstruction``, ``CDATA``, and ``EntityRef`` objects.

### getChildren

    public java.util.List getChildren()

  This returns a `NodeList` 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" 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
         }

  Returns:
    list of child `Element` objects for this element

### getChildren

    public java.util.List getChildren(java.lang.String name)

  This returns a `NodeList` of all the child elements nested directly (one level deep) within this element with the given local name and belonging to no namespace, returned as `Element` objects. 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 ``getChildren()`` for a code example.

  Parameters:
    `name` - local name for the children to match
  Returns:
    all matching child elements

### getChildren

    public java.util.List getChildren(java.lang.String name,
                                      org.jdom.Namespace ns)

  This returns a `NodeList` of all the child elements nested directly (one level deep) within this element with the given local name and belonging to the given Namespace, returned as `Element` objects. 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 ``getChildren()`` for a code example.

  Parameters:
    `name` - local name for the children to match
    `ns` - `Namespace` to search within
  Returns:
    all matching child elements

### getAttributes

    public java.util.List getAttributes()

  This returns the complete set of attributes for this element, as a `NodeList` of `Attribute` objects 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.

  Returns:
    attributes for the element

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 Apache Software Foundation. All Rights Reserved.