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

java.lang.Object
  |
  +--uk.ac.man.cs.rainbow.rapa.data.Expression
        |
        +--uk.ac.man.cs.rainbow.datamodel.Data
All Implemented Interfaces:
Argument, Serializable, Value, VariableContainer
Direct Known Subclasses:
Data.List, Data.Union, Data.Untyped, Data.Word

public abstract class Data
extends Expression

The core class of data values. The major specialisations are nested top-level classes for convenience of writing.

Of interest are:

See Also:
Type, Serialized Form

Inner Class Summary
static interface Data.Comparable
          Indicate that two data values can be compared for relative order.
static class Data.List
          Compound "list" datatypes.
static class Data.Union
          Union datatypes.
static class Data.Untyped
          The superclass of all Untypeable data classes.
static class Data.Word
          Basic "word" datatypes.
 
Method Summary
 Value apply(Unifier u)
          Apply a unifier to this value to get a new value.
abstract  Data cast(Type t)
          Return a new data value that has the given type.
abstract  boolean equals(Data d)
          Standardised equality defined over data values with equal types.
 boolean equals(Object o)
           
 boolean equals(Value o)
          Standard equality lifted to handle any argument object including data objects with non-equal types.
 Type getResultType()
           
 Type getType()
          Get the type of the data value.
 int hashCode()
          Hash-code generator.
 boolean hasVariable()
           
static void main(String[] args)
          Test code...
 boolean occurs(Substitution s, Variable v)
          Check whether the variable occurs in this value under the given substitution.
static Data parse(String s)
          Attempts to parse the given string to produce a data value.
static Data parse(String s, Hashtable context)
          Attempts to parse the given string (in context) to produce a data value.
 Value subst(Substitution s)
          Apply a substitution to this value to get a new value.
abstract  String toString()
          Print the data value.
 String typedString()
          Print the data value with a type annotation.
 Substitution unify(Substitution s, Value val)
          Get the substitution which unifies this value with the given value, after applying the given substitution.
 
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
 

Method Detail

toString

public abstract String toString()
Print the data value.
Overrides:
toString in class Object

getType

public Type getType()
Get the type of the data value. Returns null for untyped data values.

typedString

public String typedString()
Print the data value with a type annotation. The type annotation is omitted if there is no type available.

cast

public abstract Data cast(Type t)
                   throws TypeException
Return a new data value that has the given type.
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.

equals

public abstract boolean equals(Data d)
Standardised equality defined over data values with equal types. Implemented by concrete subclasses.

equals

public boolean equals(Value o)
Standard equality lifted to handle any argument object including data objects with non-equal types.
Overrides:
equals in class Expression

equals

public boolean equals(Object o)
Overrides:
equals in class Expression

hashCode

public int hashCode()
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 Object

parse

public static Data parse(String s)
                  throws TypeException
Attempts to parse the given string to produce a data value.

parse

public static Data parse(String s,
                         Hashtable context)
                  throws TypeException
Attempts to parse the given string (in context) to produce a data value.

hasVariable

public boolean hasVariable()

apply

public Value apply(Unifier u)
Description copied from interface: Value
Apply a unifier to this value to get a new value.
Overrides:
apply in class Expression

subst

public Value subst(Substitution s)
Description copied from interface: Value
Apply a substitution to this value to get a new value.
Overrides:
subst in class Expression

occurs

public boolean occurs(Substitution s,
                      Variable v)
Description copied from interface: Value
Check whether the variable occurs in this value under the given substitution.
Overrides:
occurs in class Expression

unify

public Substitution unify(Substitution s,
                          Value val)
                   throws NotUnifiable
Description copied from interface: Value
Get the substitution which unifies this value with the given value, after applying the given substitution.
Overrides:
unify in class Expression
Following copied from interface: uk.ac.man.cs.rainbow.rapa.data.Value
Parameters:
subst - The substitution to apply first.
val - The value to unify with this value.
Returns:
The substitution that is the combination of the given substitution and whatever extra substitutions are necessary to unify the two values.
Throws:
NotUnifiable - If the two values cannot be unified.

getResultType

public Type getResultType()
Overrides:
getResultType in class Expression

main

public static void main(String[] args)
Test code...