bluej.extensions
Class BField

java.lang.Object
  extended bybluej.extensions.BField

public class BField
extends java.lang.Object

A wrapper for a field of a BlueJ class. Behaviour is similar to the Reflection API.

Version:
$Id: BField.java,v 1.35 2003/11/10 14:49:42 damiano Exp $

Method Summary
 int getModifiers()
          Returns the modifiers of this field.
 java.lang.String getName()
          Return the name of the field.
 java.lang.Class getType()
          Return the type of the field.
 java.lang.Object getValue(BObject onThis)
          Return the value of this field of the given object.
 boolean matches(java.lang.String fieldName)
          Check to see if the field name matches the given one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

matches

public boolean matches(java.lang.String fieldName)
Check to see if the field name matches the given one.

Returns:
true if it does, false othervide

getName

public java.lang.String getName()
Return the name of the field. Similar to reflection API.


getType

public java.lang.Class getType()
Return the type of the field. Similar to Reflection API.


getModifiers

public int getModifiers()
Returns the modifiers of this field. The java.lang.reflect.Modifier class can be used to decode the modifiers. Similar to reflection API


getValue

public java.lang.Object getValue(BObject onThis)
                          throws ProjectNotOpenException,
                                 PackageNotFoundException
Return the value of this field of the given object. This is similar to Reflection API. In the case that the field is of primitive type (int etc.), the return value is of the appropriate Java wrapper type (Integer etc.). In the case that the field contains an object then an appropriate BObject will be returned. The main reason that this method is on a field (derived from a class), rather than directly on an object, is to allow for the retrieval of static field values without having to create an object of the appropriate type. As in the Relection API, in order to get the value of a static field pass null as the parameter to this method.

Throws:
ProjectNotOpenException - if the project to which the field belongs has been closed by the user.
PackageNotFoundException - if the package to which the field belongs has been deleted by the user.


BlueJ homepage