jcolibri.cbrcore
Class Attribute

java.lang.Object
  extended by jcolibri.cbrcore.Attribute

public class Attribute
extends java.lang.Object

This class identifies an attribute of a CaseComponent (Java Bean). Attributes are part of CaseComponents and CaseComponentes build a case. Note that each CaseComponent must be a Java Bean, so this class represents a field of a Java Bean (with its getXXX() and setXXX() methods).

Author:
Juan A. Recio-García
See Also:
CaseComponent

Constructor Summary
Attribute(java.lang.reflect.Field f)
          Creates an Attribute using the Field obtained with Reflection (getClass.getDeclaredField(name)).
Attribute(java.lang.String attributeName, java.lang.Class _class)
          Creates an attribute.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.Class<?> getDeclaringClass()
          Returns the class that this attribute belongs to.
 java.lang.String getName()
          Returns the name of the field.
 java.lang.Class<?> getType()
          Returns the type of the attribute.
 java.lang.Object getValue(java.lang.Object obj)
          Returns the value of the attribute for a concrete object.
 int hashCode()
          Returns the hashCode of the attribute.
 void setValue(java.lang.Object obj, java.lang.Object value)
          Sets the value of the attribute in a concrete object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(java.lang.reflect.Field f)
Creates an Attribute using the Field obtained with Reflection (getClass.getDeclaredField(name)). It is recommended to use the other constructor.


Attribute

public Attribute(java.lang.String attributeName,
                 java.lang.Class _class)
Creates an attribute. The attribute name must be an existing field of the class and have the get/set() methods.

Parameters:
attributeName - Name of the field
_class - Class that the attribute belongs to.
Method Detail

getName

public java.lang.String getName()
Returns the name of the field.


getDeclaringClass

public java.lang.Class<?> getDeclaringClass()
Returns the class that this attribute belongs to.


getType

public java.lang.Class<?> getType()
Returns the type of the attribute.


getValue

public java.lang.Object getValue(java.lang.Object obj)
                          throws AttributeAccessException
Returns the value of the attribute for a concrete object. Of course, the object must be instance of the class that this attribute belongs to.

Parameters:
obj - Instance to obtain the attribute from
Throws:
AttributeAccessException

setValue

public void setValue(java.lang.Object obj,
                     java.lang.Object value)
              throws AttributeAccessException
Sets the value of the attribute in a concrete object.

Parameters:
obj - Object that defines the attribute to set.
value - Value to set.
Throws:
AttributeAccessException

hashCode

public int hashCode()
Returns the hashCode of the attribute.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

GAIA - Group for Artificial Intelligence Applications
http://gaia.fdi.ucm.es