it.sauronsoftware.feed4j.bean
Class RawElement

java.lang.Object
  extended by it.sauronsoftware.feed4j.bean.RawElement
All Implemented Interfaces:
RawNode
Direct Known Subclasses:
FeedEnclosure, FeedHeader, FeedImage, FeedItem

public class RawElement
extends java.lang.Object
implements RawNode

This class is used to represent a XML element.

Author:
Carlo Pelliccia

Constructor Summary
RawElement()
           
 
Method Summary
 void addAttribute(RawAttribute attribute)
          This method adds an attribute to the element.
 void addNode(RawNode node)
          This method adds a node to the element.
 RawAttribute getAttribute(int index)
          This method returns an element attribute.
 int getAttributeCount()
          This method returns the number of the element attribute.
 java.lang.String getAttributeValue(java.lang.String namespaceURI, java.lang.String name)
          This method returns the value of an element attribute.
 RawElement getElement(java.lang.String namespaceURI, java.lang.String name)
          This method returns the first occurrence of a wanted sub-element.
 RawElement[] getElements(java.lang.String namespaceURI, java.lang.String name)
          This method returns a set of sub-elements.
 java.lang.String getElementValue(java.lang.String namespaceURI, java.lang.String name)
          This method returns the value of first occurrence of a wanted sub-element.
 java.lang.String getName()
          This method returns the element name.
 java.lang.String getNamespaceURI()
          This method returns the element namespace URI.
 RawNode getNode(int index)
          This method returns an element node.
 int getNodeCount()
          This method returns the number of the nodes in the element.
 java.lang.String getValue()
          This method returns the element value.
 void removeNode(RawNode node)
          This method removes a node from the element.
 void setName(java.lang.String name)
          This method sets the element name.
 void setNamespaceURI(java.lang.String namespaceURI)
          This method sets the element namespace URI.
 void setValue(java.lang.String value)
          This method sets the element value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RawElement

public RawElement()
Method Detail

getName

public java.lang.String getName()
This method returns the element name.

Returns:
The element name.

setName

public void setName(java.lang.String name)
This method sets the element name.

Parameters:
name - The element name.

getNamespaceURI

public java.lang.String getNamespaceURI()
This method returns the element namespace URI.

Returns:
The element namespace URI.

setNamespaceURI

public void setNamespaceURI(java.lang.String namespaceURI)
This method sets the element namespace URI.

Parameters:
namespaceURI - The element namespace URI.

getValue

public java.lang.String getValue()
This method returns the element value.

Returns:
The element value.

setValue

public void setValue(java.lang.String value)
This method sets the element value.

Parameters:
value - The element value.

getAttribute

public RawAttribute getAttribute(int index)
                          throws java.lang.IndexOutOfBoundsException
This method returns an element attribute.

Parameters:
index - The index of the wanted attribute.
Returns:
The element attribute.
Throws:
java.lang.IndexOutOfBoundsException - If the supplied index is not valid. It must be greater or equal to 0 and less than the value returned by getAttributeCount().

addAttribute

public void addAttribute(RawAttribute attribute)
This method adds an attribute to the element.

Parameters:
attribute - The attribute.

getAttributeCount

public int getAttributeCount()
This method returns the number of the element attribute.

Returns:
The number of the element attribute.

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String namespaceURI,
                                          java.lang.String name)
This method returns the value of an element attribute.

Parameters:
namespaceURI - The attribute namespace URI.
name - The attribute name.
Returns:
The value of the attribute, or null if it could not be found.

getNode

public RawNode getNode(int index)
                throws java.lang.IndexOutOfBoundsException
This method returns an element node.

Parameters:
index - The index of the wanted node.
Returns:
The node.
Throws:
java.lang.IndexOutOfBoundsException - If the supplied index is not valid. It must be greater or equal to 0 and less than the value returned by getNodeCount().

getElements

public RawElement[] getElements(java.lang.String namespaceURI,
                                java.lang.String name)
This method returns a set of sub-elements.

Parameters:
namespaceURI - The namespace URI of the wanted elements.
name - The name of the wanted elements.
Returns:
An array with the wanted elements. If no element is found, then a zero-size array is returned.

getElement

public RawElement getElement(java.lang.String namespaceURI,
                             java.lang.String name)
This method returns the first occurrence of a wanted sub-element.

Parameters:
namespaceURI - The namespace URI of the wanted element.
name - The name of the wanted element.
Returns:
The first occurrence of a wanted sub-element, or null if it could not be found.

getElementValue

public java.lang.String getElementValue(java.lang.String namespaceURI,
                                        java.lang.String name)
This method returns the value of first occurrence of a wanted sub-element.

Parameters:
namespaceURI - The namespace URI of the wanted element.
name - The name of the wanted element.
Returns:
The value first occurrence of a wanted sub-element, or null if the element could not be found or if it exists but its value is not textual.

addNode

public void addNode(RawNode node)
This method adds a node to the element.

Parameters:
node - The node.

getNodeCount

public int getNodeCount()
This method returns the number of the nodes in the element.

Returns:
The number of the nodes in the element.

removeNode

public void removeNode(RawNode node)
This method removes a node from the element.

Parameters:
node - The node to remove.