org.objectweb.cjdbc.sql
Class AbstractRequest

java.lang.Object
  extended byorg.objectweb.cjdbc.sql.AbstractRequest
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AbstractWriteRequest, SelectRequest, StoredProcedure, UnknownRequest

public abstract class AbstractRequest
extends java.lang.Object
implements java.io.Serializable

An AbstractRequest defines the skeleton of an SQL request.

Version:
1.0
Author:
Emmanuel Cecchet, Julie Marguerite, Mathieu Peltier
See Also:
Serialized Form

Field Summary
protected  int cacheable
          Whether this request is cacheable or not.
protected  boolean escapeProcessing
          Should the driver do escape processing before sending to the database?
protected  int id
          Request unique id (set by the controller).
protected  boolean isAutoCommit
          Whether this request has been sent in autocommit mode or not.
protected  boolean isParsed
          Whether the SQL content has been parsed or not.
protected  boolean isReadOnly
          True if the connection has been set to read-only
protected  java.lang.String login
          Login used to issue this request (must be set by the Connection object).
protected  int maxRows
          Maximum number of rows in the ResultSet.
protected  java.lang.String sqlQuery
          SQL query (should be set in constructor).
protected  java.lang.String sqlSkeleton
          SQL query skeleton as it appears in PreparedStatements.
protected  int timeout
          Timeout for this request in seconds, value 0 means no timeout (should be set in constructor).
protected  int transactionId
          Transaction identifier if this request belongs to a transaction.
 
Constructor Summary
AbstractRequest()
           
 
Method Summary
abstract  void cloneParsing(AbstractRequest request)
          Clones the parsing of a request.
 void debug()
          Displays some debugging information about this request.
 boolean equals(java.lang.Object other)
          Two requests are equal if they have the same SQL code.
 int getCacheAbility()
          Returns the cacheable status of this request.
 boolean getEscapeProcessing()
          Returns true if the driver should escape processing before sending to the database?
 int getId()
          Returns the unique id of this request.
 java.lang.String getLogin()
          Returns the login used to issue this request.
 int getMaxRows()
          Get the maximum number of rows the ResultSet can contain.
 java.lang.String getSQL()
          Gets the SQL code of this request.
 java.lang.String getSqlSkeleton()
           
 int getTimeout()
          Gets the timeout for this request in seconds.
 int getTransactionId()
          Gets the identifier of the transaction if this request belongs to a transaction, or -1 if this request does not belong to a transaction.
 boolean isAutoCommit()
          Returns true if the request should be executed in autocommit mode.
 boolean isParsed()
          Returns true if the request SQL content has been already parsed.
 boolean isReadOnly()
          Returns true if the connection is set to read-only
abstract  boolean isReadRequest()
          Returns true if this request is a read request (SELECT requests for example perform a read).
abstract  boolean isUnknownRequest()
          Returns true if the resulting operation on this request is unknown (some non-standard command or stored procedure for example).
abstract  boolean isWriteRequest()
          Returns true if this request is a write request (INSERT or UPDATE for example perform writes).
abstract  void parse(DatabaseSchema schema, int granularity, boolean isCaseSensitive)
          Parses the SQL request and extract the selected columns and tables given the DatabaseSchema of the database targeted by this request.
 void setCacheAbility(int cacheAbility)
          Set the cacheable status of this request.
 void setId(int id)
          Sets the unique id of this request.
 void setIsAutoCommit(boolean isAutoCommit)
          Sets the autocommit mode for this request.
 void setIsReadOnly(boolean isReadOnly)
          Sets the read-only mode for this request.
 void setLogin(java.lang.String login)
          Sets the login to use to issue this request.
 void setMaxRows(int rows)
          Set the maximum number of rows in the ResultSet.
 void setSQL(java.lang.String sql)
          Set the SQL code of this request.
 void setSqlSkeleton(java.lang.String skel)
           
 void setTimeout(int timeout)
          Sets the new timeout in seconds for this request.
 void setTransactionId(int id)
          Sets the transaction identifier this request belongs to.
protected static java.lang.String trimCarriageReturn(java.lang.String s)
          Replaces any carriage returns by a space in a given String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected int id
Request unique id (set by the controller).


sqlQuery

protected java.lang.String sqlQuery
SQL query (should be set in constructor).


sqlSkeleton

protected java.lang.String sqlSkeleton
SQL query skeleton as it appears in PreparedStatements.


login

protected java.lang.String login
Login used to issue this request (must be set by the Connection object).


cacheable

protected int cacheable
Whether this request is cacheable or not.


isParsed

protected boolean isParsed
Whether the SQL content has been parsed or not.


maxRows

protected int maxRows
Maximum number of rows in the ResultSet.

See Also:
Statement.setMaxRows(int)

isReadOnly

protected boolean isReadOnly
True if the connection has been set to read-only


isAutoCommit

protected boolean isAutoCommit
Whether this request has been sent in autocommit mode or not.


transactionId

protected int transactionId
Transaction identifier if this request belongs to a transaction.


timeout

protected int timeout
Timeout for this request in seconds, value 0 means no timeout (should be set in constructor).


escapeProcessing

protected boolean escapeProcessing
Should the driver do escape processing before sending to the database? No setter for this member, should be set in constructor.

