01: /*
02: $Header: /cvsroot/xorm/xorm/src/org/xorm/query/SimpleCondition.java,v 1.8 2003/04/10 03:13:33 wbiggs Exp $
03:
04: This file is part of XORM.
05:
06: XORM is free software; you can redistribute it and/or modify
07: it under the terms of the GNU General Public License as published by
08: the Free Software Foundation; either version 2 of the License, or
09: (at your option) any later version.
10:
11: XORM is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU General Public License for more details.
15:
16: You should have received a copy of the GNU General Public License
17: along with XORM; if not, write to the Free Software
18: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: package org.xorm.query;
21:
22: import org.xorm.datastore.Column;
23:
24: public class SimpleCondition extends Condition {
25: private Column column;
26: private Operator operator;
27: private Object value;
28:
29: public SimpleCondition(Column column, Operator operator,
30: Object value) {
31: this .column = column;
32: this .operator = operator;
33: this .value = value;
34: }
35:
36: public Column getColumn() {
37: return column;
38: }
39:
40: public Operator getOperator() {
41: return operator;
42: }
43:
44: public Object getValue() {
45: return value;
46: }
47:
48: public Object clone() {
49: SimpleCondition clone = (SimpleCondition) super .clone();
50: if (value instanceof Selector) {
51: clone.value = ((Selector) value).clone();
52: }
53: return clone;
54: }
55:
56: public String toString() {
57: StringBuffer local = new StringBuffer();
58: if (isInverted()) {
59: local.append("!(");
60: }
61: local.append((column == null ? "null" : column.getName()))
62: .append(' ').append(operator).append(' ');
63: if (value instanceof Character) {
64: local.append('\'').append(value).append('\'');
65: } else if (value instanceof String) {
66: local.append('"').append(value).append('"');
67: } else {
68: local.append(value);
69: }
70: if (isInverted()) {
71: local.append(")");
72: }
73: return local.toString();
74: }
75:
76: }
|