abc.weaving.aspectinfo
Class VarBox

java.lang.Object
  extended by abc.weaving.aspectinfo.VarBox

public class VarBox
extends java.lang.Object

A wrapper class for an optional Var value. A VarBox object is eithet SET, in which case it contains a Var, or UNSET.

Author:
Damien Sereni

Constructor Summary
VarBox()
          Constructs a new VarBox object, intially unset
VarBox(Var var)
          Constructs a new VarBox object, initially set
 
Method Summary
 boolean equals(java.lang.Object o)
          Test for equality.
 boolean equalsvar(Var v)
          Tests whether the variable stored in this VarBox is equal to another Var object.
 Var getVar()
          Returns the Var stored in this VarBox if any, undefined otherwise (if the VarBox is not set)
 boolean hasVar()
          Tests whether this VarBox is set
 void set(Var v)
          Set this VarBox.
 java.lang.String toString()
          Print this VarBox as a string.
 void unset()
          Unset this VarBox.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VarBox

public VarBox()
Constructs a new VarBox object, intially unset


VarBox

public VarBox(Var var)
Constructs a new VarBox object, initially set

Parameters:
var - the variable to be stored in the VarBox
Method Detail

hasVar

public boolean hasVar()
Tests whether this VarBox is set

Returns:
true if this VarBox is set (ie contains a value of type Var) or not

getVar

public Var getVar()
Returns the Var stored in this VarBox if any, undefined otherwise (if the VarBox is not set)

Returns:
the Var value stored inside this VarBox if it exists, undefined if it does not

equals

public boolean equals(java.lang.Object o)
Test for equality. A VarBox is equal to any other VarBox precisely when they are either both unset, or when they are both set and contain variables that are equal

Overrides:
equals in class java.lang.Object

equalsvar

public boolean equalsvar(Var v)
Tests whether the variable stored in this VarBox is equal to another Var object. If this VarBox is unset, this always returns false

Parameters:
v - a Var object to test for equality with
Returns:
true exactly when this is set, and the variable this VarBox contains equals v

unset

public void unset()
Unset this VarBox. After this, the VarBox is deemed not to contain a value


set

public void set(Var v)
Set this VarBox. This stores a variable inside this VarBox

Parameters:
v - the variable to store inside this VarBox

toString

public java.lang.String toString()
Print this VarBox as a string. A set VarBox is printed as its contents (ie a Var), an unset VarBox is shown as X

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this VarBox