KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > sqls > impl > SetStatementImpl


1 /*
2  * Copyright 2003, 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15
16  */

17 package org.apache.ws.jaxme.sqls.impl;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.Calendar JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.List JavaDoc;
23
24 import org.apache.ws.jaxme.sqls.Column;
25 import org.apache.ws.jaxme.sqls.ColumnReference;
26 import org.apache.ws.jaxme.sqls.Function;
27 import org.apache.ws.jaxme.sqls.SQLFactory;
28 import org.apache.ws.jaxme.sqls.SelectStatement;
29 import org.apache.ws.jaxme.sqls.SetStatement;
30 import org.apache.ws.jaxme.sqls.Value;
31 import org.apache.ws.jaxme.sqls.Column.Name;
32
33
34 /**
35  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
36  */

37 public abstract class SetStatementImpl extends StatementImpl implements SetStatement {
38   public static class SetValueImpl implements SetStatement.SetValue {
39     private final ColumnReference columnReference;
40     private final Object JavaDoc value;
41     public SetValueImpl(ColumnReference pColumn, Object JavaDoc pValue) {
42       if (pColumn == null) {
43         throw new NullPointerException JavaDoc("Column reference must not be null.");
44       }
45       if (pValue == null) {
46         throw new NullPointerException JavaDoc("Value must not be null.");
47       }
48       columnReference = pColumn;
49       value = pValue;
50     }
51
52     public ColumnReference getColumnReference() { return columnReference; }
53     public Object JavaDoc getValue() { return value; }
54   }
55
56   private List JavaDoc setValues = new ArrayList JavaDoc();
57
58   protected SetStatementImpl(SQLFactory pFactory) {
59     super(pFactory);
60   }
61
62   public Iterator JavaDoc getSetValues() { return setValues.iterator(); }
63
64   public void addSet(ColumnReference pColumn, Value pValue) {
65     addSet(pColumn, pValue);
66   }
67   protected void addSet(ColumnReference pRef, Object JavaDoc pValue) {
68     if (!pRef.getTableReference().equals(getTableReference())) {
69       throw new IllegalArgumentException JavaDoc("The column has an invalid table reference.");
70     }
71     setValues.add(new SetValueImpl(pRef, pValue));
72   }
73   public void addSet(Column pColumn, Object JavaDoc pValue) {
74     addSet(getTableReference().newColumnReference(pColumn), pValue);
75   }
76   public void addSet(String JavaDoc pColumn, Object JavaDoc pValue) {
77     addSet(getTableReference().newColumnReference(pColumn), pValue);
78   }
79   public void addSet(Column.Name pColumn, Object JavaDoc pValue) {
80     addSet(getTableReference().newColumnReference(pColumn), pValue);
81   }
82   public void addSet(Column pColumn, Value pValue) {
83     addSet(pColumn, (Object JavaDoc) pValue);
84   }
85   public void addSet(Column.Name pColumn, Value pValue) {
86     addSet(getTableReference().newColumnReference(pColumn), (Object JavaDoc) pValue);
87   }
88   public void addSet(String JavaDoc pColumn, Value pValue) {
89     addSet(getTableReference().newColumnReference(pColumn), (Object JavaDoc) pValue);
90   }
91
92   public void addSetNull(Column pColumn) {
93     addSet(pColumn, new ValueImpl(Value.Type.NULL, null));
94   }
95   public void addSetNull(Column.Name pColumn) {
96     addSet(pColumn, new ValueImpl(Value.Type.NULL, null));
97   }
98   public void addSetNull(String JavaDoc pColumn) {
99     addSet(pColumn, new ValueImpl(Value.Type.NULL, null));
100   }
101
102   public void addSet(Column pColumn) {
103     if (pColumn == null) {
104       throw new NullPointerException JavaDoc("The column being set must not be null.");
105     }
106     addSet(pColumn, new ValueImpl(Value.Type.PLACEHOLDER, null));
107   }
108   public void addSet(Column.Name pColumn) {
109     addSet(pColumn, new ValueImpl(Value.Type.PLACEHOLDER, null));
110   }
111   public void addSet(String JavaDoc pColumn) {
112     addSet(pColumn, new ValueImpl(Value.Type.PLACEHOLDER, null));
113   }
114
115   public void addSet(Column pColumn, byte pValue) {
116     addSet(pColumn, new ValueImpl(Value.Type.BYTE, new Byte JavaDoc(pValue)));
117   }
118   public void addSet(Column.Name pColumn, byte pValue) {
119     addSet(pColumn, new ValueImpl(Value.Type.BYTE, new Byte JavaDoc(pValue)));
120   }
121   public void addSet(String JavaDoc pColumn, byte pValue) {
122     addSet(pColumn, new ValueImpl(Value.Type.BYTE, new Byte JavaDoc(pValue)));
123   }
124
125   public void addSet(Column pColumn, short pValue) {
126     addSet(pColumn, new ValueImpl(Value.Type.SHORT, new Short JavaDoc(pValue)));
127   }
128   public void addSet(Column.Name pColumn, short pValue) {
129     addSet(pColumn, new ValueImpl(Value.Type.SHORT, new Short JavaDoc(pValue)));
130   }
131   public void addSet(String JavaDoc pColumn, short pValue) {
132     addSet(pColumn, new ValueImpl(Value.Type.SHORT, new Short JavaDoc(pValue)));
133   }
134
135   public void addSet(Column pColumn, int pValue) {
136     addSet(pColumn, new ValueImpl(Value.Type.INT, new Integer JavaDoc(pValue)));
137   }
138   public void addSet(Column.Name pColumn, int pValue) {
139     addSet(pColumn, new ValueImpl(Value.Type.INT, new Integer JavaDoc(pValue)));
140   }
141   public void addSet(String JavaDoc pColumn, int pValue) {
142     addSet(pColumn, new ValueImpl(Value.Type.INT, new Integer JavaDoc(pValue)));
143   }
144
145   public void addSet(Column pColumn, long pValue) {
146     addSet(pColumn, new ValueImpl(Value.Type.LONG, new Long JavaDoc(pValue)));
147   }
148   public void addSet(Column.Name pColumn, long pValue) {
149     addSet(pColumn, new ValueImpl(Value.Type.LONG, new Long JavaDoc(pValue)));
150   }
151   public void addSet(String JavaDoc pColumn, long pValue) {
152     addSet(pColumn, new ValueImpl(Value.Type.LONG, new Long JavaDoc(pValue)));
153   }
154
155   public void addSet(Column pColumn, float pValue) {
156     addSet(pColumn, new ValueImpl(Value.Type.FLOAT, new Float JavaDoc(pValue)));
157   }
158   public void addSet(Column.Name pColumn, float pValue) {
159     addSet(pColumn, new ValueImpl(Value.Type.FLOAT, new Float JavaDoc(pValue)));
160   }
161   public void addSet(String JavaDoc pColumn, float pValue) {
162     addSet(pColumn, new ValueImpl(Value.Type.FLOAT, new Float JavaDoc(pValue)));
163   }
164
165   public void addSet(Column pColumn, boolean pValue) {
166     addSet(pColumn, new ValueImpl(Value.Type.BOOLEAN, pValue ? Boolean.TRUE : Boolean.FALSE));
167   }
168   public void addSet(Column.Name pColumn, boolean pValue) {
169     addSet(pColumn, new ValueImpl(Value.Type.BOOLEAN, pValue ? Boolean.TRUE : Boolean.FALSE));
170   }
171   public void addSet(String JavaDoc pColumn, boolean pValue) {
172     addSet(pColumn, new ValueImpl(Value.Type.BOOLEAN, pValue ? Boolean.TRUE : Boolean.FALSE));
173   }
174
175   public void addSet(Column pColumn, String JavaDoc pValue) {
176     addSet(pColumn, new ValueImpl(Value.Type.STRING, pValue));
177   }
178   public void addSet(Column.Name pColumn, String JavaDoc pValue) {
179     addSet(pColumn, new ValueImpl(Value.Type.STRING, pValue));
180   }
181   public void addSet(String JavaDoc pColumn, String JavaDoc pValue) {
182     addSet(pColumn, new ValueImpl(Value.Type.STRING, pValue));
183   }
184
185   public void addSetDateTime(Column pColumn, Calendar JavaDoc pValue) {
186     addSet(pColumn, new ValueImpl(Value.Type.DATETIME, pValue));
187   }
188   public void addSetDateTime(Column.Name pColumn, Calendar JavaDoc pValue) {
189     addSet(pColumn, new ValueImpl(Value.Type.DATETIME, pValue));
190   }
191   public void addSetDateTime(String JavaDoc pColumn, Calendar JavaDoc pValue) {
192     addSet(pColumn, new ValueImpl(Value.Type.DATETIME, pValue));
193   }
194
195   public void addSetTime(Column pColumn, Calendar JavaDoc pValue) {
196     addSet(pColumn, new ValueImpl(Value.Type.TIME, pValue));
197   }
198   public void addSetTime(Column.Name pColumn, Calendar JavaDoc pValue) {
199     addSet(pColumn, new ValueImpl(Value.Type.TIME, pValue));
200   }
201   public void addSetTime(String JavaDoc pColumn, Calendar JavaDoc pValue) {
202     addSet(pColumn, new ValueImpl(Value.Type.TIME, pValue));
203   }
204
205   public void addSetDate(Column pColumn, Calendar JavaDoc pValue) {
206     addSet(pColumn, new ValueImpl(Value.Type.DATE, pValue));
207   }
208   public void addSetDate(Column.Name pColumn, Calendar JavaDoc pValue) {
209     addSet(pColumn, new ValueImpl(Value.Type.DATE, pValue));
210   }
211   public void addSetDate(String JavaDoc pColumn, Calendar JavaDoc pValue) {
212     addSet(pColumn, new ValueImpl(Value.Type.DATE, pValue));
213   }
214 }
215
Popular Tags