net.sf.saffron.sql
Class SqlOperator

java.lang.Object
  |
  +--net.sf.saffron.sql.SqlOperator
Direct Known Subclasses:
SqlBinaryOperator, SqlFunction, SqlJoinOperator, SqlPostfixOperator, SqlPrefixOperator, SqlSelectOperator, SqlSpecialOperator

public abstract class SqlOperator
extends Object

A SqlOperator is a type of node in a SQL parse tree (it is NOT a node in a SQL parse tree). It includes functions, operators such as '=', and syntactic constructs such as 'case' statements.


Nested Class Summary
static class SqlOperator.Syntax
          Syntax enumerates possible syntactic types of operators.
static interface SqlOperator.TypeInference
          Strategy to infer the type of an operator call from the type of the operands.
 
Field Summary
 SqlKind kind
           
(package private)  int leftPrec
          The precedence with which this operator binds to the expression to the left.
 String name
           
(package private)  int rightPrec
          The precedence with which this operator binds to the expression to the right.
private  SqlOperator.TypeInference typeInference
           
 
Constructor Summary
(package private) SqlOperator(String name, SqlKind kind, int prec, boolean isLeftAssoc, SqlOperator.TypeInference typeInference)
          Creates an operator specifying left/right associativity.
(package private) SqlOperator(String name, SqlKind kind, int leftPrecedence, int rightPrecedence, SqlOperator.TypeInference typeInference)
          Creates an operator.
 
Method Summary
 SqlCall createCall()
          Creates a call to this operand with no operands.
 SqlCall createCall(SqlNode operand)
          Creates a call to this operand with a single operand.
 SqlCall createCall(SqlNode[] operands)
          Creates a call to this operand with an array of operands.
 SqlCall createCall(SqlNode operand1, SqlNode operand2)
          Creates a call to this operand with two operands.
 SqlCall createCall(SqlNode operand1, SqlNode operand2, SqlNode operand3)
          Creates a call to this operand with three operands.
abstract  int getSyntax()
          Returns the syntactic type of this operator, a value from SqlOperator.Syntax.
 SaffronType getType(SaffronTypeFactory typeFactory, SaffronType[] argTypes)
           
 SaffronType getType(SqlValidator validator, SqlValidator.Scope scope, SqlCall call)
           
(package private)  boolean isA(SqlKind kind)
          Returns whether this is a particular operator.
 String toString()
           
(package private) abstract  void unparse(SqlWriter writer, SqlNode[] operands, int leftPrec, int rightPrec)
          Writes a SQL representation of a call to this operator to a writer, including parentheses if the operators on either side are of greater precedence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public final String name

kind

public final SqlKind kind

leftPrec

final int leftPrec
The precedence with which this operator binds to the expression to the left. This is less than the right precedence if the operator is left-associative.


rightPrec

final int rightPrec
The precedence with which this operator binds to the expression to the right. This is more than the right precedence if the operator is left-associative.


typeInference

private final SqlOperator.TypeInference typeInference
Constructor Detail

SqlOperator

SqlOperator(String name,
            SqlKind kind,
            int leftPrecedence,
            int rightPrecedence,
            SqlOperator.TypeInference typeInference)
Creates an operator.

Pre-condition:
kind != null

SqlOperator

SqlOperator(String name,
            SqlKind kind,
            int prec,
            boolean isLeftAssoc,
            SqlOperator.TypeInference typeInference)
Creates an operator specifying left/right associativity.

Method Detail

toString

public String toString()
Overrides:
toString in class Object

getSyntax

public abstract int getSyntax()
Returns the syntactic type of this operator, a value from SqlOperator.Syntax.


createCall

public SqlCall createCall(SqlNode[] operands)
Creates a call to this operand with an array of operands.


createCall

public SqlCall createCall()
Creates a call to this operand with no operands.


createCall

public SqlCall createCall(SqlNode operand)
Creates a call to this operand with a single operand.


createCall

public SqlCall createCall(SqlNode operand1,
                          SqlNode operand2)
Creates a call to this operand with two operands.


createCall

public SqlCall createCall(SqlNode operand1,
                          SqlNode operand2,
                          SqlNode operand3)
Creates a call to this operand with three operands.


unparse

abstract void unparse(SqlWriter writer,
                      SqlNode[] operands,
                      int leftPrec,
                      int rightPrec)
Writes a SQL representation of a call to this operator to a writer, including parentheses if the operators on either side are of greater precedence.


isA

boolean isA(SqlKind kind)
Returns whether this is a particular operator.


getType

public SaffronType getType(SqlValidator validator,
                           SqlValidator.Scope scope,
                           SqlCall call)

getType

public SaffronType getType(SaffronTypeFactory typeFactory,
                           SaffronType[] argTypes)

SourceForge.net_Logo