org.codehaus.cargo.module
Class AbstractDescriptor

java.lang.Object
  extended by org.jdom.Document
      extended by org.codehaus.cargo.module.AbstractDescriptor
All Implemented Interfaces:
Serializable, Cloneable, Descriptor, org.jdom.Parent
Direct Known Subclasses:
ApplicationXml, EjbJarXml, IbmEjbJarBndXmi, IbmWebBndXmi, JBossWebXml, JBossXml, OrionEjbJarXml, OrionWebXml, ResinWebXml, TomcatContextXml, WeblogicEjbJarXml, WeblogicXml, WebXml

public abstract class AbstractDescriptor
extends org.jdom.Document
implements Descriptor

Encapsulates the DOM representation of a deployment descriptor to provide convenience methods for easy access and manipulation.

Version:
$Id: AbstractDescriptor.java 1705 2008-09-02 13:14:55Z adriana $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jdom.Document
baseURI
 
Constructor Summary
AbstractDescriptor(org.jdom.Element rootElement, DescriptorType descriptorType)
          Constructor.
 
Method Summary
 org.jdom.Element addElement(DescriptorTag tag, org.jdom.Element child, org.jdom.Element parent)
          Adds an element of the specified tag to the descriptor.
protected  void checkElement(org.jdom.Element element, DescriptorTag expectedTag)
          Checks an element whether its name matches the specified name.
protected  org.jdom.Element createNestedText(DescriptorTag tag, String text)
          Creates an element that contains nested text.
protected  String getChildText(org.jdom.Element parent, DescriptorTag tag)
          Returns the text value from a child directly under the parent tag.
protected  String getChildText(org.jdom.Element parent, String tagName)
          Returns the text value from a child directly under the parent tag.
 DescriptorType getDescriptorType()
          Get the descriptor type for this descriptor.
 org.jdom.Document getDocument()
          Return the representation as a document.
 Iterator getElements(DescriptorTag tag)
          Returns an iterator over the elements that match the specified tag.
 Iterator getElements(String tagName)
          Returns an iterator over the elements that match the specified tag.
protected  org.jdom.Element getImmediateChild(org.jdom.Element parent, DescriptorTag tag)
          Gets a certain tag directly under the parent tag.
protected  org.jdom.Element getInsertionPointFor(DescriptorTag tag, String parent)
          Returns the node before which the specified tag should be inserted, or null if the node should be inserted at the end of the descriptor.
protected  Iterator getNestedElements(org.jdom.Element parent, DescriptorTag tag)
          Returns an iterator over the child elements of the specified element that match the specified tag.
protected  String getNestedText(org.jdom.Element parent, DescriptorTag tag)
          Returns the text nested inside a child element of the specified element.
 org.jdom.Element getTagByIdentifier(DescriptorTag tag, String value)
          Get elements of a particular descriptor tag whose identifier matches the passed parameter.
 org.jdom.Element getTagByIdentifier(String tagName, String value)
          Get elements of a particular descriptor tag whose identifier matches the passed parameter.
 List getTags(DescriptorTag tag)
          Get tags of a particular type.
 List getTags(String tagName)
          Get tags of a particular type.
protected  String getText(org.jdom.Element element)
          Returns the text value of an element.
 
Methods inherited from class org.jdom.Document
addContent, addContent, addContent, addContent, clone, cloneContent, detachRootElement, equals, getBaseURI, getContent, getContent, getContent, getContentSize, getDescendants, getDescendants, getDocType, getParent, getProperty, getRootElement, hashCode, hasRootElement, indexOf, removeContent, removeContent, removeContent, removeContent, setBaseURI, setContent, setContent, setContent, setContent, setDocType, setProperty, setRootElement, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.codehaus.cargo.module.Descriptor
getFileName, getRootElement
 
Methods inherited from interface org.jdom.Parent
clone, cloneContent, getContent, getContent, getContent, getContentSize, getDescendants, getDescendants, getParent, indexOf, removeContent, removeContent, removeContent, removeContent
 

Constructor Detail

AbstractDescriptor

public AbstractDescriptor(org.jdom.Element rootElement,
                          DescriptorType descriptorType)
Constructor.

Parameters:
rootElement - The root element of the document
descriptorType - The type of the descriptor
Method Detail

getDocument

public org.jdom.Document getDocument()
Return the representation as a document.

Specified by:
getDocument in interface Descriptor
Specified by:
getDocument in interface org.jdom.Parent
Overrides:
getDocument in class org.jdom.Document
Returns:
JDOM Document

getTags

public List getTags(DescriptorTag tag)
Get tags of a particular type.

