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

public class Cell
extends java.lang.Object
implements 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
private  int annotation
           
private  java.lang.String annotationID
           
static int ASG_COLLECTION_SIZE_ITEMS
           
static int ASG_COLLECTION_SIZE_ITEMS_TIMES_TUPLE_TYPE
           
private  int cellLevel
           
private  java.lang.Object data
           
private  java.util.Calendar date
           
private  double floatNumber
           
private static java.lang.String[] indents
           
private  long intNumber
           
private  boolean join_annotation
           
private  Cell l
           
private static int MAX_INDENT
           
private  int optimisation_annotation
           
private  Cell r
           
private  int tag
           
static int TAG_APPLY
           
static int TAG_CONSTRUCTOR
           
static int TAG_DATETIME
           
static int TAG_FLOAT
           
static int TAG_FUNCTION
           
static int TAG_INTEGER
           
static int TAG_LAMBDA
           
static int TAG_SCHEME
           
static int TAG_SPECIAL
           
static int TAG_STRING
           
static int TAG_SYSCONSTRUCTOR
           
static int TAG_SYSVARIABLE
           
static int TAG_VARIABLE
           
 
Constructor Summary
private Cell()
           
  Cell(java.util.Calendar d)
           
  Cell(java.util.Date d)
           
  Cell(int snum, java.util.Calendar d)
           
  Cell(int snum, double f)
           
  Cell(int snum, long 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
static int compareNodes(Cell x, Cell y)
           
 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)
           
 boolean equalsButForConstants(java.lang.Object o)
           
 boolean equalsButForConstantsCell(java.lang.Object o)
           
 boolean equalsCell(java.lang.Object o)
           
 void explore()
           
private  void explore(int indent, java.io.PrintStream ps)
           
 void explore(java.io.PrintStream ps)
           
 int getAnnotation()
           
 java.lang.String getAnnotationID()
           
 int getCellLevel()
           
 long getCollectionSize(Cell c, int option)
           
 java.util.Calendar getDateTime()
           
 double getFloat()
           
 long getInt()
           
 boolean getJoinAnnotation()
           
 int getOptimisationAnnotation()
           
 int hashCode()
           
 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 isNull()
          Returns true if the Cell represents a null value
 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.
private  void printIndent(java.io.PrintStream ps, int indent)
           
 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(FunctionTable ft)
           
 boolean representsFunction(java.lang.String function, FunctionTable ft)
           
 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 setAnnotationID(java.lang.String s)
           
 void setCellLevel(int cellLevel)
           
 void setData(java.lang.Object newData)
          Sets the Cell's data
private  void setDataValue()
          Set cell's actual 'value' from tag
 void setDateTime(java.util.Calendar c)
           
 void setFloat(double f)
           
 void setInt(long i)
           
 void setJoinAnnotation(boolean value)
           
 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 text(boolean withOBID)
           
 java.lang.String textOBID()
          Deprecated. use @link{#text(boolean)} instead
 java.lang.String toString()
           
 Cell toStringType()
           
private  int tupleTest()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TAG_APPLY

public static final int TAG_APPLY
See Also:
Constant Field Values

TAG_LAMBDA

public static final int TAG_LAMBDA
See Also:
Constant Field Values

TAG_SCHEME

public static final int TAG_SCHEME
See Also:
Constant Field Values

TAG_CONSTRUCTOR

public static final int TAG_CONSTRUCTOR
See Also:
Constant Field Values

TAG_VARIABLE

public static final int TAG_VARIABLE
See Also:
Constant Field Values

TAG_FUNCTION

public static final int TAG_FUNCTION
See Also:
Constant Field Values

TAG_SPECIAL

public static final int TAG_SPECIAL
See Also:
Constant Field Values

TAG_SYSVARIABLE

public static final int TAG_SYSVARIABLE
See Also:
Constant Field Values

TAG_INTEGER

public static final int TAG_INTEGER
See Also:
Constant Field Values

TAG_FLOAT

public static final int TAG_FLOAT
See Also:
Constant Field Values

TAG_STRING

public static final int TAG_STRING
See Also:
Constant Field Values

TAG_DATETIME

public static final int TAG_DATETIME
See Also:
Constant Field Values

TAG_SYSCONSTRUCTOR

public static final int TAG_SYSCONSTRUCTOR
See Also:
Constant Field Values

tag

private int tag

l

private Cell l

r

private Cell r

data

private java.lang.Object data

intNumber

private long intNumber

floatNumber

private double floatNumber

date

private java.util.Calendar date

annotation

private int annotation

optimisation_annotation

private int optimisation_annotation

join_annotation

private boolean join_annotation

cellLevel

private int cellLevel

annotationID

private java.lang.String annotationID

MAX_INDENT

private static final int MAX_INDENT
See Also:
Constant Field Values

indents

private static final java.lang.String[] indents

ASG_COLLECTION_SIZE_ITEMS

public static final int ASG_COLLECTION_SIZE_ITEMS
See Also:
Constant Field Values

ASG_COLLECTION_SIZE_ITEMS_TIMES_TUPLE_TYPE

public static final int ASG_COLLECTION_SIZE_ITEMS_TIMES_TUPLE_TYPE
See Also:
Constant Field Values
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,
            long i)

