KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > sql > SqlBinOpLike


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.extractor.sql;
24
25
26 public class SqlBinOpLike extends SqlBinaryOperator
27 {
28
29     private static final String JavaDoc RCSRevision = "$Revision: 1.4 $";
30     private static final String JavaDoc RCSName = "$Name: $";
31
32     private boolean _not = false;
33
34     /**
35     @param leftOperand
36     @param rightOperand
37     @param not
38     @roseuid 3BD177D702F1
39      */

40     public SqlBinOpLike(SqlExpression leftOperand, SqlExpression rightOperand, boolean not)
41     {
42         super ( leftOperand, rightOperand );
43         setNot ( not ) ;
44     }
45
46     /**
47     leftOperand NOT LIKE rightOperand
48     @roseuid 3BD177D702BF
49      */

50     public SqlBinOpLike()
51     {
52
53     }
54
55     /**
56     @param not
57     @roseuid 3BD177D800B8
58      */

59     public void setNot(boolean not)
60     {
61         _not = not ;
62     }
63
64     /**
65     @return boolean
66     @roseuid 3BD177D8013A
67      */

68     public boolean getNot()
69     {
70         return _not ;
71     }
72
73     /**
74     @return String
75     @roseuid 3BD177D8016C
76      */

77     public String JavaDoc toSql(Context context)
78     {
79         //Trace.enter(this,"toSql(Context context)");
80

81         StringBuffer JavaDoc retVal = new StringBuffer JavaDoc();
82
83         retVal.append("(");
84         retVal.append(getLeftOperand().toSql(context));
85         retVal.append(")");
86         if ( _not )
87         {
88             retVal.append(" NOT LIKE ") ;
89         }
90         else
91         {
92             retVal.append(" LIKE ");
93         }
94
95         retVal.append("(");
96         retVal.append(getRightOperand().toSql(context));
97         retVal.append(")");
98
99         //Trace.exit(this,"toSql(Context context)", retVal);
100
return retVal.toString();
101     }
102 }
103
Popular Tags