fr.jussieu.gla.wasa.core
Class Var

java.lang.Object
  |
  +--fr.jussieu.gla.wasa.core.Var
Direct Known Subclasses:
CellVar, DateBeanVar, PropertyVar, ScheduleVar

public abstract class Var
extends java.lang.Object

Opens access to a particular Buisness Object value.

This class has the Watcher role in a modified Memento pattern. The value is kept only for a short time, letting the Configuration storing the Buisness Objects state for a longer time.

Derive this class to provide your specific accessor to some particular Buisness Object, or use VarFactory to take advantage of reflexion-based mapping.

Version:
$Revision: 1.8 $ $Date: 2002/04/17 15:24:05 $
Author:
Laurent Caillette, Florent Selva

Constructor Summary
Var(Explorer explorer)
          Constructor.
 
Method Summary
protected abstract  java.lang.Object cloneValue()
          Override this method to provide custom cloning operation.
 float getError()
          Returns the current error value.
 Explorer getExplorer()
          Returns the Explorer instance associated to the Var.
 java.lang.String getName()
          Allows to get a user-defined tag.
 int getRank()
          Returns the instanciation rank of the Var.
abstract  java.lang.Object getReferencedValue()
          Override this method to provide the specific behavior for getting the reference to the value object hold by buisness object.
 boolean hasValueBasedHashCode()
          Returns if value's hashCode can be used to perform faster comparisons.
 void incError(double error)
          Facility for callingincError( float ).
 void incError(float error)
          Method that Constraint implementations should call in their Constraint.evaluate() method, in order to explain how a Var's value violates a constraint.
 void incError(int error)
          Facility for callingincError( float ).
 void setName(java.lang.String name)
          Allows to set a user-defined tag.
abstract  void setReferencedValue(java.lang.Object value)
          Override this method to provide the specific behavior of updating the value object held by buisness object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Var

public Var(Explorer explorer)
Constructor. Automatically adds the instantiated Var to the Explorer.
Parameters:
explorer - The Explorer this Var belongs to.
Method Detail

getRank

public int getRank()
Returns the instanciation rank of the Var.
Returns:
The instanciation rank of the Var.

getExplorer

public final Explorer getExplorer()
Returns the Explorer instance associated to the Var.
Returns:
The Explorer instance associated to the Var.

hasValueBasedHashCode

public boolean hasValueBasedHashCode()
Returns if value's hashCode can be used to perform faster comparisons.

Override this method to return true if you are sure the value object has significant hash code, in other words it respects this part of the hashCode contract :
If two objects are equal according to the equals( Object ) method, then calling the hashCode method on each of the two objects must produce the same integer result.

Returns:
false by default.
See Also:
Object.hashCode(), Object.equals( Object )

getError

public final float getError()
Returns the current error value.
Returns:
The current error value.

incError

public final void incError(float error)
Method that Constraint implementations should call in their Constraint.evaluate() method, in order to explain how a Var's value violates a constraint. Increment the var error of error.
Parameters:
The - error value, lower means less error, means better.

incError

public final void incError(int error)
Facility for callingincError( float ).
Parameters:
A - value to cast to a float.

incError

public final void incError(double error)
Facility for callingincError( float ).
Parameters:
A - value to cast to a float.

getReferencedValue

public abstract java.lang.Object getReferencedValue()
Override this method to provide the specific behavior for getting the reference to the value object hold by buisness object.
Returns:
A reference to the value object.

cloneValue

protected abstract java.lang.Object cloneValue()
                                        throws java.lang.CloneNotSupportedException
Override this method to provide custom cloning operation. The framework guarantees that it won't be called if value is null.
Returns:
A clone of value object.
Throws:
java.lang.CloneNotSupportedException - as Object.clone() does.

setReferencedValue

public abstract void setReferencedValue(java.lang.Object value)
Override this method to provide the specific behavior of updating the value object held by buisness object.
Parameters:
value - The value to set.

getName

public final java.lang.String getName()
Allows to get a user-defined tag. Default value is var + <var index>.
Returns:
The name of this ProblemItem.

setName

public final void setName(java.lang.String name)
Allows to set a user-defined tag.
Parameters:
name - The name of this ProblemItem.