kaapo.project
Class Attribute

java.lang.Object
  extended by kaapo.project.Attribute
All Implemented Interfaces:
Serializable

public class Attribute
extends Object
implements Serializable

Attribute of a project component, with name, type and value.

Attribute value is stored and returned as a generic Object instance. It may be cast into a specific class according to the following rules:

Author:
hkovaska
See Also:
Serialized Form

Nested Class Summary
static class Attribute.AttributeType
          Enumeration for attribute type.
 
Field Summary
protected  String name
           
protected  Attribute.AttributeType type
           
protected  Object value
           
 
Constructor Summary
Attribute(String name, Attribute.AttributeType type)
          Constructs an attribute with null initial value.
Attribute(String name, Attribute.AttributeType type, Object value)
          Constructs an attribute with given initial value.
 
Method Summary
 String getName()
          Returns attribute name.
 Attribute.AttributeType getType()
          Returns attribute type.
 Object getValue()
          Returns attribute value.
 void setValue(Object value)
          Sets attribute value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name

value

protected Object value

type

protected Attribute.AttributeType type
Constructor Detail

Attribute

public Attribute(String name,
                 Attribute.AttributeType type)
Constructs an attribute with null initial value. Normally, this constructor is not called directly, but the attribute is created and added to a project component with ProjectComponent.addAttribute.

Parameters:
name - Attribute name
type - Attribute type
See Also:
ProjectComponent.addAttribute(String, Attribute.AttributeType)

Attribute

public Attribute(String name,
                 Attribute.AttributeType type,
                 Object value)
Constructs an attribute with given initial value. Normally, this constructor is not called directly, but the attribute is created and added to a project component with ProjectComponent.addAttribute.

Parameters:
name - Attribute name
type - Attribute type
value - Initial value
Throws:
IllegalArgumentException - If the value object is wrong type
See Also:
ProjectComponent.addAttribute(String, Attribute.AttributeType, Object)
Method Detail

setValue

public void setValue(Object value)
Sets attribute value. The value may be null.

Parameters:
value - New value.
Throws:
IllegalArgumentException - If the value object is wrong type

getValue

public Object getValue()
Returns attribute value. The value may be null.

Returns:
Value

getName

public String getName()
Returns attribute name.

Returns:
Name

getType

public Attribute.AttributeType getType()
Returns attribute type.

Returns:
Type