bluej.extensions
Class BField

java.lang.Object
  extended by bluej.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.

Author:
Damiano Bolla, University of Kent at Canterbury, 2003, Clive Miller, University of Kent at Canterbury, 2002

Method Summary
 java.lang.reflect.Field getJavaField()
          Returns the java Field for inspection.
 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)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

matches

@Deprecated
public boolean matches(java.lang.String fieldName)
Deprecated. 

Check to see if the field name matches the given one.

This method is deprecated. Use "getName().equals(fieldName)" instead.

Parameters:
fieldName - the field name to compare with
Returns:
true if it does, false otherwise

getName

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

Returns:
The name value

getType

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

Returns:
The type value

getJavaField

public java.lang.reflect.Field getJavaField()
Returns the java Field for inspection. Use this method when you need more information about the Field than is provided by the BField interface. E.g.: What is the declaring class of this Field? Note that this is for information only. If you want to interact with BlueJ you must use the methods provided in BField.

Returns:
The java.lang.reflect.Field providing extra information about this BField.

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

Returns:
The modifiers value

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.

Parameters:
onThis - Description of the Parameter
Returns:
The value value
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