Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: javatools/db/DbTrueExpr.java


1   /*
2       Javatools (modified version) - Some useful general classes.
3       Copyright (C) 2002-2003  Chris Bitmead (original) Antonio Petrelli (modified)
4   
5       This program is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published by
7       the Free Software Foundation; either version 2 of the License, or
8       (at your option) any later version.
9   
10      This program is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13      GNU General Public License for more details.
14  
15      You should have received a copy of the GNU General Public License
16      along with this program; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  
19      Contact me at: brenmcguire@users.sourceforge.net
20   */
21  package javatools.db;
22  import java.sql.*;
23  
24  /**
25   * An expression that always evaluates to true. If not optimised away but
26   * DbAndExpr, this will probably result in "0 = 0" in the SQL. <P>
27   *
28   * The use of true expressions makes it very convenient for dynamically
29   * generated queries...
30   * <PRE>
31   * DbExpr e = db.trueExpr();
32   * if (name != null) {
33   *  e = e.and(table.getColumn("NAME")).equals(name));
34   * }
35   * if (age != null) {
36   *   e = e.and(table.getColumn("AGE")).equals(age));
37   * }
38   * </PRE>
39   * This gets converted to...
40   * <PRE>
41   * (0 = 0) AND ( NAME = ? ) AND ( AGE = ? )
42   * </PRE>
43   * and then DbAndExpr optimises this to...
44   * <PRE>
45   * ( NAME = ? ) AND ( AGE = ? )
46   * </PRE>
47   *
48   * @author Bitmec
49   * @created 26 September 2001
50   * @see DbAndExpr
51   * @version 0.7
52   */
53  public class DbTrueExpr extends DbCriterion {
54      /** Creates a new DbTrueExpr expression.
55       * @param db The database to use.
56       */    
57    public DbTrueExpr(DbDatabase db) {
58      super(db, "0", "=", "0");
59    }
60  }