Java Doc for SQLQuery.java in  » Report » datavision-1.1.0 » jimm » datavision » source » sql » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » datavision 1.1.0 » jimm.datavision.source.sql 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   jimm.datavision.source.Query
      jimm.datavision.source.sql.SQLQuery

All known Subclasses:   jimm.datavision.source.sql.SubreportQuery,  jimm.datavision.source.ncsql.NCQuery,
SQLQuery
public class SQLQuery extends Query (Code)
Queries build SQL query strings. They contain tables, joins, and where clauses.
author:
   Jim Menard, jimm@io.com
See Also:   ParserHelper


Field Summary
protected  ArrayListpreparedStmtValues
    
protected  Settables
    

Constructor Summary
public  SQLQuery(Report report)
     Constructor.

Method Summary
protected  voidaddParameter(StringBuffer buf, String prevWord, String idAsString)
     Given a parameter id string, add its value(s) to the parameter list and add prepared statement placeholders in the query buffer.
protected  voidaddParameterForDisplay(StringBuffer buf, String prevWord, String idAsString)
     Given a parameter id string, add it and a possible modified previous word to buf.
protected  voidaddTable(Table t)
     Adds the table t to tables, but only if t is not null and is not already in tables.
protected  voidbuildFrom(StringBuffer str)
    
protected  voidbuildJoins(StringBuffer str)
    
protected  voidbuildOrderBy(StringBuffer str)
    
protected  voidbuildSelect(StringBuffer str)
    
protected  voidbuildUserWhereClause(StringBuffer str, boolean forDisplay)
    
protected  voidbuildWhereClause(StringBuffer str, boolean forDisplay)
    
public  voidfindSelectablesUsed()
     Builds collections of the report tables and selectable fields actually used in the report.
public  intgetNumTables()
     Returns the number of tables in the query.
public  CollectiongetTablesUsed()
     Returns a collection containing the tables used by this query.
protected  StringgetWhereClauseForDisplay()
     Returns the where clause string; may be null.
protected  StringgetWhereClauseForPreparedStatement()
     Returns the where clause string; may be null.
public  Stringprepare(String clause)
     Given a clause (really any string), replace all formulas and parameters with their values.
protected  StringqueryAsString(boolean forDisplay)
     Returns the query as either a human-readable SQL statement or a SQL string suitable for building a prepared statement.
public  Stringquoted(String name)
     Quotes those parts of a table or column name that need to be quoted.
public  voidsetParameters(PreparedStatement stmt)
     Given a prepared statement created with the text returned by toPreparedStatementString, plug in all the parameter and formula values.
public  StringtoPreparedStatementString()
     Returns the query as a SQL string suitable for building a prepared statement.
public  StringtoString()
     Returns the query as a human-readable SQL statement, including parameter, formula, and user column display strings.

Field Detail
preparedStmtValues
protected ArrayList preparedStmtValues(Code)



tables
protected Set tables(Code)




Constructor Detail
SQLQuery
public SQLQuery(Report report)(Code)
Constructor.
Parameters:
  report - the report for which this query will generate SQL




Method Detail
addParameter
protected void addParameter(StringBuffer buf, String prevWord, String idAsString)(Code)
Given a parameter id string, add its value(s) to the parameter list and add prepared statement placeholders in the query buffer. Appends the previous word to the buffer. The previous word may be modified if the circumstances call for it. For example, we want to turn "foo in {?Range Parameter}" into "foo between ? and ?". The value of prevWord here would be "in". We would append "between" to the buffer and return the "word" "? and ".
Parameters:
  buf - a string buffer containing the SQL query so far
Parameters:
  prevWord - the previous word
Parameters:
  idAsString - the parameter id



addParameterForDisplay
protected void addParameterForDisplay(StringBuffer buf, String prevWord, String idAsString)(Code)
Given a parameter id string, add it and a possible modified previous word to buf. Does not modify preparedStmtValues list.
Parameters:
  buf - a string buffer containing the SQL query so far
Parameters:
  prevWord - the previous word
Parameters:
  idAsString - the parameter id
See Also:   SQLQuery.addParameter



addTable
protected void addTable(Table t)(Code)
Adds the table t to tables, but only if t is not null and is not already in tables. We compare tables by name instead of value (pointer) because different table object may refer to the same table, for example if one is from the report and the other is from a subreport.
Parameters:
  t - a Table



buildFrom
protected void buildFrom(StringBuffer str)(Code)



buildJoins
protected void buildJoins(StringBuffer str)(Code)



buildOrderBy
protected void buildOrderBy(StringBuffer str)(Code)



buildSelect
protected void buildSelect(StringBuffer str)(Code)



buildUserWhereClause
protected void buildUserWhereClause(StringBuffer str, boolean forDisplay)(Code)



