edu.wpi.ebob.internal.inspect
Class FieldNode

java.lang.Object
  extended by edu.wpi.ebob.internal.inspect.AbstractNode
      extended by edu.wpi.ebob.internal.inspect.FieldNode
All Implemented Interfaces:
ModifiableNode, Node

public class FieldNode
extends AbstractNode
implements ModifiableNode

represents a IFieldin a tree.

Author:
Liam Morley

Field Summary
private  IField field
          the field to display in the tree.
private  boolean hasCheckedForChildren
          we only want to check for children once.
private  boolean hasRetrievedValue
          we only want to retrieve the value once.
private  IObject obj
          the object that this field belongs to.
private  IObject value
          the value of the field fieldin object obj.
 
Fields inherited from class edu.wpi.ebob.internal.inspect.AbstractNode
children
 
Constructor Summary
FieldNode(IObject obj, IField field)
          creates a new node in the tree representing a field.
 
Method Summary
 Node[] getChildren()
          returns the child nodes of this node, represented as objects.
 org.eclipse.swt.graphics.Image getImage()
          returns the image that should be shown for this node.
 java.lang.String getName()
          the text label for this node.
 IClass getType()
          returns the Class object associated with this node.
 IObject getValue()
          the underlying value for this node.
 java.lang.String getValueAsString()
          returns the toString() of Node.getValue().
 boolean hasChildren()
           
 boolean isModifiable()
           
 void setValue(IObject newValue)
          sets the value of the field.
 
Methods inherited from class edu.wpi.ebob.internal.inspect.AbstractNode
addChild, getParent, setParent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.wpi.ebob.internal.inspect.Node
getParent, setParent
 

Field Detail

field

private IField field
the field to display in the tree.


hasCheckedForChildren

private boolean hasCheckedForChildren
we only want to check for children once.


hasRetrievedValue

private boolean hasRetrievedValue
we only want to retrieve the value once.


obj

private IObject obj
the object that this field belongs to.


value

private IObject value
the value of the field fieldin object obj.

Constructor Detail

FieldNode

public FieldNode(IObject obj,
                 IField field)
creates a new node in the tree representing a field.

Parameters:
obj - the object that this field belongs to.
field - the field to display in the tree.
Method Detail

getChildren

public Node[] getChildren()
Description copied from interface: Node
returns the child nodes of this node, represented as objects.

Specified by:
getChildren in interface Node
Overrides:
getChildren in class AbstractNode
See Also:
Node.getChildren()

getImage

public org.eclipse.swt.graphics.Image getImage()
Description copied from interface: Node
returns the image that should be shown for this node.

Specified by:
getImage in interface Node
Overrides:
getImage in class AbstractNode
Returns:
null
See Also:
Node.getImage()

getName

public java.lang.String getName()
Description copied from interface: Node
the text label for this node.

Specified by:
getName in interface Node
See Also:
Node.getName()

getType

public IClass getType()
Description copied from interface: Node
returns the Class object associated with this node.

Specified by:
getType in interface Node
See Also:
Node.getType()

getValue

public IObject getValue()
Description copied from interface: Node
the underlying value for this node.

Specified by:
getValue in interface Node
See Also:
Node.getValue()

getValueAsString

public java.lang.String getValueAsString()
Description copied from class: AbstractNode
returns the toString() of Node.getValue().

Specified by:
getValueAsString in interface Node
Overrides:
getValueAsString in class AbstractNode
Returns:
an empty string if the field type is not primitive.
See Also:
Node.getValueAsString()

hasChildren

public boolean hasChildren()
Specified by:
hasChildren in interface Node
Overrides:
hasChildren in class AbstractNode
Returns:
true if the object is non-null and any of the following are true:
  1. the object is an array with a length greater than 0
  2. the object is not-primitive and has at least one declared field
See Also:
Node.hasChildren()

isModifiable

public boolean isModifiable()
Specified by:
isModifiable in interface ModifiableNode
Returns:
true if and only if this object can be modified.
See Also:
ModifiableNode.isModifiable()

setValue

public void setValue(IObject newValue)
sets the value of the field. throws an exception if the field is not public.

Specified by:
setValue in interface ModifiableNode
Parameters:
newValue - the new value for this field.
See Also:
IField