spark.data
Class SOReflect

java.lang.Object
  extended by spark.data.SObj
      extended by spark.data.SOReflect
All Implemented Interfaces:
SO, SParented

public class SOReflect
extends SObj

This is a concrete implementation of SO that has special properties. Subclasses of SOReflect can be used to expose various fields of the subclass as attributes visible to SO. It also accepts fields that are not known to the subclass and stores them as well.

Any public field that is Double, Long, Boolean, String, SO or SA will be exposes as an SO attribute.

Any pair of getXX()/setXX(v) methods will be treated as the attribute XX.

The idea is to create a subclass of SOReflect and give it public fields or get/set methods to define a set of attributes.

Author:
olsen

Constructor Summary
SOReflect()
           
 
Method Summary
 java.lang.String[] attributes()
          This will retrieve the names of all of the attributes that are available for this object.
 SV get(java.lang.String name)
          This will return the value of the named attribute.
 java.lang.String myClass()
          This returns the name of the class that implements this object.
 void set(java.lang.String name, SV val)
          This will set the value of the named attribute.
 void setNull(java.lang.String name)
           
 
Methods inherited from class spark.data.SObj
getArray, getDouble, getLong, getObj, getString, isTrue, myParent, newParent, set, set, set, set, set, set, unParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SOReflect

public SOReflect()
Method Detail

myClass

public java.lang.String myClass()
Description copied from interface: SO
This returns the name of the class that implements this object.

Specified by:
myClass in interface SO
Overrides:
myClass in class SObj
Returns:
a full class name

get

public SV get(java.lang.String name)
Description copied from interface: SO
This will return the value of the named attribute.

Specified by:
get in interface SO
Overrides:
get in class SObj
Parameters:
name - the name of the attribute value to be returned.
Returns:
The value of the attribute. If this object does not have this attribute, then null will be returned.

setNull

public void setNull(java.lang.String name)
Specified by:
setNull in interface SO
Overrides:
setNull in class SObj

set

public void set(java.lang.String name,
                SV val)
Description copied from interface: SO
This will set the value of the named attribute. If it is not possible to set this attribute then a RuntimeException is thrown. This can be used to create new attributes or to change them.

Specified by:
set in interface SO
Overrides:
set in class SObj
Parameters:
name - the name of the attribute to be set.
val - the new value for the attribute.

attributes

public java.lang.String[] attributes()
Description copied from interface: SO
This will retrieve the names of all of the attributes that are available for this object.

Specified by:
attributes in interface SO
Overrides:
attributes in class SObj
Returns:
an array of attribute names.