uk.ac.man.cs.rainbow.datamodel
Class Data.Word

java.lang.Object
  |
  +--uk.ac.man.cs.rainbow.rapa.data.Expression
        |
        +--uk.ac.man.cs.rainbow.datamodel.Data
              |
              +--uk.ac.man.cs.rainbow.datamodel.Data.Word
All Implemented Interfaces:
Argument, Data.Comparable, Serializable, Value, VariableContainer
Enclosing class:
Data

public static class Data.Word
extends Data
implements Serializable, Data.Comparable

Basic "word" datatypes.

See Also:
Data, Type, Type.Boolean, Type.Integer, Type.Enum, Serialized Form

Inner Class Summary
static interface Data.Word.RestrictingT
          Some word types can restrict the range of the underlying word.
static interface Data.Word.T
          What special operations must the type of a word implement?
 
Inner classes inherited from class uk.ac.man.cs.rainbow.datamodel.Data
Data.Comparable, Data.List, Data.Union, Data.Untyped, Data.Word
 
Field Summary
protected  int value
           
 
Constructor Summary
Data.Word(boolean value)
          Create a new word whose type is that of an boolean.
Data.Word(int value)
          Create a new word whose type is that of an integer.
Data.Word(int value, Type type)
          Create a new word whose type is that specified.
 
Method Summary
 Data cast(Type t)
          Return a new data value that has the given type.
 int compare(Data.Comparable d)
          Check for relative ordering with respect to this object.
 boolean equals(Data d)
          Standardised equality defined over data values with equal types.
 int getValue()
           
 int hashCode()
          Hash-code generator.
protected  void setType(Type t)
           
 String toString()
          Print the data value.
 
Methods inherited from class uk.ac.man.cs.rainbow.datamodel.Data
apply, equals, equals, getResultType, getType, hasVariable, main, occurs, parse, parse, subst, typedString, unify
 
Methods inherited from class uk.ac.man.cs.rainbow.rapa.data.Expression
compatableWith, evaluate, getNodeType, subst
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected int value
Constructor Detail

Data.Word

public Data.Word(int value)
Create a new word whose type is that of an integer.

Data.Word

public Data.Word(boolean value)
Create a new word whose type is that of an boolean.

Data.Word

public Data.Word(int value,
                 Type type)
          throws TypeException
Create a new word whose type is that specified.
Method Detail

toString

public String toString()
Description copied from class: Data
Print the data value.
Overrides:
toString in class Data

getValue

public int getValue()

setType

protected void setType(Type t)
                throws TypeException

equals

public boolean equals(Data d)
Description copied from class: Data
Standardised equality defined over data values with equal types. Implemented by concrete subclasses.
Overrides:
equals in class Data

cast

public Data cast(Type t)
          throws TypeException
Description copied from class: Data
Return a new data value that has the given type.
Overrides:
cast in class Data
Following copied from class: uk.ac.man.cs.rainbow.datamodel.Data
Throws:
TypeException - Thrown if the data value being cast from (or some part of it) disgrees with the type (or type component) that is being specified for it.

hashCode

public int hashCode()
Description copied from class: Data
Hash-code generator. Implemented so that data values that print the same way have the same hashCode (and ought to satisfy equals() too...)
Overrides:
hashCode in class Data

compare

public int compare(Data.Comparable d)
            throws TypeException
Description copied from interface: Data.Comparable
Check for relative ordering with respect to this object.
Specified by:
compare in interface Data.Comparable
Following copied from interface: uk.ac.man.cs.rainbow.datamodel.Data.Comparable
Parameters:
otherComparable - Comparable object to compare with.
Returns:
Negative if this object is less, positive if this object is more, and zero if this object is the same. Zero should only be returned if equals would return true.
Throws:
TypeException - If the objects are not of a similar-enough type to compare.