standup.joke
Class Clause

java.lang.Object
  extended by standup.joke.Clause

public class Clause
extends Object

An output specification function clause. See Chapter 5 (Surface Generation) of the STANDUP backend technical specification document for details. The actual Clause instances themselves should be created by XMLReaders, which reads in details of the OSF clauses from an XML file.

Author:
Ruli Manurung

Field Summary
private  Precondition outSpec
           
private  List<Precondition> preconditions
           
private static String sqlPreconditionTablePrefix
           
private  Precondition tempSpec
           
private  UnifiableListVar tempSpecArgumentQueryableLexemes
           
 
Constructor Summary
Clause(Element clauseElement)
          Constructor for instantiating a Clause specified in an XML Element.
Clause(Precondition outSpec, Precondition tempSpec, List<Precondition> preconditions, UnifiableListVar tempSpecArgumentQueryableLexemes)
          Default constructor providing instances for all fields.
 
Method Summary
private static UnifiableListVar doTAQLVariables(Element e)
           
 Bindings getBindings(UnifiableList outSpecLex, UnifiableList tempSpecLex)
          Returns a Bindings that results from the unification of both the output specifier and the template specifier instantiations.
 List<List<Keyword>> getClauseInstantiations(UnifiableList input, InstantiationConstraint[] constraints)
          This method takes a Clause, a list of JOKEGRAPHNODES!!! that instantiate the input arguments of the Clause, and an array of InstantiationConstraint objects that further constrain the clause instantiations, and sends a query to the SQL server to retrieve all valid clause instantiations.
static List<List<Keyword>> getClauseInstantiationsCombined(List<Clause> clauses, UnifiableList input, InstantiationConstraint[] constraints)
           
private  List<Precondition> getDuplicateFunctorPreconditions(String functor, List<Precondition> precondCopy, Hashtable<Precondition,String> dupeFunctorNames)
           
private  String getFieldByIndex(int index)
          This method returns the SQL field name for a precondition argument.
 String getInstantiationQuery(UnifiableList inputs, InstantiationConstraint[] constraints)
          Returns an SQL query string that returns all valid instantiations for this Clause, where it has been bound to Schema instantiations specified by inputs.
 Precondition getOutSpec()
           
 List<Precondition> getPreconditions()
           
 UnifiableListVar getQueryableTempSpecVars()
           
 Precondition getTempSpec()
           
 UnifiableCompound instantiateOutSpec(Bindings b)
           
 UnifiableCompound instantiateTempSpec(Bindings b)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sqlPreconditionTablePrefix

private static final String sqlPreconditionTablePrefix
See Also:
Constant Field Values

outSpec

private final Precondition outSpec

tempSpec

private final Precondition tempSpec

preconditions

private final List<Precondition> preconditions

tempSpecArgumentQueryableLexemes

private final UnifiableListVar tempSpecArgumentQueryableLexemes
Constructor Detail

Clause

public Clause(Element clauseElement)
Constructor for instantiating a Clause specified in an XML Element.

Parameters:
clauseElement -

Clause

public Clause(Precondition outSpec,
              Precondition tempSpec,
              List<Precondition> preconditions,
              UnifiableListVar tempSpecArgumentQueryableLexemes)
Default constructor providing instances for all fields.

Parameters:
outSpec -
tempSpec -
preconditions -
tempSpecArgumentQueryableLexemes -
Method Detail

getQueryableTempSpecVars

public UnifiableListVar getQueryableTempSpecVars()

getPreconditions

public List<Precondition> getPreconditions()

toString

public String toString()
Overrides:
toString in class Object

getBindings

public Bindings getBindings(UnifiableList outSpecLex,
                            UnifiableList tempSpecLex)
Returns a Bindings that results from the unification of both the output specifier and the template specifier instantiations.

Parameters:
outSpecLex -
tempSpecLex -
Returns:

getOutSpec

public Precondition getOutSpec()

getTempSpec

public Precondition getTempSpec()

instantiateOutSpec

public UnifiableCompound instantiateOutSpec(Bindings b)

instantiateTempSpec

public UnifiableCompound instantiateTempSpec(Bindings b)

getDuplicateFunctorPreconditions

private List<Precondition> getDuplicateFunctorPreconditions(String functor,
                                                            List<Precondition> precondCopy,
                                                            Hashtable<Precondition,String> dupeFunctorNames)

doTAQLVariables

private static UnifiableListVar doTAQLVariables(Element e)

getInstantiationQuery

public String getInstantiationQuery(UnifiableList inputs,
                                    InstantiationConstraint[] constraints)
Returns an SQL query string that returns all valid instantiations for this Clause, where it has been bound to Schema instantiations specified by inputs. Additionally, the instantiations must satisfy the given InstantiationConstraints.

Parameters:
inputs - input values arising from Schema instantiation
constraints - additional constraints on the Clause instantiations
Returns:
an SQL query that returns the required instantiations

getFieldByIndex

private String getFieldByIndex(int index)
This method returns the SQL field name for a precondition argument. The SQL cached tables of lexical preconditions follows the general contract as follows: 1st field: x 2nd field: y 3rd field: z 4th field: w TODO: This should move to SQLUtils


getClauseInstantiations

public List<List<Keyword>> getClauseInstantiations(UnifiableList input,
                                                   InstantiationConstraint[] constraints)
This method takes a Clause, a list of JOKEGRAPHNODES!!! that instantiate the input arguments of the Clause, and an array of InstantiationConstraint objects that further constrain the clause instantiations, and sends a query to the SQL server to retrieve all valid clause instantiations.


getClauseInstantiationsCombined

public static List<List<Keyword>> getClauseInstantiationsCombined(List<Clause> clauses,
                                                                  UnifiableList input,
                                                                  InstantiationConstraint[] constraints)