Cell

public Cell(int snum,
            double f)

Cell

public Cell(int snum,
            java.util.Calendar d)

Cell

public Cell(java.util.Calendar d)

Cell

public Cell(java.util.Date d)

Cell

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

Cell

public Cell(java.lang.String sdata)

Cell

private Cell()
Method Detail

text

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

Parameters:
withOBID - when set true, the schemes are annotated with their OBID. Useful for debugging, but produces a representation that is not parsable.

text

public java.lang.String text(boolean withOBID)

textOBID

public java.lang.String textOBID()
Deprecated. use @link{#text(boolean)} instead


data

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


setInt

public void setInt(long i)

setFloat

public void setFloat(double f)

setDateTime

public void setDateTime(java.util.Calendar c)

getInt

public long getInt()

getFloat

public double getFloat()

getDateTime

public java.util.Calendar getDateTime()

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


isNull

public boolean isNull()
Returns true if the Cell represents a null value


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


tupleTest

private int tupleTest()

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)
Parameters:
annotation - sets the annotation for this cell
Throws:
java.lang.Exception

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

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(FunctionTable ft)

representsFunction

public boolean representsFunction(java.lang.String function,
                                  FunctionTable ft)

representsFunction

public boolean representsFunction()

representsNestedComprehension

public boolean representsNestedComprehension()
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

equalsCell

public boolean equalsCell(java.lang.Object o)

equalsButForConstants

public boolean equalsButForConstants(java.lang.Object o)

equalsButForConstantsCell

public boolean equalsButForConstantsCell(java.lang.Object o)

toString

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

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

printIndent

private void printIndent(java.io.PrintStream ps,
                         int indent)

explore

public void explore()

explore

public void explore(java.io.PrintStream ps)

explore

private void explore(int indent,
                     java.io.PrintStream ps)

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

setDataValue

private void setDataValue()
                   throws ParseException
Set cell's actual 'value' from tag

Throws:
ParseException

getAnnotationID

public java.lang.String getAnnotationID()

setAnnotationID

public void setAnnotationID(java.lang.String s)

getCellLevel

public int getCellLevel()

setCellLevel

public void setCellLevel(int cellLevel)

getJoinAnnotation

public boolean getJoinAnnotation()

setJoinAnnotation

public void setJoinAnnotation(boolean value)

getCollectionSize

public long getCollectionSize(Cell c,
                              int option)

compareNodes

public static int compareNodes(Cell x,
                               Cell y)
                        throws QProcException
Parameters:
x -
y -
Returns:
1 if x>y, -1 if x<y, 0 if they are equal
Throws:
QProcException