choco.kernel.model.variables
Class AbstractVariable

java.lang.Object
  extended by choco.kernel.model.VariableArray
      extended by choco.kernel.model.ModelObject
          extended by choco.kernel.model.variables.AbstractVariable
All Implemented Interfaces:
IPretty, IIndex, IConstraintList, IFindManager, IOptions, IVariableArray, IHook, Variable, Serializable, Comparable
Direct Known Subclasses:
ComponentVariable, MultipleVariables

public abstract class AbstractVariable
extends ModelObject
implements Variable, Comparable

Created by IntelliJ IDEA. User: charles Date: 17 mars 2008 Time: 18:28:35 Abstract class for variable with basic methods

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class choco.kernel.model.VariableArray
VariableArray.VConstraintsDataStructure
 
Field Summary
protected  String name
           
protected  VariableType type
           
 
Fields inherited from class choco.kernel.model.VariableArray
NO_CONSTRAINTS
 
Fields inherited from interface choco.kernel.model.variables.Variable
LOGGER
 
Fields inherited from interface choco.kernel.model.variables.IHook
NO_HOOK
 
Constructor Summary
AbstractVariable(VariableType type, boolean enableOptions)
           
AbstractVariable(VariableType type, boolean enableOption, IConstraintList constraints)
           
AbstractVariable(VariableType type, Variable[] variables, boolean enableOptions)
           
 
Method Summary
 void _addConstraint(Constraint c)
           
 boolean _contains(Constraint c)
           
 void _removeConstraint(Constraint c)
           
 int compareTo(Object o)
          Compares this object with the specified object for order.
 Constraint getConstraint(int idx)
           
 Iterator<Constraint> getConstraintIterator()
          Deprecated. 
 Iterator<Constraint> getConstraintIterator(Model m)
           
 Constraint[] getConstraints()
           
 int getHook()
          get the current hook value
 String getName()
           
 int getNbConstraint()
          Deprecated. 
 int getNbConstraint(Model m)
           
 VariableType getVariableType()
           
 String pretty()
          pretty printing of the object.
 void removeConstraints()
           
 void resetHook()
          reset the hook, it allows to set a new value.
 void setHook(int hook)
          you should be sure to reset the hook before setting a new hook value
 void setName(String name)
           
protected static void throwConstantException()
           
 String toString()
           
 
Methods inherited from class choco.kernel.model.ModelObject
addOption, addOptions, addOptions, addOptions, addOptions, containsOption, getIndex, getOptions, hashCode
 
Methods inherited from class choco.kernel.model.VariableArray
cancelExtractVariables, doExtractVariables, extractVariables, forceExtractVariables, getNbVars, getVariable, getVariableIterator, getVariables, replaceBy, replaceByConstantAt, setVariables, setVariables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface choco.kernel.model.variables.Variable
getConstraintManager, getExpressionManager, getVariableManager
 
Methods inherited from interface choco.kernel.model.IVariableArray
extractVariables, getNbVars, getVariable, getVariableIterator, getVariables, replaceBy
 
Methods inherited from interface choco.kernel.common.IIndex
getIndex
 
Methods inherited from interface choco.kernel.model.IFindManager
findManager
 
Methods inherited from interface choco.kernel.model.IOptions
addOption, addOptions, addOptions, addOptions, addOptions, containsOption, getOptions
 

Field Detail

type

protected final VariableType type

name

protected String name
Constructor Detail

AbstractVariable

public AbstractVariable(VariableType type,
                        boolean enableOption,
                        IConstraintList constraints)

AbstractVariable

public AbstractVariable(VariableType type,
                        boolean enableOptions)

AbstractVariable

public AbstractVariable(VariableType type,
                        Variable[] variables,
                        boolean enableOptions)
Method Detail

throwConstantException

protected static void throwConstantException()

getName

public final String getName()
Specified by:
getName in interface Variable

setName

public final void setName(String name)

getVariableType

public final VariableType getVariableType()
Specified by:
getVariableType in interface Variable

pretty

public String pretty()
Description copied from interface: IPretty
pretty printing of the object. This String is not constant and may depend on the context.

Specified by:
pretty in interface IPretty
Overrides:
pretty in class VariableArray
Returns:
a readable string representation of the object

toString

public String toString()
Overrides:
toString in class ModelObject
See Also:
Object.toString()

compareTo

public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.

It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals."

In the foregoing description, the notation sgn(expression) designates the mathematical signum function, which is defined to return one of -1, 0, or 1 according to whether the value of expression is negative, zero or positive.

Specified by:
compareTo in interface Comparable
Parameters:
o - the object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the specified object's type prevents it from being compared to this object.

_addConstraint

public final void _addConstraint(Constraint c)
Specified by:
_addConstraint in interface IConstraintList

_removeConstraint

public final void _removeConstraint(Constraint c)
Specified by:
_removeConstraint in interface IConstraintList

_contains

public boolean _contains(Constraint c)
Specified by:
_contains in interface IConstraintList

getConstraintIterator

@Deprecated
public Iterator<Constraint> getConstraintIterator()
Deprecated. 

Specified by:
getConstraintIterator in interface Variable

getConstraintIterator

public final Iterator<Constraint> getConstraintIterator(Model m)
Specified by:
getConstraintIterator in interface IConstraintList

getConstraints

public Constraint[] getConstraints()
Specified by:
getConstraints in interface IConstraintList

getConstraint

public final Constraint getConstraint(int idx)
Specified by:
getConstraint in interface IConstraintList

getNbConstraint

@Deprecated
public int getNbConstraint()
Deprecated. 

Specified by:
getNbConstraint in interface Variable

getNbConstraint

public int getNbConstraint(Model m)
Specified by:
getNbConstraint in interface IConstraintList

removeConstraints

public void removeConstraints()
Specified by:
removeConstraints in interface IConstraintList

getHook

public final int getHook()
Description copied from interface: IHook
get the current hook value

Specified by:
getHook in interface IHook

resetHook

public final void resetHook()
Description copied from interface: IHook
reset the hook, it allows to set a new value.

Specified by:
resetHook in interface IHook

setHook

public final void setHook(int hook)
Description copied from interface: IHook
you should be sure to reset the hook before setting a new hook value

Specified by:
setHook in interface IHook
Parameters:
hook - the new hook value


Copyright © 2012. All Rights Reserved.