javax.constraints.impl
Class BasicVarString

java.lang.Object
  extended by javax.constraints.impl.CommonBase
      extended by javax.constraints.impl.AbstractConstrainedVariable
          extended by javax.constraints.impl.BasicVarString
All Implemented Interfaces:
ConstrainedVariable, VarString

public class BasicVarString
extends AbstractConstrainedVariable
implements VarString

BasicVarString are a special type of constrained variables that are defined using an array of string values.


Constructor Summary
BasicVarString(Problem problem, java.lang.String[] allStrings)
           
BasicVarString(Problem problem, java.lang.String name, java.lang.String[] allStrings)
           
 
Method Summary
 java.lang.String[] getAllStrings()
          Returns all possible strings from the domain of this variable.
 int getIndex(java.lang.String string)
           
 java.lang.String getInitialDomain()
           
 Var getInt()
          Returns the underlying integer constrained variable.
 java.lang.String getValue()
          Returns a String which is the value to which this variable has been instantiated, throws a RuntimeException if the variable is not instantiated.
 boolean hasSameDomain(VarString var)
           
 boolean isBound()
           
 java.lang.String toString()
           
 
Methods inherited from class javax.constraints.impl.CommonBase
getImpl, getName, getObject, getProblem, setImpl, setName, setObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.constraints.ConstrainedVariable
getImpl, getName, getObject, getProblem, setImpl, setName, setObject
 

Constructor Detail

BasicVarString

public BasicVarString(Problem problem,
                      java.lang.String[] allStrings)

BasicVarString

public BasicVarString(Problem problem,
                      java.lang.String name,
                      java.lang.String[] allStrings)
Method Detail

getAllStrings

public java.lang.String[] getAllStrings()
Returns all possible strings from the domain of this variable.

Specified by:
getAllStrings in interface VarString
Returns:
all possible strings from the domain of this variable.

getIndex

public int getIndex(java.lang.String string)
Specified by:
getIndex in interface VarString
Returns:
an integer index of the "string" inside the domain of this variable.

getInitialDomain

public java.lang.String getInitialDomain()
Specified by:
getInitialDomain in interface VarString
Returns:
a string representing the initial domain of the variable

getInt

public Var getInt()
Returns the underlying integer constrained variable.

Specified by:
getInt in interface VarString
Returns:
the underlying integer constrained variable.

getValue

public java.lang.String getValue()
Returns a String which is the value to which this variable has been instantiated, throws a RuntimeException if the variable is not instantiated.

Specified by:
getValue in interface VarString
Returns:
a String which is the value of this instantiated variable.
Throws:
java.lang.RuntimeException - if this variable is not instantiated.

hasSameDomain

public boolean hasSameDomain(VarString var)
Specified by:
hasSameDomain in interface VarString
Returns:
true if this variable has the same domain as "var"

isBound

public boolean isBound()
Specified by:
isBound in interface VarString
Returns:
true if the variable is bound (domain size is 1)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object