org.openspml.message
Class Attribute

java.lang.Object
  |
  +--org.openspml.message.Attribute
Direct Known Subclasses:
Modification

public class Attribute
extends java.lang.Object

A class used to represent an attr element, found in several contexts within SPML.

Currently this is the same as a DSML attribute, though it is likely to be extended to provide a richer set of value types. DSML only allows xsd:string, xsd:base64binary and xsd:anyURI values.

The value is allowed to be any object, but until an extension mechanism is in place, values should be limited to Strings or Lists of Strings. Multi-valued attributes are represented with Lists.


Constructor Summary
Attribute()
           
Attribute(java.lang.String name, java.lang.Object value)
           
 
Method Summary
static Attribute getAttribute(java.util.List attributes, java.lang.String name)
          Utility method to Lookup an attribute by name given a list of attributes.
static java.util.List getAttributes(java.util.Map src)
          Convenience method to build a List of Attribute objects given a Map of name/value pairs.
static java.lang.Object getAttributeValue(java.util.List attributes, java.lang.String name)
          Utility method to Lookup an attribute by name given a list of attributes.
 java.lang.String getName()
           
 java.lang.Object getValue()
           
 void setName(java.lang.String s)
           
 void setValue(java.lang.Object o)
           
static void sort(java.util.List list)
          Utility to sort a list of Attribute objects by name.
static java.util.Map toMap(java.util.List attlist)
          Given a list of Attribute objects, convert them into a Map of names and values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute()

Attribute

public Attribute(java.lang.String name,
                 java.lang.Object value)
Method Detail

setName

public void setName(java.lang.String s)

setValue

public void setValue(java.lang.Object o)

getAttributes

public static java.util.List getAttributes(java.util.Map src)
Convenience method to build a List of Attribute objects given a Map of name/value pairs.

getName

public java.lang.String getName()

getValue

public java.lang.Object getValue()

getAttribute

public static Attribute getAttribute(java.util.List attributes,
                                     java.lang.String name)
Utility method to Lookup an attribute by name given a list of attributes. Used by several classes to search their attribute lists.

// It is assumed this won't happen very often and the lists will // be short. If not, then an intermediate class that maintains // a HashMap may be required.


getAttributeValue

public static java.lang.Object getAttributeValue(java.util.List attributes,
                                                 java.lang.String name)
Utility method to Lookup an attribute by name given a list of attributes. Used by several classes to search their attribute lists.

The actual value of the attribute is returned.


sort

public static void sort(java.util.List list)
Utility to sort a list of Attribute objects by name. Convenient for unit tests cause the attributes to serialize in a predictable order.

toMap

public static java.util.Map toMap(java.util.List attlist)
Given a list of Attribute objects, convert them into a Map of names and values.