: Class Literal

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ModSQL
Class Literal

    java.lang.Object
      |
      +--ModSQL.Literal

All Implemented Interfaces:
  Function

final class Literal
extends Object
implements Function

Wrapper for literal values.

Author:
  chris.studholme@utoronto.ca

Field Summary
`protected int` | `type` SQL type of value.
`protected Object` | `value` Literal value.

Fields inherited from interface ModSQL.Function
`MATCH_BEGINS, MATCH_EQU, MATCH_GT, MATCH_GTE, MATCH_LT, MATCH_LTE, MATCH_NE`

Constructor Summary
`Literal()` Constructor for null value.
`Literal(boolean b)` Constructor for boolean.
`Literal(double d)` Constructor for double.
`Literal(int i)` Constructor for integer.
`Literal(long l)` Constructor for long.
`Literal(Object s)` Constructor for java object.

Method Summary
`void` | `addParameter(Function item)` Adds a parameter to the list of parameters.
`Object` | `evaluate(boolean aggregate)` Returns the literal value.
`Object` | `evaluate(int match_op, Object match_value)` Returns the literal value.
`void` | `evaluateOrder(int index, int order)` Specify the order in which the parameters should be evaluated.
`int` | `getMaxResultSize()` If the literal is a String, this method returns the length of the String.
`Function` | `getParameter(int index)` Get a particular parameter.
`int` | `getParameterCount()` Get the number of parameters.
`int` | `getSQLType()` Return the SQL type of the literal value.
`boolean` | `isAggregate()` Determine if this function will return a value that is an aggregate of many database rows.
`boolean` | `isConstant()` Determine if this function returns a constant value.
`void` | `optimize()` Does nothing.
`void` | `registerWith(Object o)` Does nothing as a Literal has no parameters.
`void` | `reset()` Does nothing.
`String` | `toString()` Return human readable version of literal.

Methods inherited from class java.lang.Object
`, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait`

Field Detail

### value

    protected Object value

  Literal value.

### type

    protected int type

  SQL type of value.

Constructor Detail

### Literal

    public Literal()

  Constructor for null value.

### Literal

    public Literal(Object s)

  Constructor for java object.
  Parameters:
    `s` - object literal

### Literal

    public Literal(int i)

  Constructor for integer.
  Parameters:
    `i` - integer literal

### Literal

    public Literal(long l)

  Constructor for long.
  Parameters:
    `l` - long literal

### Literal

    public Literal(double d)

  Constructor for double.
  Parameters:
    `d` - double literal

### Literal

    public Literal(boolean b)

  Constructor for boolean.
  Parameters:
    `b` - boolean literal

Method Detail

### toString

    public String toString()

  Return human readable version of literal.
  Overrides:
    `toString` in class `Object`
  Returns:
    human readable literal

### getParameterCount

    public int getParameterCount()

  Get the number of parameters. Always returns 0 as parameters are not supported.
  Specified by:
    `getParameterCount` in interface `Function`
  Returns:
    number of parameters

### getParameter

    public Function getParameter(int index)

  Get a particular parameter. Always throws an exception as parameters are not supported.
  Specified by:
    `getParameter` in interface `Function`
  Parameters:
    `index` - index of parameter to get
  Returns:
    parameter (function)
  Throws:
    `IndexOutOfBoundsException` - always

### addParameter

    public void addParameter(Function item)
                      throws SQLException

  Adds a parameter to the list of parameters. Always throws an exception as parameters are not supported.
  Specified by:
    `addParameter` in interface `Function`
  Parameters:
    `item` - function to add
  Throws:
    `SQLException` - always

### evaluateOrder

    public void evaluateOrder(int index,
                              int order)

  Specify the order in which the parameters should be evaluated. Always throws an exception as parameters are not supported.
  Specified by:
    `evaluateOrder` in interface `Function`
  Parameters:
    `index` - index of parameter
    `order` - number indicating order in which parameter is evaluated
  Throws:
    `IndexOutOfBoundsException` - always

### registerWith

    public void registerWith(Object o)

  Does nothing as a Literal has no parameters.
  Specified by:
    `registerWith` in interface `Function`
  Parameters:
    `o` - object to register with

### optimize

    public void optimize()

  Does nothing.
  Specified by:
    `optimize` in interface `Function`
  Following copied from interface: `ModSQL.Function`
  Throws:
    `SQLException` - if an error occurs

### isConstant

    public boolean isConstant()

  Determine if this function returns a constant value. Always returns true for literal values.
  Specified by:
    `isConstant` in interface `Function`
  Returns:
    true

### isAggregate

    public boolean isAggregate()

  Determine if this function will return a value that is an aggregate of many database rows. Always returns false for literal values.
  Specified by:
    `isAggregate` in interface `Function`
  Returns:
    false

### getSQLType

    public int getSQLType()

  Return the SQL type of the literal value.
  Specified by:
    `getSQLType` in interface `Function`
  Returns:
    SQL type of data to be returned

### getMaxResultSize

    public int getMaxResultSize()

  If the literal is a String, this method returns the length of the String. Otherwise, -1 is returned.
  Specified by:
    `getMaxResultSize` in interface `Function`
  Returns:
    length of String or -1 if literal is not a String

### evaluate

    public Object evaluate(boolean aggregate)

  Returns the literal value.
  Specified by:
    `evaluate` in interface `Function`
  Parameters:
    `aggregate` - true to get final aggregate value
  Returns:
    result object

### evaluate

    public Object evaluate(int match_op,
                           Object match_value)

  Returns the literal value.
  Specified by:
    `evaluate` in interface `Function`
  Parameters:
    `match_op` - how the value should be matched
    `match_value` - desired value
  Returns:
    result object

### reset

    public void reset()

  Does nothing.
  Specified by:
    `reset` in interface `Function`
  Following copied from interface: `ModSQL.Function`
  Throws:
    `SQLException` - if an error occurs

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD