Package bluej.extensions2
Class BObject
- java.lang.Object
-
- bluej.extensions2.BObject
-
public class BObject extends java.lang.ObjectA 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 voidaddToBench(java.lang.String instanceName)Adds this object on the object bench.BClassgetBClass()Returns the class of this object.java.lang.StringgetInstanceName()Returns the name of this object on the object bench.BPackagegetPackage()Returns the package this object belongs to.voidremoveFromBench()Removes this object from the object bench.java.lang.StringtoString()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
BPackageobject 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, PackageNotFoundExceptionRemoves 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, PackageNotFoundExceptionAdds this object on the object bench. Ifnullis passed asinstanceNamethe 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,
nullothervise
-
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
BClassobject 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:
toStringin classjava.lang.Object
-
-