com.ibm.commons.iloader.node
Class DataNode.ComputedField

java.lang.Object
  extended by com.ibm.commons.iloader.node.DataNode.ComputedField
All Implemented Interfaces:
IAttribute, IMember
Enclosing class:
DataNode

public static class DataNode.ComputedField
extends java.lang.Object
implements IAttribute

An attribute whose values may or may not have a direct bearing on the underlying model. A ComputedField can get information that is outside the bounds of the model associated with the current DataNode. Clients will typically override the getValue(Object), setValue(Object, String, DataChangeNotifier), isReadOnly() and shouldRecompute(Object, Object, int, IMember, int) methods.


Field Summary
 
Fields inherited from interface com.ibm.commons.iloader.node.IMember
TYPE_BOOLEAN, TYPE_INTEGER, TYPE_NUMBER, TYPE_OBJECT, TYPE_STRING
 
Constructor Summary
DataNode.ComputedField(java.lang.String name, int type)
          Creates a new instance of this class.
 
Method Summary
 java.lang.String getCategory()
          Get the category.
 java.lang.String getDefaultValue()
          Returns the default value of the property.
 java.lang.String getDescription()
          Get a description, for user help.
 java.lang.String getDisplayName()
          Get the attribute display name.
 IPropertyEditor getEditor()
          Returns a property editor that can be used to define this property.
 ILookup getLookup()
          Returns a lookup that can be used to define the possible values of the property/attribute that this class represents.
 java.lang.String getName()
          Get the attribute name.
 IClassDef getParent()
          Get the class definition parent of this member.
 java.lang.String getPropertyToDisplay()
           
 IValidator getScriptValidator(java.lang.Object obj)
          Returns a validator that will be associated with the IPropertyEditor that is associated with this property.
 int getType()
          Get the attribute data type.
 IClassDef getTypeDef()
          In the case of a member whose type is com.ibm.commons.iloader.node.IMember.TYPE_OBJECT this method will return the class that can be used to define a new Object.
 java.lang.String getValue(java.lang.Object instance)
          Returns the value of the ComputedField in respect to the current model.
 boolean isComputable()
          Returns true if the field's value is computable.
 boolean isReadOnly()
          Returns whether or not a member is read-only.
 boolean isScriptable(IScript script)
          Defines whether or not the property's value can be a script value.
 boolean isVisible(java.lang.Object obj)
          Check if the member is visible.
 void setValue(java.lang.Object instance, java.lang.String value, DataChangeNotifier notifier)
          Sets the value of the ComputedField.
 boolean shouldRecompute(java.lang.Object instance, java.lang.Object object, int operation, IMember member, int position)
          Determines if the value of the field should be recomputed based on the operation provided
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataNode.ComputedField

public DataNode.ComputedField(java.lang.String name,
                              int type)
Creates a new instance of this class.

Parameters:
name - the property name of this field
type - the type of the field
Method Detail

getName

public java.lang.String getName()
Description copied from interface: IMember
Get the attribute name.

Specified by:
getName in interface IMember
Returns:
returns the name of the attribute

getDisplayName

public java.lang.String getDisplayName()
Description copied from interface: IMember
Get the attribute display name.

Specified by:
getDisplayName in interface IMember
Returns:
returns the name of the attribute as it is to appear in the user interface

getDescription

public java.lang.String getDescription()
Description copied from interface: IMember
Get a description, for user help.

Specified by:
getDescription in interface IMember
Returns:
returns a description of the property

getCategory

public java.lang.String getCategory()
Description copied from interface: IMember
Get the category.

Specified by:
getCategory in interface IMember
Returns:
returns the category that this property falls under, e.g. "Basics", "Data", etc..

getParent

public IClassDef getParent()
Description copied from interface: IMember
Get the class definition parent of this member.

Specified by:
getParent in interface IMember
Returns:
returns the IClassDef parent of this IMember
See Also:
IClassDef

getType

public int getType()
Description copied from interface: IMember
Get the attribute data type. Typically returns one of:

Specified by:
getType in interface IMember
Returns:
returns an int corresponding to the data type of the property

getTypeDef

public IClassDef getTypeDef()
Description copied from interface: IMember
In the case of a member whose type is com.ibm.commons.iloader.node.IMember.TYPE_OBJECT this method will return the class that can be used to define a new Object.

Specified by:
getTypeDef in interface IMember

getLookup

public ILookup getLookup()
Description copied from interface: IAttribute
Returns a lookup that can be used to define the possible values of the property/attribute that this class represents.

Specified by:
getLookup in interface IAttribute
Returns:
returns an ILookup that can be used to set the value of the property, may be null.
See Also:
ILookup

isReadOnly

public boolean isReadOnly()
Description copied from interface: IMember
Returns whether or not a member is read-only.

Specified by:
isReadOnly in interface IMember
Returns:
returns true if the property is read-only

isVisible

public boolean isVisible(java.lang.Object obj)
Description copied from interface: IMember
Check if the member is visible.

Specified by:
isVisible in interface IMember

getDefaultValue

public java.lang.String getDefaultValue()
Description copied from interface: IMember
Returns the default value of the property.

Specified by:
getDefaultValue in interface IMember
Returns:
returns a string

getEditor

public IPropertyEditor getEditor()
Description copied from interface: IMember
Returns a property editor that can be used to define this property.

Specified by:
getEditor in interface IMember
Returns:
returns a IPropertyEditor
See Also:
IPropertyEditor

isScriptable

public boolean isScriptable(IScript script)
Description copied from interface: IMember
Defines whether or not the property's value can be a script value.

Specified by:
isScriptable in interface IMember
Returns:
returns true if the property's value can be set via a script

getValue

public java.lang.String getValue(java.lang.Object instance)
                          throws com.ibm.commons.iloader.node.NodeException
Returns the value of the ComputedField in respect to the current model. This method MUST be overridden.

Parameters:
instance - the model
Returns:
returns a String value
Throws:
NodeException

setValue

public void setValue(java.lang.Object instance,
                     java.lang.String value,
                     DataChangeNotifier notifier)
              throws com.ibm.commons.iloader.node.NodeException
Sets the value of the ComputedField. This method MUST be overridden.

Parameters:
instance - the model
value - the value of the ComputedField
notifier - a notifier who will notify listeners of the change
Throws:
NodeException

shouldRecompute

public boolean shouldRecompute(java.lang.Object instance,
                               java.lang.Object object,
                               int operation,
                               IMember member,
                               int position)
Determines if the value of the field should be recomputed based on the operation provided

Parameters:
instance - the model
object - the new value of the property
operation - the operation that was performed (value changed, inserted, deleted)
member - the member that changed
position - the position of the member
Returns:
true if the field should be recomputed

isComputable

public boolean isComputable()
Returns true if the field's value is computable.

Returns:

getPropertyToDisplay

public java.lang.String getPropertyToDisplay()

getScriptValidator

public IValidator getScriptValidator(java.lang.Object obj)
Description copied from interface: IMember
Returns a validator that will be associated with the IPropertyEditor that is associated with this property.

Specified by:
getScriptValidator in interface IMember
Returns:
See Also:
#getEditor()}, {@link com.ibm.commons.iloader.node.validators.IValidator}