buildWhereClause
protected void buildWhereClause(StringBuffer str, boolean forDisplay)(Code)



findSelectablesUsed
public void findSelectablesUsed()(Code)
Builds collections of the report tables and selectable fields actually used in the report.



getNumTables
public int getNumTables()(Code)
Returns the number of tables in the query. Does not recalculate the columns or tables used; we assume this is being called after the query has been run, or at least after findSelectablesUsed has been called.

This method is only used for testing, so far.




getTablesUsed
public Collection getTablesUsed()(Code)
Returns a collection containing the tables used by this query. the collection of tables used by this query



getWhereClauseForDisplay
protected String getWhereClauseForDisplay()(Code)
Returns the where clause string; may be null. If there are any column names contained in curly braces, we remove the curly braces. Formulas, parameters, and user colums remain as-is.

Implementation note: we can't use StringUtils.replaceDelimited because we modify the symbol that appears before some of the delimited items. the where clause string; may be null
See Also:   SQLQuery.getWhereClause




getWhereClauseForPreparedStatement
protected String getWhereClauseForPreparedStatement()(Code)
Returns the where clause string; may be null. If there are any parameter values, we return '?' in their place and save the values for later use.

This code may also modify the clause. For example, a parameter can change the previous comparison operator ("=", "is") based on its arity. the where clause string; may be null
See Also:   SQLQuery.getWhereClause




prepare
public String prepare(String clause)(Code)
Given a clause (really any string), replace all formulas and parameters with their values. Anything else in curly braces must be a column; we remove the curly braces and quote the name.

Implementation note: we can't use StringUtils.replaceDelimited because we modify the symbol that appears before some of the delimited items.




queryAsString
protected String queryAsString(boolean forDisplay)(Code)
Returns the query as either a human-readable SQL statement or a SQL string suitable for building a prepared statement.
Parameters:
  forDisplay - if true return a human-readable string,else return a SQL string suitable for building a prepared statement a SQL string



quoted
public String quoted(String name)(Code)
Quotes those parts of a table or column name that need to be quoted.

Different databases and JDBC drivers treat case sensitively differently. We use the database metadata case sensitivity values to determine which parts of the name need to be quoted.
Parameters:
  name - a table or column name a quoted version of the name




setParameters
public void setParameters(PreparedStatement stmt) throws SQLException(Code)
Given a prepared statement created with the text returned by toPreparedStatementString, plug in all the parameter and formula values.
See Also:   SQLQuery.toPreparedStatementString



toPreparedStatementString
public String toPreparedStatementString()(Code)
Returns the query as a SQL string suitable for building a prepared statement. a SQL query string



toString
public String toString()(Code)
Returns the query as a human-readable SQL statement, including parameter, formula, and user column display strings. a SQL query string



Fields inherited from jimm.datavision.source.Query
final public static int SORT_ASCENDING(Code)(Java Doc)
final public static int SORT_DESCENDING(Code)(Java Doc)
final public static int SORT_UNDEFINED(Code)(Java Doc)
protected ArrayList joins(Code)(Java Doc)
protected Report report(Code)(Java Doc)
protected ArrayList selectables(Code)(Java Doc)
protected ArrayList sortOrders(Code)(Java Doc)
protected ArrayList sortSelectables(Code)(Java Doc)
protected String whereClause(Code)(Java Doc)

Methods inherited from jimm.datavision.source.Query
public void addAllJoins(Collection coll)(Code)(Java Doc)
public void addJoin(Join join)(Code)(Java Doc)
public void addSort(Selectable sel, int order)(Code)(Java Doc)
public void clearJoins()(Code)(Java Doc)
public void clearSorts()(Code)(Java Doc)
public boolean containsReferenceTo(Parameter p)(Code)(Java Doc)
public void findSelectablesUsed()(Code)(Java Doc)
public String getEditableWhereClause()(Code)(Java Doc)
public int getNumSelectables()(Code)(Java Doc)
public String getWhereClause()(Code)(Java Doc)
public int indexOfSelectable(Selectable selectable)(Code)(Java Doc)
public Iterator joins()(Code)(Java Doc)
public void reloadColumns(DataSource dataSource)(Code)(Java Doc)
public void removeJoin(Join join)(Code)(Java Doc)
public void removeSort(Selectable sel)(Code)(Java Doc)
public Iterator selectables()(Code)(Java Doc)
public void setEditableWhereClause(String newWhereClause)(Code)(Java Doc)
public void setWhereClause(String newWhereClause)(Code)(Java Doc)
public int sortOrderOf(Selectable sel)(Code)(Java Doc)
public Iterator sortedSelectables()(Code)(Java Doc)
protected void writeExtras(XMLWriter out)(Code)(Java Doc)
public void writeXML(XMLWriter out)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.