com.lexonics.edsel
Class Attribute

java.lang.Object
  extended bycom.lexonics.edsel.Attribute

public final class Attribute
extends Object

An Edsel attribute. An Attribute has a name and a value list. The name is a valid Edsel identifier; that is, it is a non-null, non-empty String that contains no characters other than upper- and lowercase ASCII letters, digits, and hyphens. Names beginning with hyphens are reserved. By convention, attribute names are lowercase words separated by hyphens. The value list is a non-null List of Strings. Attributes are immutable.


Constructor Summary
Attribute(String name)
          Construct an Attribute with a given name and an empty value list.
Attribute(String name, List valueList)
          Construct an Attribute with a given name and value list.
Attribute(String name, String value)
          Construct an Attribute with a given name and a value list containing a single value.
 
Method Summary
 boolean equals(Object o)
          Compare a given object with this Attribute for equality.
 int hashCode()
          Return the hash code value for this Attribute.
 String name()
          Return the name of this Attribute.
 String toString()
          Return a string representation of this Attribute.
 List valueList()
          Return a shallow copy of the value list of this Attribute.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(String name)
Construct an Attribute with a given name and an empty value list.

Parameters:
name - The name of the Attribute. Must be a valid Edsel identifier.
Throws:
IllegalArgumentException - The name is not a valid Edsel identifier.

Attribute

public Attribute(String name,
                 String value)
Construct an Attribute with a given name and a value list containing a single value.

Parameters:
name - The name of the Attribute. Must be a valid Edsel identifier.
value - The value. Must be non-null.
Throws:
IllegalArgumentException - The name is not a valid Edsel identifier, or the value is null.

Attribute

public Attribute(String name,
                 List valueList)
Construct an Attribute with a given name and value list.

Parameters:
name - The name of the Attribute. Must be a valid Edsel identifier.
valueList - The value list of the Attribute. Must be a non-null List of Strings. This list is copied by a shallow copy, to guarantee Attribute immutability.
Throws:
IllegalArgumentException - The name is not a valid Edsel identifier, the value list is null, or an element of the value list is not a String.
Method Detail

equals

public boolean equals(Object o)
Compare a given object with this Attribute for equality. Return true if the given object is also an Attribute, and the two Attributes have equal names and value lists.

Parameters:
o - The object.
Returns:
true if the object is equal to this Attribute.

hashCode

public int hashCode()
Return the hash code value for this Attribute. The hash code of an Attribute is defined to be the sum of the hash codes of its name and value list.

Returns:
The hash code value for this Attribute.

name

public String name()
Return the name of this Attribute.

Returns:
The name of this Attribute.

toString

public String toString()
Return a string representation of this Attribute.

Returns:
The string representation. Any backslash or single quote in a value in the value list is escaped by a backslash.

valueList

public List valueList()
Return a shallow copy of the value list of this Attribute.

Returns:
A shallow copy of value list of this Attribute.


Copyright, 2003
Lexonics, Inc.
All Rights Reserved