public interface Attribute
An attribute involves 6 objects, described below, which are used to secure
reference to a method (using reflection) which either produces or consumes
data of type E (see the Coupling
documentation). From this
standpoint, a coupling is a pair consisting of a getter and a setter:
Producer (getX) --> E ---> Consumer (setX).
Usually (1)-(3) below are all that are needed to create an attribute. (4) Can
be customized as needed. (5) and (6) are only used in special cases where
"auxiliary" arguments are needed. These fields are described here. However in
practice, an attribute is created by way of a PotentialAttribute
, using the AttributeManager
.
(1) BaseObject (Object): This is the basic object (a neuron, an agent in a simulated world, etc) where the method lives.
(2) MethodName (String): The name of the method in question. Usually a getter for producers, and a setter for consumers.
(3) DataType (Class): The "main" data type (usually double) of the data
produced or consumed by a coupling. Note that Producer
,
Consumer
, and Coupling
are all parameterized by
this type.
(4) Description (String): A description of the attribute, which is useful in
displaying couplings, and also in displaying a PotentialAttibute
in the GUI, and also for debugging. Can be set to a custom value. Otherwise a
default description describing the object, methodname, and datatype is made.
Auxiliary arguments are used to secure access to an underlying object that produces or consumes a value.
(5) ArgumentDataTypes (Class[]): The method signature of a getter or setter that requires auxiliary arguments. Usually null unless auxiliary arguments are needed.
(6) ArgumentValues (Object[]): The values passed to a getter or setter with auxiliary arguments.Usually null unless auxiliary arguments are needed.
The way auxiliary arguments work is a little different for producers and consumers
Producers: These are straightforward. The method signature for the getter and the values passed in line up.
Consumers: This is a bit more complex, because the method signature and values are offset by 1. This is because the fist item of the method signature vector is the datatype. Note that this constrains what kind of setter can be a consumer with auxiliary arguments: in setters like this the first argument must be the same as the DataType.
Finally, note that the actual act of creating a producer or consumer using the reflection API happens in the AttributeManager class.
AttributeManager
,
PotentialAttribute
,
Coupling
Modifier and Type | Method and Description |
---|---|
java.lang.Class<?>[] |
getArgumentDataTypes()
Returns the method signature for auxiliary arguments (see the javadocs
above for more information on this).
|
java.lang.Object[] |
getArgumentValues()
Returns the argument values auxiliary arguments (see the javadocs above
for more information on this).
|
java.lang.Object |
getBaseObject()
Returns the base object associated with this attribute.
|
java.lang.Class<?> |
getDataType()
Returns the "main" data type of this attribute (see class javadocs
above).
|
java.lang.String |
getDescription()
Returns a descriptive name for this attribute.
|
java.lang.String |
getMethodName()
Returns the name of the method associated with this attribute.
|
WorkspaceComponent |
getParentComponent()
Returns a reference to the parent component.
|
WorkspaceComponent getParentComponent()
java.lang.Object getBaseObject()
java.lang.Class<?> getDataType()
java.lang.String getMethodName()
java.lang.Class<?>[] getArgumentDataTypes()
java.lang.Object[] getArgumentValues()
java.lang.String getDescription()