org.castor.cpa.persistence.sql.query.visitor
Class DefaultQueryVisitor

java.lang.Object
  extended by org.castor.cpa.persistence.sql.query.visitor.DefaultQueryVisitor
All Implemented Interfaces:
Visitor
Direct Known Subclasses:
DefaultDoubleQuoteNameQueryVisitor, SapDbQueryVisitor

public class DefaultQueryVisitor
extends Object
implements Visitor

Class representing a alias of a specific table or a database.

Version:
$Revision: 8469 $ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $
Author:
Dennis Butterstein, Ralf Joachim

Field Summary
protected  StringBuilder _queryString
          StringBuilder used to append query string.
protected static org.apache.commons.logging.Log LOG
          The Jakarta Commons Logging instance used for all logging.
 
Constructor Summary
DefaultQueryVisitor()
           
 
Method Summary
protected  void addTableNames(Qualifier qualifier)
          Method adding table-names in case of joins.
protected  String getSequenceNextValString(String seqName)
          Returns the database engine specific string to fetch sequence next value.
protected  void handleJoinConstruction(Qualifier qualifier)
          Method handling construction of joins.
protected  void handleLock(Select select)
          Method appending lock clauses as "FOR UPDATE" when needed.
protected  String quoteName(String name)
          Method returning prepared string to match requirements of specific databases if needed.
 String toString()
          Method returning constructed String.
 void visit(AndCondition andCondition)
          Visit method to handle AndCondition elements.
 void visit(Assignment assignment)
          Visit method to handle Assignment elements.
 void visit(Column column)
          Visit method to handle Column elements.
 void visit(Compare compare)
          Visit method to handle Compare elements.
 void visit(Delete delete)
          Visit method to handle Delete elements.
 void visit(Insert insert)
          Visit method to handle Insert elements.
 void visit(IsNullPredicate isNullPredicate)
          Visit method to handle IsNullPredicate elements.
 void visit(Join join)
          Visit method to handle Join elements.
 void visit(NextVal nextVal)
          Visit method to handle NextVal elements.
 void visit(OrCondition orCondition)
          Visit method to handle OrCondition elements.
 void visit(Parameter parameter)
          Visit method to handle Parameter elements.
 void visit(Select select)
          Visit method to handle select elements.
 void visit(Table table)
          Visit method to handle Table elements.
 void visit(TableAlias tableAlias)
          Visit method to handle TableAlias elements.
 void visit(Update update)
          Visit method to handle update elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_queryString

protected final StringBuilder _queryString
StringBuilder used to append query string.


LOG

protected static final org.apache.commons.logging.Log LOG
The Jakarta Commons Logging instance used for all logging.

Constructor Detail

DefaultQueryVisitor

public DefaultQueryVisitor()
Method Detail

visit

public void visit(Assignment assignment)
Visit method to handle Assignment elements.

Specified by:
visit in interface Visitor
Parameters:
assignment - Assignment object to be handled.

visit

public void visit(Delete delete)
Visit method to handle Delete elements.

Specified by:
visit in interface Visitor
Parameters:
delete - Delete object to be handled.

visit

public void visit(Insert insert)
Visit method to handle Insert elements.

Specified by:
visit in interface Visitor
Parameters:
insert - Insert object to be handled.

visit

public void visit(Join join)
Visit method to handle Join elements.

Specified by:
visit in interface Visitor
Parameters:
join - Join object to be handled

visit

public void visit(Select select)
Visit method to handle select elements.

Specified by:
visit in interface Visitor
Parameters:
select - Select object to be handled.

handleJoinConstruction

protected final void handleJoinConstruction(Qualifier qualifier)
Method handling construction of joins. If Processing of joins is delegated to visit(Table) and visit(TableAlias) method we get the problem that they are processed by every class holding qualifier as well (e. g. compare). This behavior can result in an infinite loop.

Parameters:
qualifier - Qualifier to process joins from.

addTableNames

protected void addTableNames(Qualifier qualifier)
Method adding table-names in case of joins. Normal table => Adding table name only, Aliased table => adding table name SPACE table alias.

Parameters:
qualifier - Qualifier to add names from

visit

public void visit(Table table)
Visit method to handle Table elements.

Specified by:
visit in interface Visitor
Parameters:
table - Table object to be handled.

visit

public void visit(TableAlias tableAlias)
Visit method to handle TableAlias elements.

Specified by:
visit in interface Visitor
Parameters:
tableAlias - TableAlias object to be handled.

visit

public void visit(Update update)
Visit method to handle update elements.

Specified by:
visit in interface Visitor
Parameters:
update - Update object to be handled.

visit

public void visit(AndCondition andCondition)
Visit method to handle AndCondition elements.

Specified by:
visit in interface Visitor
Parameters:
andCondition - AndCondition object to be handled.

visit

public void visit(Compare compare)
Visit method to handle Compare elements.

Specified by:
visit in interface Visitor
Parameters:
compare - Compare object to be handled.

visit

public void visit(IsNullPredicate isNullPredicate)
Visit method to handle IsNullPredicate elements.

Specified by:
visit in interface Visitor
Parameters:
isNullPredicate - IsNullPredicate object to be handled.

visit

public void visit(OrCondition orCondition)
Visit method to handle OrCondition elements.

Specified by:
visit in interface Visitor
Parameters:
orCondition - OrCondition object to be handled.

visit

public void visit(Column column)
Visit method to handle Column elements.

Specified by:
visit in interface Visitor
Parameters:
column - Column object to be handled.

visit

public void visit(NextVal nextVal)
Visit method to handle NextVal elements.

Specified by:
visit in interface Visitor
Parameters:
nextVal - NextVal object to be handled.

visit

public void visit(Parameter parameter)
Visit method to handle Parameter elements.

Specified by:
visit in interface Visitor
Parameters:
parameter - Parameter object to be handled.

quoteName

protected String quoteName(String name)
Method returning prepared string to match requirements of specific databases if needed.

Parameters:
name - String to be prepared.
Returns:
Prepared string.

getSequenceNextValString

protected String getSequenceNextValString(String seqName)
Returns the database engine specific string to fetch sequence next value.

Parameters:
seqName - Name of the sequence.
Returns:
String to fetch sequence next value.

handleLock

protected void handleLock(Select select)
Method appending lock clauses as "FOR UPDATE" when needed.

Parameters:
select - Select to check if locking-clauses have to be appended or not.

toString

public String toString()
Method returning constructed String.

Specified by:
toString in interface Visitor
Overrides:
toString in class Object
Returns:
Constructed query string.


Copyright © 2011. All Rights Reserved.