1 17 package org.apache.ws.jaxme.sqls.impl; 18 19 import java.util.ArrayList ; 20 import java.util.Calendar ; 21 import java.util.Iterator ; 22 import java.util.List ; 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 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 value; 41 public SetValueImpl(ColumnReference pColumn, Object pValue) { 42 if (pColumn == null) { 43 throw new NullPointerException ("Column reference must not be null."); 44 } 45 if (pValue == null) { 46 throw new NullPointerException ("Value must not be null."); 47 } 48 columnReference = pColumn; 49 value = pValue; 50 } 51 52 public ColumnReference getColumnReference() { return columnReference; } 53 public Object getValue() { return value; } 54 } 55 56 private List setValues = new ArrayList (); 57 58 protected SetStatementImpl(SQLFactory pFactory) { 59 super(pFactory); 60 } 61 62 public Iterator 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 pValue) { 68 if (!pRef.getTableReference().equals(getTableReference())) { 69 throw new IllegalArgumentException ("The column has an invalid table reference."); 70 } 71 setValues.add(new SetValueImpl(pRef, pValue)); 72 } 73 public void addSet(Column pColumn, Object pValue) { 74 addSet(getTableReference().newColumnReference(pColumn), pValue); 75 } 76 public void addSet(String pColumn, Object pValue) { 77 addSet(getTableReference().newColumnReference(pColumn), pValue); 78 } 79 public void addSet(Column.Name pColumn, Object pValue) { 80 addSet(getTableReference().newColumnReference(pColumn), pValue); 81 } 82 public void addSet(Column pColumn, Value pValue) { 83 addSet(pColumn, (Object ) pValue); 84 } 85 public void addSet(Column.Name pColumn, Value pValue) { 86 addSet(getTableReference().newColumnReference(pColumn), (Object ) pValue); 87 } 88 public void addSet(String pColumn, Value pValue) { 89 addSet(getTableReference().newColumnReference(pColumn), (Object ) 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 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 ("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 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 (pValue))); 117 } 118 public void addSet(Column.Name pColumn, byte pValue) { 119 addSet(pColumn, new ValueImpl(Value.Type.BYTE, new Byte (pValue))); 120 } 121 public void addSet(String pColumn, byte pValue) { 122 addSet(pColumn, new ValueImpl(Value.Type.BYTE, new Byte (pValue))); 123 } 124 125 public void addSet(Column pColumn, short pValue) { 126 addSet(pColumn, new ValueImpl(Value.Type.SHORT, new Short (pValue))); 127 } 128 public void addSet(Column.Name pColumn, short pValue) { 129 addSet(pColumn, new ValueImpl(Value.Type.SHORT, new Short (pValue))); 130 } 131 public void addSet(String pColumn, short pValue) { 132 addSet(pColumn, new ValueImpl(Value.Type.SHORT, new Short (pValue))); 133 } 134 135 public void addSet(Column pColumn, int pValue) { 136 addSet(pColumn, new ValueImpl(Value.Type.INT, new Integer (pValue))); 137 } 138 public void addSet(Column.Name pColumn, int pValue) { 139 addSet(pColumn, new ValueImpl(Value.Type.INT, new Integer (pValue))); 140 } 141 public void addSet(String pColumn, int pValue) { 142 addSet(pColumn, new ValueImpl(Value.Type.INT, new Integer (pValue))); 143 } 144 145 public void addSet(Column pColumn, long pValue) { 146 addSet(pColumn, new ValueImpl(Value.Type.LONG, new Long (pValue))); 147 } 148 public void addSet(Column.Name pColumn, long pValue) { 149 addSet(pColumn, new ValueImpl(Value.Type.LONG, new Long (pValue))); 150 } 151 public void addSet(String pColumn, long pValue) { 152 addSet(pColumn, new ValueImpl(Value.Type.LONG, new Long (pValue))); 153 } 154 155 public void addSet(Column pColumn, float pValue) { 156 addSet(pColumn, new ValueImpl(Value.Type.FLOAT, new Float (pValue))); 157 } 158 public void addSet(Column.Name pColumn, float pValue) { 159 addSet(pColumn, new ValueImpl(Value.Type.FLOAT, new Float (pValue))); 160 } 161 public void addSet(String pColumn, float pValue) { 162 addSet(pColumn, new ValueImpl(Value.Type.FLOAT, new Float (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 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 pValue) { 176 addSet(pColumn, new ValueImpl(Value.Type.STRING, pValue)); 177 } 178 public void addSet(Column.Name pColumn, String pValue) { 179 addSet(pColumn, new ValueImpl(Value.Type.STRING, pValue)); 180 } 181 public void addSet(String pColumn, String pValue) { 182 addSet(pColumn, new ValueImpl(Value.Type.STRING, pValue)); 183 } 184 185 public void addSetDateTime(Column pColumn, Calendar pValue) { 186 addSet(pColumn, new ValueImpl(Value.Type.DATETIME, pValue)); 187 } 188 public void addSetDateTime(Column.Name pColumn, Calendar pValue) { 189 addSet(pColumn, new ValueImpl(Value.Type.DATETIME, pValue)); 190 } 191 public void addSetDateTime(String pColumn, Calendar pValue) { 192 addSet(pColumn, new ValueImpl(Value.Type.DATETIME, pValue)); 193 } 194 195 public void addSetTime(Column pColumn, Calendar pValue) { 196 addSet(pColumn, new ValueImpl(Value.Type.TIME, pValue)); 197 } 198 public void addSetTime(Column.Name pColumn, Calendar pValue) { 199 addSet(pColumn, new ValueImpl(Value.Type.TIME, pValue)); 200 } 201 public void addSetTime(String pColumn, Calendar pValue) { 202 addSet(pColumn, new ValueImpl(Value.Type.TIME, pValue)); 203 } 204 205 public void addSetDate(Column pColumn, Calendar pValue) { 206 addSet(pColumn, new ValueImpl(Value.Type.DATE, pValue)); 207 } 208 public void addSetDate(Column.Name pColumn, Calendar pValue) { 209 addSet(pColumn, new ValueImpl(Value.Type.DATE, pValue)); 210 } 211 public void addSetDate(String pColumn, Calendar pValue) { 212 addSet(pColumn, new ValueImpl(Value.Type.DATE, pValue)); 213 } 214 } 215 | Popular Tags |