Business Objects
Quark Platform Documentation
Version 1.7.0_0
Business Objects

org.openquark.util.attributes
Class Attribute

java.lang.Object
  extended by org.openquark.util.attributes.Attribute

public final class Attribute
extends Object

An Attribute is an association of a String (the name) and an Object (the value, or list of values). This class is immutable.


Nested Class Summary
static class Attribute.Type
          Attribute type constants
 
Constructor Summary
Attribute(String name, AttributeSet attrSet)
          Attribute constructor.
Attribute(String name, boolean boolVal)
          Attribute constructor.
Attribute(String name, Collection<?> values)
          Attribute constructor.
Attribute(String name, Color colour)
          Attribute constructor.
Attribute(String name, double doubleVal)
          Attribute constructor.
Attribute(String name, int intVal)
          Attribute constructor.
Attribute(String name, Object value)
          Attribute constructor.
Attribute(String name, String stringVal)
          Attribute constructor.
Attribute(String name, Time timeVal)
          Attribute constructor.
 
Method Summary
static boolean equalNames(String s1, String s2)
          A method to correctly compare 2 attribute names.
 boolean equals(Object obj)
           
 Attribute.Type getAttributeType()
          Returns the Attribute.Type enum
 int getAttributeTypeOrdinal()
          Deprecated.  
 String getName()
          Returns the attribute name.
static Comparator<Attribute> getNameComparator()
          Returns a Comparator that compares two attributes by their names.
 Object getSingleValue()
          Returns a single value for the attribute.
 List<?> getValues()
          Returns the list of values for the attribute.
 int hashCode()
           
protected  boolean isSupportedAttributeType(Class<?> valueClass)
          Returns whether the specified value type can be stored as an attribute value.
static Attribute Load(Element attrElement)
          Load the attribute from the specified XML element.
static Attribute makeAttribute(String name, List<?> values)
          Creates a new attribute with the specified name and value list.
 void store(Element parentElem)
          Store the attribute in the specified XML element.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(String name,
                 Color colour)
Attribute constructor.

Parameters:
name - the attribute name
colour - the attribute value

Attribute

public Attribute(String name,
                 boolean boolVal)
Attribute constructor.

Parameters:
name - the attribute name
boolVal - the attribute value

Attribute

public Attribute(String name,
                 int intVal)
Attribute constructor.

Parameters:
name - the attribute name
intVal - the attribute value

Attribute

public Attribute(String name,
                 double doubleVal)
Attribute constructor.

Parameters:
name - the attribute name
doubleVal - the attribute value

Attribute

public Attribute(String name,
                 String stringVal)
Attribute constructor.

Parameters:
name - the attribute name
stringVal - the attribute value

Attribute

public Attribute(String name,
                 Time timeVal)
Attribute constructor.

Parameters:
name - the attribute name
timeVal - the attribute value

Attribute

public Attribute(String name,
                 AttributeSet attrSet)
Attribute constructor.

Parameters:
name - the attribute name
attrSet - the attribute value

Attribute

public Attribute(String name,
                 Collection<?> values)
Attribute constructor.

Parameters:
name - the attribute name
values - the attribute values

Attribute

public Attribute(String name,
                 Object value)
Attribute constructor.

Parameters:
name - the attribute name
value - the attribute value
Method Detail

equalNames

public static boolean equalNames(String s1,
                                 String s2)
A method to correctly compare 2 attribute names.


isSupportedAttributeType

protected boolean isSupportedAttributeType(Class<?> valueClass)
Returns whether the specified value type can be stored as an attribute value.

Subclasses can override this method to change the supported attribute type set.

Parameters:
valueClass - the class of a value
Returns:
boolean true if the value type can be stored as an attribute value

toString

public String toString()
Overrides:
toString in class Object
Returns:
a string to assist in debugging
See Also:
Object.toString()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

getName

public String getName()
Returns the attribute name.

Returns:
the attribute name

getSingleValue

public Object getSingleValue()
Returns a single value for the attribute. If there are multiple values, then the last one in the list (if any) will be returned.

Returns:
a single value of the attribute

getValues

public List<?> getValues()
Returns the list of values for the attribute. If there is only one value, then it will be put into a list.

Returns:
the list of the attribute values

Load

public static Attribute Load(Element attrElement)
Load the attribute from the specified XML element.

Parameters:
attrElement - the root element for the attribute XML data
Returns:
the new attribute created by loading it from the XML element

store

public void store(Element parentElem)
Store the attribute in the specified XML element.

Parameters:
parentElem - the parent XML element under which the attribute data will be stored

getAttributeType

public Attribute.Type getAttributeType()
Returns the Attribute.Type enum


getAttributeTypeOrdinal

public int getAttributeTypeOrdinal()
Deprecated. 

This is a helper for CAL - as CAL still needs to deal with ordinals

Returns:
0 - Unknown 1 - Colour 2 - Boolean 3 - Integer 4 - Double 5 - String 6 - AttributeSet 7 - Time

makeAttribute

public static Attribute makeAttribute(String name,
                                      List<?> values)
Creates a new attribute with the specified name and value list.

Parameters:
name - the attribute name
values - the value list for the attribute
Returns:
a new attribute

getNameComparator

public static Comparator<Attribute> getNameComparator()
Returns a Comparator that compares two attributes by their names.

Returns:
Comparator

Business Objects
Quark Platform Documentation
Version 1.7.0_0
Business Objects

Copyright © 2007 Business Objects. All rights reserved.