org.gibello.zql
Class ZUpdate

java.lang.Object
  extended by org.gibello.zql.ZUpdate
All Implemented Interfaces:
java.io.Serializable, ZStatement

public class ZUpdate
extends java.lang.Object
implements ZStatement

ZUpdate: an SQL UPDATE statement.

See Also:
Serialized Form

Constructor Summary
ZUpdate(java.lang.String tab)
          Create an UPDATE statement on a given table.
 
Method Summary
 void addColumnUpdate(java.lang.String col, ZExp val)
          Add one column=value pair to the SET... clause This method also keeps track of the column order
 void addSet(java.util.Hashtable t)
          Insert a SET... clause in the UPDATE statement
 void addWhere(ZExp w)
          Insert a WHERE... clause in the UPDATE statement
 java.lang.String getAlias()
           
 ZExp getColumnUpdate(int index)
          Get the SQL expression that specifies a given column's update value.
 ZExp getColumnUpdate(java.lang.String col)
          Get the SQL expression that specifies a given column's update value.
 int getColumnUpdateCount()
          Returns the number of column/value pairs in the SET... clause.
 java.lang.String getColumnUpdateName(int index)
          Get the column name that corresponds to a given index.
 java.util.Hashtable getSet()
          Get the whole SET... clause
 java.lang.String getTable()
           
 ZExp getWhere()
          Get the WHERE clause of this UPDATE statement.
 void setAlias(java.lang.String alias)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZUpdate

public ZUpdate(java.lang.String tab)
Create an UPDATE statement on a given table.

Method Detail

getTable

public java.lang.String getTable()

setAlias

public void setAlias(java.lang.String alias)

getAlias

public java.lang.String getAlias()

addSet

public void addSet(java.util.Hashtable t)
Insert a SET... clause in the UPDATE statement

Parameters:
t - A Hashtable, where keys are column names (the columns to update), and values are ZExp objects (the column values). For example, the values may be ZConstant objects (like "Smith") or more complex SQL Expressions.

getSet

public java.util.Hashtable getSet()
Get the whole SET... clause

Returns:
A Hashtable, where keys are column names (the columns to update), and values are ZExp objects (Expressions that specify column values: for example, ZConstant objects like "Smith").

addColumnUpdate

public void addColumnUpdate(java.lang.String col,
                            ZExp val)
Add one column=value pair to the SET... clause This method also keeps track of the column order

Parameters:
col - The column name
val - The column value

getColumnUpdate

public ZExp getColumnUpdate(java.lang.String col)
Get the SQL expression that specifies a given column's update value. (for example, a ZConstant object like "Smith").

Parameters:
col - The column name.
Returns:
a ZExp, like a ZConstant representing a value, or a more complex SQL expression.

getColumnUpdate

public ZExp getColumnUpdate(int index)
Get the SQL expression that specifies a given column's update value. (for example, a ZConstant object like "Smith").
WARNING: This method will work only if column/value pairs have been inserted using addColumnUpdate() - otherwise it is not possible to guess what the right order is, and null will be returned.

Parameters:
num - The column index (starting from 1).
Returns:
a ZExp, like a ZConstant representing a value, or a more complex SQL expression.

getColumnUpdateName

public java.lang.String getColumnUpdateName(int index)
Get the column name that corresponds to a given index.
WARNING: This method will work only if column/value pairs have been inserted using addColumnUpdate() - otherwise it is not possible to guess what the right order is, and null will be returned.

Parameters:
num - The column index (starting from 1).
Returns:
The corresponding column name.

getColumnUpdateCount

public int getColumnUpdateCount()
Returns the number of column/value pairs in the SET... clause.


addWhere

public void addWhere(ZExp w)
Insert a WHERE... clause in the UPDATE statement

Parameters:
w - An SQL Expression compatible with a WHERE... clause.

getWhere

public ZExp getWhere()
Get the WHERE clause of this UPDATE statement.

Returns:
An SQL Expression compatible with a WHERE... clause.

toString

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