uk.ac.bbk.dcs.automed.qproc.iql
Class Cell

java.lang.Object
  extended by uk.ac.bbk.dcs.automed.qproc.iql.Cell
All Implemented Interfaces:
java.io.Serializable, PersistentObject

public class Cell
extends java.lang.Object
implements PersistentObject, java.io.Serializable

Every node in an ASG is a Cell, so one has to use this class in order to perform any operations on an ASG

See Also:
Serialized Form

Field Summary
static int ANNOTATION_COMP_ARG
           
static int ANNOTATION_COMP_ROOT
           
static int ANNOTATION_OPT_DO_NOT_UNNEST
           
static int ANNOTATION_OTHER
           
static int apply
           
static int constructor
           
static int copyGraphCalls
           
static long copyOfGraphTimeSpent
           
static int dateTimeType
           
static int EVALUATION_STATE_EVALUATED
           
static int EVALUATION_STATE_UNKNOWN
           
static int EVALUATION_STATE_WHNF
           
static int floatType
           
static int function
           
static int intType
           
static int lambda
           
protected  java.util.logging.Logger logger
           
static int scheme
           
static int special
           
static int stringType
           
static int sysConstructor
           
static int sysvariable
           
static int variable
           
 
Constructor Summary
Cell(int snum, double f)
           
Cell(int snum, int i)
           
Cell(int snum, java.lang.Object sdata)
           
Cell(int snum, java.lang.Object lRef, java.lang.Object rRef)
           
Cell(int snum, java.lang.Object lRef, java.lang.Object rRef, java.lang.Object sdata)
           
Cell(java.lang.Object lRef, java.lang.Object rRef)
           
Cell(java.lang.String sdata)
           
 
Method Summary
 void annotate(Cell c, boolean inComp)
           
 Cell bsingleton()
          Returns the root of an ASG representing an empty bag
 Cell copyOfGraph()
          Returns an exact copy of the ASG
 java.lang.Object data()
          Returns the Object contained in the Cell
 boolean equals(java.lang.Object o)
           
 void finalize()
           
 int getAnnotation()
           
static long getCreated()
           
 java.lang.String getDate()
           
 java.lang.String getDateTime()
           
 java.lang.String getDay()
           
static long getDestroyed()
           
 int getEvaluationState()
           
 double getFloat()
           
 java.lang.String getHours()
           
 java.lang.String getID()
           
 int getInt()
           
 PersistentKey getKey()
           
 java.lang.String getMinutes()
           
 java.lang.String getMonth()
           
 int getOptimisationAnnotation()
           
 java.util.Map getPersistentAttributes()
           
 java.lang.String getSeconds()
           
 java.lang.String getTime()
           
 java.lang.String getYear()
           
 boolean isApply()
          Returns true if tag is apply
 boolean isBConsConstructor()
          Returns true if tag is "BCons"
 boolean isBNilConstructor()
          Returns true if tag is "BNil"
 boolean isCollectionConstructor()
          Returns true if tag is "Cons", "BCons" or "SCons"
 boolean isCollectionNilConstructor()
          Returns true if tag is "Nil"
 boolean isConsConstructor()
           
 boolean isConstant()
          Returns true if tag is constant
 boolean isConstructor()
          Returns true if tag is constructor
 boolean isConstructor(java.lang.String s)
           
 boolean isConstructorOrSysConstructor()
          Returns true if tag is constructor or system constructor
 boolean isDateTime()
           
 boolean isFloat()
           
 boolean isFunction()
          Returns true if tag is function
 boolean isInteger()
           
 boolean isLambda()
          Returns true if tag is lambda
 boolean isNilConstructor()
          Returns true if tag is "Nil"
 boolean isNum()
          Deprecated. use isNumberType() instead
 boolean isNumberType()
           
 boolean isScheme()
          Returns true if tag is scheme
 boolean isSConsConstructor()
          Returns true if tag is "SCons"
 boolean isSNilConstructor()
          Returns true if tag is "SNil"
 boolean isSpecial()
          Returns true if tag is special
 boolean isSpecial(java.lang.String s)
           
 boolean isString()
           
 boolean isSysConstructor()
          Returns true if tag is system constructor
 boolean isSysConstructor(java.lang.String s)
           
 boolean isSysVariable()
          Returns true if tag is sysvariable
 boolean isVariable()
          Returns true if tag is variable
 boolean isVarOrSysVar()
          Returns true if tag is variable or sysvariable
 Cell l()
          Returns a reference to the left child of the Cell
 void mimicThisCell(Cell n)
          Copies content of all fields of input Cell to current Cell.
 Cell r()
          Returns a reference to the right child of the Cell
 boolean representsBag()
          Returns true if the Cell is the root of an ASG representing a bag
 boolean representsBagComprehension()
           
 boolean representsBSingleton()
           
 boolean representsCollection()
          Returns true if the Cell is the root of an ASG representing a collection
 boolean representsCollectionSingleton()
           
 boolean representsComprehension()
           
 boolean representsConstructor()
           
 boolean representsConstructor(java.lang.String s)
           
 boolean representsFunction()
           
 boolean representsFunction(java.lang.String function, int argNum)
           
 boolean representsGenerator()
          Returns true if the Cell is the root of an ASG representing a generator
 boolean representsLambdaExpression()
           
 boolean representsLet()
           
 boolean representsList()
          Returns true if the Cell is the root of an ASG representing a list
 boolean representsListComprehension()
           
 boolean representsLSingleton()
           
 boolean representsNestedComprehension()
           
 boolean representsPair()
          Returns true if tag is "Tuple2"
 boolean representsSet()
          Returns true if the Cell is the root of an ASG representing a set
 boolean representsSetComprehension()
           
 boolean representsSpecial()
           
 boolean representsSpecial(java.lang.String function, int argNum)
           
 boolean representsSSingleton()
           
 int representsTuple()
          Returns the arity of the tuple, or -1 if Cell does not represent a tuple
 void set_l(Cell n)
          Sets the reference to the left child of the Cell to n
 void set_r(Cell n)
          Sets the reference to the left child of the Cell to n
 void setAnnotation(int annotation)
           
 void setData(java.lang.Object newData)
          Sets the Cell's data
 void setDateTime(java.lang.String s)
           
 void setEvaluationState(int evaluation_state)
           
 void setFloat(double f)
           
 void setFloat(float f)
           
 void setInt(int i)
           
 void setOptimisationAnnotation(int optimisation_annotation)
           
 void setTag(int i)
           
 Cell singleton()
          Returns the root of an ASG representing an empty list
 Cell ssingleton()
          Returns the root of an ASG representing an empty set
 int tag()
          Returns the Cell's tag
 java.lang.String text()
          Returns the string representation of the object contained in the Cell
 java.lang.String textOBID()
           
 java.lang.String toString()
           
 Cell toStringType()
           
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected transient java.util.logging.Logger logger

apply

public static final int apply
See Also:
Constant Field Values

lambda

public static final int lambda
See Also:
Constant Field Values

scheme

public static final int scheme
See Also:
Constant Field Values

constructor

public static final int constructor
See Also:
Constant Field Values

variable

public static final int variable
See Also:
Constant Field Values

function

public static final int function
See Also:
Constant Field Values

special

public static final int special
See Also:
Constant Field Values

sysvariable

public static final int sysvariable
See Also:
Constant Field Values

intType

public static final int intType
See Also:
Constant Field Values

floatType

public static final int floatType
See Also:
Constant Field Values

stringType

public static final int stringType
See Also:
Constant Field Values

dateTimeType

public static final int dateTimeType
See Also:
Constant Field Values

sysConstructor

public static final int sysConstructor
See Also:
Constant Field Values

ANNOTATION_COMP_ROOT

public static final int ANNOTATION_COMP_ROOT
See Also:
Constant Field Values

ANNOTATION_COMP_ARG

public static final int ANNOTATION_COMP_ARG
See Also:
Constant Field Values

ANNOTATION_OTHER

public static final int ANNOTATION_OTHER
See Also:
Constant Field Values

ANNOTATION_OPT_DO_NOT_UNNEST

public static final int ANNOTATION_OPT_DO_NOT_UNNEST
See Also:
Constant Field Values

EVALUATION_STATE_UNKNOWN

public static final int EVALUATION_STATE_UNKNOWN
See Also:
Constant Field Values

EVALUATION_STATE_WHNF

public static final int EVALUATION_STATE_WHNF
See Also:
Constant Field Values

EVALUATION_STATE_EVALUATED

public static final int EVALUATION_STATE_EVALUATED
See Also:
Constant Field Values

copyGraphCalls

public static int copyGraphCalls

copyOfGraphTimeSpent

public static long copyOfGraphTimeSpent
Constructor Detail

Cell

public Cell(int snum,
            java.lang.Object lRef,
            java.lang.Object rRef,
            java.lang.Object sdata)
