org.primordion.xholon.base
Class ReflectionJavaStandard

java.lang.Object
  extended byorg.primordion.xholon.base.ReflectionJavaStandard
All Implemented Interfaces:
IReflection

public class ReflectionJavaStandard
extends java.lang.Object
implements IReflection

Reflection supports a metadata capability. ReflectionJavaStandard implements reflection by using the Java Standard Edition reflection mechanism, including the Field, Method and Array classes.

Since:
0.5 (Created on December 7, 2006)
Author:
Ken Webb

Constructor Summary
ReflectionJavaStandard()
           
 
Method Summary
 int getAttributeIntVal(java.lang.Class aClass, java.lang.String attrName)
          Get the current value of an int attribute.
 int getAttributeIntVal(IXholon xhNode, java.lang.String attrName)
          Get the current value of an int attribute.
 java.lang.Object[][] getAttributes(IXholon node)
          Get all attributes that are accessible using a method that starts with "get".
 java.lang.String getAttributeStringVal(IXholon xhNode, java.lang.String attrName)
          XPath uses this to get the current value of a String attribute.
 int setAttributeArrayVal(IXholon tNode, java.lang.String attrName, java.lang.String val, int valIx, int arraySubscript)
          Set the value of one slot in a named array attribute.
 boolean setAttributeBooleanVal(IXholon tNode, java.lang.String attrName, boolean val)
          Set the value of a boolean attribute.
 int setAttributeVal(IXholon tNode, java.lang.String attrName, java.lang.String val, int valIx)
          Set the value of a named attribute.
 boolean setParam(java.lang.String pName, java.lang.String pValue, Application app)
          Application uses this to set parameters.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionJavaStandard

public ReflectionJavaStandard()
Method Detail

setParam

public boolean setParam(java.lang.String pName,
                        java.lang.String pValue,
                        Application app)
Description copied from interface: IReflection
Application uses this to set parameters. Parameters are typically specified in the _xhn.xml file.

Specified by:
setParam in interface IReflection
Parameters:
pName - Parameter name.
pValue - Parameter value.
app - The Application.
Returns:
Whether or not the parameter could be set.

getAttributes

public java.lang.Object[][] getAttributes(IXholon node)
Description copied from interface: IReflection
Get all attributes that are accessible using a method that starts with "get". Only those get methods that have no input parameters are handled. ex: getVal() getRoleName() getUseDataPlotter()

Specified by:
getAttributes in interface IReflection
Parameters:
node - An instance of IXholon.
Returns:
A two-dimensional array with a variable number of rows, each containing a Name/Value pair.

getAttributeStringVal

public java.lang.String getAttributeStringVal(IXholon xhNode,
                                              java.lang.String attrName)
Description copied from interface: IReflection
XPath uses this to get the current value of a String attribute.

Specified by:
getAttributeStringVal in interface IReflection
Parameters:
attrName - The name of a String attribute.
Returns:
The current value of the String attribute.

getAttributeIntVal

public int getAttributeIntVal(IXholon xhNode,
                              java.lang.String attrName)
Description copied from interface: IReflection
Get the current value of an int attribute. This is currently used at configuration time to get the value of a constant, specifically, the values of port, FSM connection point, and signal id constants. These are all class variables defined as static, and possibly as final.

Specified by:
getAttributeIntVal in interface IReflection
Parameters:
attrName - The name of an int attribute.
Returns:
The current value of the int attribute.

getAttributeIntVal

public int getAttributeIntVal(java.lang.Class aClass,
                              java.lang.String attrName)
Description copied from interface: IReflection
Get the current value of an int attribute. This is currently used at configuration time to get the value of a constant, specifically, by StateMachineEntity, and by ReflectionJavaStandard.getAttributeIntVal(IXholon xhNode, String attrName)

Specified by:
getAttributeIntVal in interface IReflection
Parameters:
aClass - A Java class, typically a Xh concrete class.
attrName - The name of an int attribute.
Returns:
The current value of the int attribute.

setAttributeVal

public int setAttributeVal(IXholon tNode,
                           java.lang.String attrName,
                           java.lang.String val,
                           int valIx)
Description copied from interface: IReflection
Set the value of a named attribute. The type could be any valid Java type. This is currently used at configuration time in Xholon.setVariableValue(String, int) to initialize the value of a variable owned by a specific xholon instance, and by XholonClass.configure().

Specified by:
setAttributeVal in interface IReflection
Parameters:
attrName - The name of an attribute.
val - A String that contains the value that the attribute should be set to.
valIx - An index into the String. The location within the String where the value begins.
Returns:
The Java class type of the input val.

setAttributeBooleanVal

public boolean setAttributeBooleanVal(IXholon tNode,
                                      java.lang.String attrName,
                                      boolean val)
Description copied from interface: IReflection
Set the value of a boolean attribute. This is currently used at configuration time in Xholon.setVariableValue(String, int) to initialize the value of a variable owned by a specific xholon instance, and by XholonClass.configure().

Specified by:
setAttributeBooleanVal in interface IReflection
Parameters:
tNode - An IXholon instance.
attrName - The name of a boolean attribute.
val - The value that this boolean attribute should be set to.
Returns:
Whether or not the attribute could be set.

setAttributeArrayVal

public int setAttributeArrayVal(IXholon tNode,
                                java.lang.String attrName,
                                java.lang.String val,
                                int valIx,
                                int arraySubscript)
Description copied from interface: IReflection
Set the value of one slot in a named array attribute. This is currently used at configuration time in Xholon.setVariableValue(String, int) to initialize the value of a variable owned by a specific xholon instance, and by XholonClass.configure().

Specified by:
setAttributeArrayVal in interface IReflection
Parameters:
tNode - An IXholon instance.
attrName - The name of an array attribute.
val - A String that contains the value that the attribute should be set to.
valIx - An index into the String. The location within the String where the value begins.
arraySubscript - The Zero-indexed subscript of the slot within the array.
Returns:
The Java class type of the input val.