net.sourceforge.nite.search.rewriter
Class DeclarableVariable

java.lang.Object
  extended by net.sourceforge.nite.search.rewriter.DeclarableVariable

public class DeclarableVariable
extends java.lang.Object

A class encapsulating details about a variable which is to be declared in a suitable SimpleQuery during a query rewrite. This will be done by SimpleQueryCreator. Records the variable along with the conditions which use it, and a boolean indicating whether or not this variable has been declared yet in a new SimpleQuery.

Author:
Neil Mayo

Constructor Summary
DeclarableVariable(java.lang.String name, java.util.List types)
          Initialise the object with a variable name and types.
DeclarableVariable(java.lang.String name, java.util.List types, boolean exists, boolean forall)
          Initialise the object with a variable name and types, and whether it's declared exists or forall.
 
Method Summary
 void addCondition(MinimalCondition mc)
          Adds a MinimalCondition to the list of conditions which use this variable.
 java.util.List getBareConditions()
          Returns the condition nodes involving this variable.
 int getCardinality()
          Returns the number of conditions involving this variable.
 java.util.List getConditions()
          Returns the conditions involving this variable.
 java.util.List getConditionsOfCardinality(int n)
          Returns all the MinimalCondition objects which are of the given cardinality (those which involve n variables).
 java.lang.String getName()
          Returns the name of the variable.
 java.util.List getTypes()
          Returns a list of the possible types of the variable.
 boolean isExists()
          return true if the variable was declared as 'exists'
 boolean isForall()
          return true if the variable was declared as 'forall'
 boolean isLone()
          Returns true if all the conditions containing this variable contain only this variable (are of cardinality 1).
 void setExists(boolean val)
          set the variable to be an 'exists' var
 void setForall(boolean val)
          set the variable to be an 'forall' var
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DeclarableVariable

public DeclarableVariable(java.lang.String name,
                          java.util.List types)
Initialise the object with a variable name and types.


DeclarableVariable

public DeclarableVariable(java.lang.String name,
                          java.util.List types,
                          boolean exists,
                          boolean forall)
Initialise the object with a variable name and types, and whether it's declared exists or forall.

Method Detail

addCondition

public void addCondition(MinimalCondition mc)
Adds a MinimalCondition to the list of conditions which use this variable. Also updates the MinimalCondition with a reference to this variable.


getCardinality

public int getCardinality()
Returns the number of conditions involving this variable.


getConditions

public java.util.List getConditions()
Returns the conditions involving this variable.


getBareConditions

public java.util.List getBareConditions()
Returns the condition nodes involving this variable.


getTypes

public java.util.List getTypes()
Returns a list of the possible types of the variable.


getName

public java.lang.String getName()
Returns the name of the variable.


getConditionsOfCardinality

public java.util.List getConditionsOfCardinality(int n)
Returns all the MinimalCondition objects which are of the given cardinality (those which involve n variables).


isLone

public boolean isLone()
Returns true if all the conditions containing this variable contain only this variable (are of cardinality 1).


toString

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

isExists

public boolean isExists()
return true if the variable was declared as 'exists'


isForall

public boolean isForall()
return true if the variable was declared as 'forall'


setExists

public void setExists(boolean val)
set the variable to be an 'exists' var


setForall

public void setForall(boolean val)
set the variable to be an 'forall' var