Parameters:
snum - designates the type of the Cell. Possible values: apply, lambda, constant, scheme, constructor, variable, function, special, sysvariable
lRef - reference to the Cell's left child
rRef - reference to the Cell's right child
sdata - value of sdata depends on snum. Possible values: apply:null, lambda:lambda, constant:(integer, String, ...), scheme:(String), constructor:(String, for example Cons, Tuple2, ...), variable:(String, e.g. x, y, ...), function:(function name), special:Let, sysvariable:(wrapper object)

Cell

public Cell(int snum,
            java.lang.Object lRef,
            java.lang.Object rRef)

Cell

public Cell(int snum,
            java.lang.Object sdata)

Cell

public Cell(int snum,
            int i)

Cell

public Cell(int snum,
            double f)

Cell

public Cell(java.lang.Object lRef,
            java.lang.Object rRef)

Cell

public Cell(java.lang.String sdata)
Method Detail

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

text

public java.lang.String text()
Returns the string representation of the object contained in the Cell


textOBID

public java.lang.String textOBID()

data

public java.lang.Object data()
Returns the Object contained in the Cell


setInt

public void setInt(int i)

setFloat

public void setFloat(float f)

setFloat

public void setFloat(double f)

setDateTime

public void setDateTime(java.lang.String s)

getInt

public int getInt()

getFloat

public double getFloat()

getDateTime

public java.lang.String getDateTime()
                             throws TypeException
Throws:
TypeException

getDate

public java.lang.String getDate()
                         throws TypeException
Throws:
TypeException

getYear

public java.lang.String getYear()
                         throws TypeException
Throws:
TypeException

getMonth

public java.lang.String getMonth()
                          throws TypeException
Throws:
TypeException

getDay

public java.lang.String getDay()
                        throws TypeException
Throws:
TypeException

getTime

public java.lang.String getTime()
                         throws TypeException
Throws:
TypeException

getHours

public java.lang.String getHours()
                          throws TypeException
Throws:
TypeException

getMinutes

public java.lang.String getMinutes()
                            throws TypeException
Throws:
TypeException

getSeconds

public java.lang.String getSeconds()
                            throws TypeException
Throws:
TypeException

isNum

public boolean isNum()
Deprecated. use isNumberType() instead


isNumberType

public boolean isNumberType()

tag

public int tag()
Returns the Cell's tag


l

public Cell l()
Returns a reference to the left child of the Cell


r

public Cell r()
Returns a reference to the right child of the Cell


set_l

public void set_l(Cell n)
Sets the reference to the left child of the Cell to n


set_r

public void set_r(Cell n)
Sets the reference to the left child of the Cell to n


setData

public void setData(java.lang.Object newData)
Sets the Cell's data


setTag

public void setTag(int i)

mimicThisCell

public void mimicThisCell(Cell n)
Copies content of all fields of input Cell to current Cell.


copyOfGraph

public Cell copyOfGraph()
Returns an exact copy of the ASG


singleton

public Cell singleton()
Returns the root of an ASG representing an empty list


bsingleton

public Cell bsingleton()
Returns the root of an ASG representing an empty bag


ssingleton

public Cell ssingleton()
Returns the root of an ASG representing an empty set


isApply

public boolean isApply()
Returns true if tag is apply


isConstructor

public boolean isConstructor(java.lang.String s)
Parameters:
s -
Returns:
true if this is a constructor Cell with name s

isSysConstructor

public boolean isSysConstructor(java.lang.String s)
Parameters:
s -
Returns:
true if this is a system constructor Cell with name s

isLambda

public boolean isLambda()
Returns true if tag is lambda


isConstant

public boolean isConstant()
Returns true if tag is constant


isFloat

public boolean isFloat()

isInteger

public boolean isInteger()

isString

public boolean isString()

isDateTime

public boolean isDateTime()

isScheme

public boolean isScheme()
Returns true if tag is scheme


isConstructor

public boolean isConstructor()
Returns true if tag is constructor


isSysConstructor

public boolean isSysConstructor()
Returns true if tag is system constructor


isConstructorOrSysConstructor

public boolean isConstructorOrSysConstructor()
Returns true if tag is constructor or system constructor


isVariable

public boolean isVariable()
Returns true if tag is variable


isSpecial

public boolean isSpecial()
Returns true if tag is special


isSpecial

public boolean isSpecial(java.lang.String s)

isFunction

public boolean isFunction()
Returns true if tag is function


isSysVariable

public boolean isSysVariable()
Returns true if tag is sysvariable


isVarOrSysVar

public boolean isVarOrSysVar()
Returns true if tag is variable or sysvariable


isCollectionNilConstructor

public boolean isCollectionNilConstructor()
Returns true if tag is "Nil"


