org.apache.cocoon.components.elementprocessor.types
Class Attribute

java.lang.Object
  extended by org.apache.cocoon.components.elementprocessor.types.Attribute

public class Attribute
extends Object

Encapsulation of a single XML element attribute in a way that shields the consumer from the data's XML origins.

Version:
CVS $Id: Attribute.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Marc Johnson (marc_johnson27591@hotmail.com)

Constructor Summary
Attribute(String name, String value)
          Constructor
 
Method Summary
 String getName()
          Get the name of the Attribute.
 String getValue()
          Get the value of the Attribute as a String.
 boolean getValueAsBoolean()
          A convenience method to get the value of the attribute as a boolean.
 int getValueAsInt()
          A convenience method to get the value of the Attribute as an int.
 long getValueAsLong()
          A convenience method to get the value of the Attribute as a long.
 short getValueAsShort()
          A convenience method to get the value of the Attribute as a short.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(String name,
                 String value)
Constructor

Parameters:
name - the name of the Attribute, the left hand side of the '=' of an XML element's attribute.
value - the value of the Attribute, the right hand side of the '=' of an XML element's attribute.
Throws:
IllegalArgumentException - is thrown if name is null or empty, or if value is null.
Method Detail

getName

public String getName()
Get the name of the Attribute.

Returns:
the name of the Attribute

getValue

public String getValue()
Get the value of the Attribute as a String.

Returns:
the value of the Attribute as a String

getValueAsInt

public int getValueAsInt()
A convenience method to get the value of the Attribute as an int.

Returns:
the value of the Attribute as an int
Throws:
NumberFormatException - if the value is not an int

getValueAsShort

public short getValueAsShort()
A convenience method to get the value of the Attribute as a short.

Returns:
the value of the Attribute as a short
Throws:
NumberFormatException - if the value is not a short

getValueAsLong

public long getValueAsLong()
A convenience method to get the value of the Attribute as a long.

Returns:
the value of the Attribute as a long
Throws:
NumberFormatException - if the value is not a long

getValueAsBoolean

public boolean getValueAsBoolean()
A convenience method to get the value of the attribute as a boolean. Understands these value strings in a case-insensitive fashion:

Returns:
the value of the Attribute as a boolean
Throws:
IllegalArgumentException - if the value does not represent a boolean


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.