Package bluej.extensions2
Class BObject
- java.lang.Object
-
- bluej.extensions2.BObject
-
public class BObject extends java.lang.Object
A wrapper for an object on the BlueJ object bench. This wraps an object the extension can add and remove from the bench.- Author:
- Clive Miller, University of Kent at Canterbury, 2002, Damiano Bolla, University of Kent at Canterbury 2003,2004
- See Also:
BConstructor
,BMethod
,BField
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToBench(java.lang.String instanceName)
Adds this object on the object bench.BClass
getBClass()
Returns the class of this object.java.lang.String
getInstanceName()
Returns the name of this object on the object bench.BPackage
getPackage()
Returns the package this object belongs to.void
removeFromBench()
Removes this object from the object bench.java.lang.String
toString()
Returns a string representation of the Object
-
-
-
Method Detail
-
getPackage
public BPackage getPackage() throws ProjectNotOpenException, PackageNotFoundException
Returns the package this object belongs to.- Returns:
- A
BPackage
object wrapping the package this object belongs to. - Throws:
ProjectNotOpenException
- if the project to which this object belongs has been closed by the user.PackageNotFoundException
- if the package to which this object belongs has been deleted by the user.
-
removeFromBench
public void removeFromBench() throws ProjectNotOpenException, PackageNotFoundException
Removes this object from the object bench. This will also remove it from the view of the object bench. Once the object is removed from the bench it will not be available again.- Throws:
ProjectNotOpenException
- if the project to which this object belongs has been closed by the user.PackageNotFoundException
- if the package to which this object belongs has been deleted by the user.
-
addToBench
public void addToBench(java.lang.String instanceName) throws ProjectNotOpenException, PackageNotFoundException
Adds this object on the object bench. Ifnull
is passed asinstanceName
the object will have a predefined name. If the object is not a valid one nothing will happen.- Parameters:
instanceName
- The name to be given to this object on the bench.- Throws:
ProjectNotOpenException
- if the project to which this object belongs has been closed by the user.PackageNotFoundException
- if the package to which this object belongs has been deleted by the user.
-
getInstanceName
public java.lang.String getInstanceName()
Returns the name of this object on the object bench.- Returns:
- The instance name if the object can be put into bench,
null
othervise
-
getBClass
public BClass getBClass() throws ProjectNotOpenException, PackageNotFoundException, ClassNotFoundException
Returns the class of this object. Similar to Reflection API. Note the naming inconsistency, which avoids a clash withjava.lang.Object.getClass()
- Returns:
- a
BClass
object wrapping the class of this BObject. - Throws:
ProjectNotOpenException
- if the project to which this object belongs has been closed by the user.ClassNotFoundException
- if the class has been deleted by the user.PackageNotFoundException
- if the Package has been deleted by the user.
-
toString
public java.lang.String toString()
Returns a string representation of the Object- Overrides:
toString
in classjava.lang.Object
-
-