01: /*
02: * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package org.mandarax.jdbc.server.sql;
20:
21: /**
22: * Represents a host variable (usually represented by '?').
23: * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
24: * @version 3.3.2 <29 December 2004>
25: * @since 3.0
26: */
27:
28: public class HostVariable extends ColumnTerm {
29: private Object value = null;
30:
31: /**
32: * Constructor.
33: */
34: public HostVariable() {
35: super ();
36: }
37:
38: /**
39: * Compares objects.
40: * @param obj another object.
41: * @return a boolean
42: */
43: public boolean sameAs(Object obj) {
44: return (obj != null && obj instanceof HostVariable);
45: }
46:
47: /** Getter for property value.
48: * @return Value of property value.
49: *
50: */
51: public java.lang.Object getValue() {
52: return value;
53: }
54:
55: /**
56: * Bind the variable.
57: * @param value the new value.
58: */
59: public void bind(java.lang.Object value) {
60: this .value = value;
61: }
62:
63: /**
64: * Reset the variable.
65: */
66: public void reset() {
67: this .value = null;
68: }
69:
70: /**
71: * Indicates whether the variable is bound.
72: * @return a boolean
73: */
74: public boolean isBound() {
75: return value != null;
76: }
77:
78: /**
79: * Gather the host variables.
80: * @param variables the list used to collect the variables
81: */
82: public void prepare(java.util.List variables) {
83: variables.add(this );
84: }
85:
86: /**
87: * Print the object on a buffer in order to display the parsed SQL.
88: * @param out a string bufer to print on
89: */
90: public void print(StringBuffer out) {
91: out.append('?');
92: }
93:
94: }
|