Constructor Detail

AbstractRequest

public AbstractRequest()
Method Detail

isReadRequest

public abstract boolean isReadRequest()
Returns true if this request is a read request (SELECT requests for example perform a read).

Returns:
true if this request is a read request

isWriteRequest

public abstract boolean isWriteRequest()
Returns true if this request is a write request (INSERT or UPDATE for example perform writes).

Returns:
true if this requests is a write request

isUnknownRequest

public abstract boolean isUnknownRequest()
Returns true if the resulting operation on this request is unknown (some non-standard command or stored procedure for example).

Returns:
a boolean value

isParsed

public boolean isParsed()
Returns true if the request SQL content has been already parsed.

Returns:
a boolean value

isReadOnly

public boolean isReadOnly()
Returns true if the connection is set to read-only

Returns:
a boolean value

setIsReadOnly

public void setIsReadOnly(boolean isReadOnly)
Sets the read-only mode for this request.

Parameters:
isReadOnly - true if connection is read-only

getCacheAbility

public int getCacheAbility()
Returns the cacheable status of this request. It can be: RequestType.CACHEABLE, RequestType.UNCACHEABLE or RequestType.UNIQUE_CACHEABLE

Returns:
a int value

setCacheAbility

public void setCacheAbility(int cacheAbility)
Set the cacheable status of this request. It can be: RequestType.CACHEABLE, RequestType.UNCACHEABLE or RequestType.UNIQUE_CACHEABLE

Parameters:
cacheAbility - a int value

getEscapeProcessing

public boolean getEscapeProcessing()
Returns true if the driver should escape processing before sending to the database?

Returns:
a boolean value

getId

public int getId()
Returns the unique id of this request.

Returns:
the request id

setId

public void setId(int id)
Sets the unique id of this request.

Parameters:
id - the id to set

isAutoCommit

public boolean isAutoCommit()
Returns true if the request should be executed in autocommit mode.

Returns:
a boolean value

setIsAutoCommit

public void setIsAutoCommit(boolean isAutoCommit)
Sets the autocommit mode for this request.

Parameters:
isAutoCommit - true if autocommit should be used

getLogin

public java.lang.String getLogin()
Returns the login used to issue this request.

Returns:
a String value

setLogin

public void setLogin(java.lang.String login)
Sets the login to use to issue this request.

Parameters:
login - a String value

getSQL

public java.lang.String getSQL()
Gets the SQL code of this request.

Returns:
the SQL query

getMaxRows

public int getMaxRows()
Get the maximum number of rows the ResultSet can contain.

Returns:
maximum number of rows
See Also:
Statement.getMaxRows()

setMaxRows

public void setMaxRows(int rows)
Set the maximum number of rows in the ResultSet.

Parameters:
rows - maximum number of rows
See Also:
Statement.setMaxRows(int)

setSQL

public void setSQL(java.lang.String sql)
Set the SQL code of this request. Warning! The request parsing validity is not checked. The caller has to recall parse(DatabaseSchema, int, boolean) if needed.

Parameters:
sql - SQL statement

getTimeout

public int getTimeout()
Gets the timeout for this request in seconds.

Returns:
timeout in seconds (0 means no timeout)

setTimeout

public void setTimeout(int timeout)
Sets the new timeout in seconds for this request.

Parameters:
timeout - an int value

getTransactionId

public int getTransactionId()
Gets the identifier of the transaction if this request belongs to a transaction, or -1 if this request does not belong to a transaction.

Returns:
transaction identifier or -1

setTransactionId

public void setTransactionId(int id)
Sets the transaction identifier this request belongs to.

Parameters:
id - transaction id

equals

public boolean equals(java.lang.Object other)
Two requests are equal if they have the same SQL code.

Parameters:
other - an object
Returns:
a boolean value

parse

public abstract void parse(DatabaseSchema schema,
                           int granularity,
                           boolean isCaseSensitive)
                    throws java.sql.SQLException
Parses the SQL request and extract the selected columns and tables given the DatabaseSchema of the database targeted by this request.

An exception is thrown when the parsing fails. Warning, this method does not check the validity of the request. In particular, invalid request could be parsed without throwing an exception. However, valid SQL request should never throw an exception.

Parameters:
schema - a DatabaseSchema value
granularity - parsing granularity as defined in ParsingGranularities
isCaseSensitive - true if parsing must be case sensitive
Throws:
java.sql.SQLException - if the parsing fails

cloneParsing

public abstract void cloneParsing(AbstractRequest request)
Clones the parsing of a request.

Parameters:
request - the parsed request to clone

trimCarriageReturn

protected static java.lang.String trimCarriageReturn(java.lang.String s)
Replaces any carriage returns by a space in a given String.

Parameters:
s - the String to transform
Returns:
the transformed String

getSqlSkeleton

public java.lang.String getSqlSkeleton()
Returns:
the SQL query skeleton given in a PreparedStatement.

setSqlSkeleton

public void setSqlSkeleton(java.lang.String skel)
Parameters:
skel - set the SQL query skeleton given in a PreparedStatement.

debug

public void debug()
Displays some debugging information about this request.



Copyright © 2002, 2003 - ObjectWeb Consortium - All Rights Reserved.