org.jplate.foundation.node.attribute.impl.defaults
Class DefaultAttribute<N,V>

java.lang.Object
  extended by org.jplate.foundation.node.attribute.impl.defaults.DefaultAttribute<N,V>
Type Parameters:
N - The name type of the attribute.
V - The value type of the attribute.
All Implemented Interfaces:
FormattableIfc, AttributeIfc<N,V>

public final class DefaultAttribute<N,V>
extends java.lang.Object
implements AttributeIfc<N,V>

Default implementation of AttributeIfc. It represents an attribute which is a name/value pair. As name uniquely identifies an attribute, its name is immutable through this interface. Values, however, are mutable. Please note: Manipulation of the value is not thread safe.

Modifications:
    $Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $
    $Revision: 479 $
    $Author: sfloess $
    $HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/java/org/jplate/foundation/node/attribute/impl/defaults/DefaultAttribute.java $
    


Field Summary
private  org.apache.commons.logging.Log _log
          Used for logging.
private  N _name
          The name of the attribute.
private  V _value
          The value of the attribute.
private static java.lang.String NAME_IS_NULL_MSG
          Denotes the name is null...
 
Constructor Summary
private DefaultAttribute()
          Default constructor not allowed.
  DefaultAttribute(N name)
          This constructor sets the name the attribute.
 
Method Summary
 boolean equals(java.lang.Object toCompare)
          Returns true if self is equal to toCompare or false if not.
 N getName()
          Returns the name of the attribute.
 V getValue()
          Returns the value of the attribute.
 int hashCode()
          Returns the hash code representation of self.
 void setValue(V value)
          Sets the value of the attribute.
 java.lang.String toString()
          Returns a string representation of self.
 java.lang.String toString(java.lang.String prepend)
          Returns a string representation of self prepending prepend to each line.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NAME_IS_NULL_MSG

private static final java.lang.String NAME_IS_NULL_MSG
Denotes the name is null...

See Also:
Constant Field Values

_log

private final transient org.apache.commons.logging.Log _log
Used for logging.


_name

private final N _name
The name of the attribute.


_value

private V _value
The value of the attribute.

Constructor Detail

DefaultAttribute

public DefaultAttribute(N name)
This constructor sets the name the attribute.

Parameters:
name - The name of the attribute.
Throws:
java.lang.IllegalArgumentException - if name is null.

DefaultAttribute

private DefaultAttribute()
Default constructor not allowed.

Throws:
java.lang.UnsupportedOperationException - If this constructor is called.
Method Detail

hashCode

public int hashCode()
Returns the hash code representation of self.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of self.

equals

public boolean equals(java.lang.Object toCompare)
Returns true if self is equal to toCompare or false if not.

Overrides:
equals in class java.lang.Object
Parameters:
toCompare - The object to compare self for equality.
Returns:
true If self equal to toCompare or false if not.

toString

public java.lang.String toString()
Returns a string representation of self.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of self.

toString

public java.lang.String toString(java.lang.String prepend)
Returns a string representation of self prepending prepend to each line.

Specified by:
toString in interface FormattableIfc
Parameters:
prepend - The text to prepend to each line as defined in the return value.
Returns:
A string representation of self who has prepend prepended to each line.

getName

public N getName()
Returns the name of the attribute.

Specified by:
getName in interface AttributeIfc<N,V>
Returns:
the name of the attribute.

getValue

public V getValue()
Returns the value of the attribute.

Specified by:
getValue in interface AttributeIfc<N,V>
Returns:
the value of the attribute.

setValue

public void setValue(V value)
Sets the value of the attribute.

Specified by:
setValue in interface AttributeIfc<N,V>
Parameters:
value - represents the new value of the attribute.