isNilConstructor

public boolean isNilConstructor()
Returns true if tag is "Nil"


isBNilConstructor

public boolean isBNilConstructor()
Returns true if tag is "BNil"


isSNilConstructor

public boolean isSNilConstructor()
Returns true if tag is "SNil"


isCollectionConstructor

public boolean isCollectionConstructor()
Returns true if tag is "Cons", "BCons" or "SCons"


isConsConstructor

public boolean isConsConstructor()

isBConsConstructor

public boolean isBConsConstructor()
Returns true if tag is "BCons"


isSConsConstructor

public boolean isSConsConstructor()
Returns true if tag is "SCons"


representsConstructor

public boolean representsConstructor()
Returns:
true if the Cell is the root of an ASG whose leftmost leaf is a constructor

representsConstructor

public boolean representsConstructor(java.lang.String s)
Returns:
true if the Cell is the root of an ASG whose leftmost leaf is a constructor with name s

representsComprehension

public boolean representsComprehension()
Returns:
true if the Cell is the root of an ASG representing a comprehension

representsSetComprehension

public boolean representsSetComprehension()
Returns:
true if the Cell is the root of an ASG representing a set comprehension

representsListComprehension

public boolean representsListComprehension()
Returns:
true if the Cell is the root of an ASG representing a list comprehension

representsBagComprehension

public boolean representsBagComprehension()
Returns:
true if the Cell is the root of an ASG representing a bag comprehension

representsLet

public boolean representsLet()
Returns:
true if the Cell is the root of an ASG representing a comprehension

representsLambdaExpression

public boolean representsLambdaExpression()

representsGenerator

public boolean representsGenerator()
Returns true if the Cell is the root of an ASG representing a generator


representsPair

public boolean representsPair()
Returns true if tag is "Tuple2"


representsTuple

public int representsTuple()
Returns the arity of the tuple, or -1 if Cell does not represent a tuple


representsCollection

public boolean representsCollection()
Returns true if the Cell is the root of an ASG representing a collection


representsList

public boolean representsList()
Returns true if the Cell is the root of an ASG representing a list


representsBag

public boolean representsBag()
Returns true if the Cell is the root of an ASG representing a bag


representsSet

public boolean representsSet()
Returns true if the Cell is the root of an ASG representing a set


representsCollectionSingleton

public boolean representsCollectionSingleton()

representsLSingleton

public boolean representsLSingleton()

representsBSingleton

public boolean representsBSingleton()

representsSSingleton

public boolean representsSSingleton()

setAnnotation

public void setAnnotation(int annotation)
                   throws QProcException
Parameters:
annotation - sets the annotation for this cell
Throws:
java.lang.Exception
QProcException

getAnnotation

public int getAnnotation()
Returns:
the annotation of this cell
Throws:
QProcException

setOptimisationAnnotation

public void setOptimisationAnnotation(int optimisation_annotation)
                               throws QProcException
Parameters:
optimisation_annotation - sets the optimisation annotation for this cell
Throws:
java.lang.Exception
QProcException

getOptimisationAnnotation

public int getOptimisationAnnotation()
Returns:
the optimisation annotation of this cell
Throws:
QProcException

setEvaluationState

public void setEvaluationState(int evaluation_state)
                        throws QProcException
Throws:
QProcException

getEvaluationState

public int getEvaluationState()

representsSpecial

public boolean representsSpecial()

representsSpecial

public boolean representsSpecial(java.lang.String function,
                                 int argNum)

representsFunction

public boolean representsFunction(java.lang.String function,
                                  int argNum)
Parameters:
function - the textual representation of a function name, such as (++), (--), "member", ect.
Returns:
true, if this is an apply cell containing the function specified by the input string

representsFunction

public boolean representsFunction()

representsNestedComprehension

public boolean representsNestedComprehension()
                                      throws QProcException
Returns:
true if c is a nested comprehension
Throws:
QProcException - thrown if the Cell is not actually the root of a comprehension

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toString

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

toStringType

public Cell toStringType()
                  throws QProcException
Throws:
QProcException

annotate

public void annotate(Cell c,
                     boolean inComp)
              throws QProcException
Parameters:
c -
inComp - true if we are within a comprehension, false otherwise.
Throws:
QProcException

getID

public java.lang.String getID()

getKey

public PersistentKey getKey()
Specified by:
getKey in interface PersistentObject

getPersistentAttributes

public java.util.Map getPersistentAttributes()
Specified by:
getPersistentAttributes in interface PersistentObject

getCreated

public static long getCreated()

getDestroyed

public static long getDestroyed()