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

Quick Search    Search Deep

Source code: javatools/db/DbFalseExpr.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 false. If not optimised away by
26   * DbTrueExpr, it will probably result in "0 = 1" in the SQL.
27   * <P>
28   * The use of false expressions makes it very convenient for dynamically
29   * generated queries...
30   *
31   * <PRE>
32   * DbExpr e = db.falseExpr();
33   * if (name != null) {
34   *  e = e.or(table.getColumn("NAME")).equals(name));
35   * }
36   * if (age != null) {
37   *  e = e.or(table.getColumn("AGE")).equals(age));
38   * }
39   * </PRE>
40   * This gets converted to...
41   * <PRE>
42   * (0 = 1) OR ( NAME = ? ) OR ( AGE = ? )
43   * </PRE>
44   * and then DbOrExpr optimises this to...
45   * <PRE>
46   * ( NAME = ? ) OR ( AGE = ? )
47   * </PRE>
48   *
49   * @author Bitmec
50   * @created 26 September 2001
51   * @see DbOrExpr
52   * @version 0.7
53   * @commentedby Antonio Petrelli
54   */
55  
56  public class DbFalseExpr extends DbCriterion {
57      /** Builds a new false expression.
58       * @param db The database that will be used.
59       */    
60    public DbFalseExpr(DbDatabase db) {
61      super(db, "0", "=", "1");
62    }
63  }