Specified by:
getTags in interface Descriptor
Parameters:
tag - type of elements to find
Returns:
list of tags

getTags

public List getTags(String tagName)
Get tags of a particular type.

Parameters:
tagName - type of elements to find
Returns:
list of tags

getElements

public Iterator getElements(DescriptorTag tag)
Returns an iterator over the elements that match the specified tag.

Parameters:
tag - The descriptor tag of which the elements should be returned
Returns:
An iterator over the elements matching the tag, in the order they occur in the descriptor

getElements

public Iterator getElements(String tagName)
Returns an iterator over the elements that match the specified tag.

Parameters:
tagName - The name of a descriptor tag of which the elements should be returned
Returns:
An iterator over the elements matching the tag, in the order they occur in the descriptor

checkElement

protected void checkElement(org.jdom.Element element,
                            DescriptorTag expectedTag)
                     throws IllegalArgumentException
Checks an element whether its name matches the specified name.

Parameters:
element - The element to check
expectedTag - The expected tag name
Throws:
IllegalArgumentException - If the element name doesn't match

getNestedElements

protected Iterator getNestedElements(org.jdom.Element parent,
                                     DescriptorTag tag)
Returns an iterator over the child elements of the specified element that match the specified tag.

Parameters:
parent - The element of which the nested elements should be retrieved
tag - The descriptor tag of which the elements should be returned
Returns:
An iterator over the elements matching the tag, in the order they occur in the descriptor

createNestedText

protected org.jdom.Element createNestedText(DescriptorTag tag,
                                            String text)
Creates an element that contains nested text.

Parameters:
tag - The tag to create an instance of
text - The text that should be nested in the element
Returns:
The created DOM element

getNestedText

protected String getNestedText(org.jdom.Element parent,
                               DescriptorTag tag)
Returns the text nested inside a child element of the specified element.

Parameters:
parent - The element of which the nested text should be returned
tag - The descriptor tag in which the text is nested
Returns:
The text nested in the element

getText

protected String getText(org.jdom.Element element)
Returns the text value of an element.

Parameters:
element - the element of wich the text value should be returned
Returns:
the text value of an element

getImmediateChild

protected org.jdom.Element getImmediateChild(org.jdom.Element parent,
                                             DescriptorTag tag)
Gets a certain tag directly under the parent tag.

Parameters:
parent - the tag to get the cild from
tag - name of the child tag
Returns:
tag directly under the parent tag.

getChildText

protected String getChildText(org.jdom.Element parent,
                              DescriptorTag tag)
Returns the text value from a child directly under the parent tag.

Parameters:
parent - the parent tag to get the child text from
tag - the name of the child tag
Returns:
the text value of a child tag directly under the parent tag

getChildText

protected String getChildText(org.jdom.Element parent,
                              String tagName)
Returns the text value from a child directly under the parent tag.

Parameters:
parent - the parent tag to get the child text from
tagName - the name of the child tag
Returns:
the text value of a child tag directly under the parent tag

addElement

public org.jdom.Element addElement(DescriptorTag tag,
                                   org.jdom.Element child,
                                   org.jdom.Element parent)
Adds an element of the specified tag to the descriptor.

Specified by:
addElement in interface Descriptor
Parameters:
tag - The descriptor tag
child - The child element to add
parent - The parent element to add the child to
Returns:
the inserted element

getInsertionPointFor

protected org.jdom.Element getInsertionPointFor(DescriptorTag tag,
                                                String parent)
Returns the node before which the specified tag should be inserted, or null if the node should be inserted at the end of the descriptor.

Parameters:
tag - The tag that should be inserted
parent - name of the parent tag
Returns:
The node before which the tag can be inserted

getDescriptorType

public DescriptorType getDescriptorType()
Description copied from interface: Descriptor
Get the descriptor type for this descriptor.

Specified by:
getDescriptorType in interface Descriptor
Returns:
the descriptorType

getTagByIdentifier

public org.jdom.Element getTagByIdentifier(DescriptorTag tag,
                                           String value)
Get elements of a particular descriptor tag whose identifier matches the passed parameter.

Specified by:
getTagByIdentifier in interface Descriptor
Parameters:
tag - tag to search for
value - value for the identifier to match
Returns:
the element that matches

getTagByIdentifier

public org.jdom.Element getTagByIdentifier(String tagName,
                                           String value)
Get elements of a particular descriptor tag whose identifier matches the passed parameter.

Parameters:
tagName - Name of the tag to search for
value - value for the identifier to match
Returns:
the element that matches


Copyright © 2004-2012 Codehaus. All Rights Reserved.