1 24 25 package org.objectweb.cjdbc.common.sql.schema; 26 27 import java.sql.Types ; 28 29 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags; 30 31 36 public class DatabaseProcedureParameter 37 { 38 39 40 41 public static final int ProcedureColumnUnknown = 0; 42 43 public static final int ProcedureColumnIn = 1; 44 45 public static final int ProcedureColumnInOut = 2; 46 47 public static final int ProcedureColumnOut = 3; 48 49 public static final int ProcedureColumnReturn = 4; 50 51 public static final int ProcedureColumnResult = 5; 52 53 54 55 public static final int ProcedureNoNulls = 0; 56 57 public static final int ProcedureNullable = 1; 58 59 public static final int ProcedureNullableUnknown = 2; 60 61 private String name; 62 private int columnType; 63 private int dataType; 64 private String typeName; 65 private float precision; 66 private int length; 67 private int scale; 68 private int radix; 69 private int nullable; 70 private String remarks; 71 72 78 public static int getNullFromString(String nullable) 79 { 80 if (nullable.equalsIgnoreCase(DatabasesXmlTags.VAL_noNulls)) 81 return ProcedureNoNulls; 82 if (nullable.equalsIgnoreCase(DatabasesXmlTags.VAL_nullable)) 83 return ProcedureNullable; 84 else 85 return ProcedureNullableUnknown; 86 } 87 88 94 public static String getNullFromInt(int nullable) 95 { 96 switch (nullable) 97 { 98 case ProcedureNoNulls : 99 return DatabasesXmlTags.VAL_noNulls; 100 case ProcedureNullable : 101 return DatabasesXmlTags.VAL_nullable; 102 case ProcedureNullableUnknown : 103 default : 104 return DatabasesXmlTags.VAL_nullableUnknown; 105 } 106 } 107 108 114 public static String getColumnTypeFromInt(int type) 115 { 116 switch (type) 117 { 118 case ProcedureColumnIn : 119 return DatabasesXmlTags.VAL_in; 120 case ProcedureColumnOut : 121 return DatabasesXmlTags.VAL_out; 122 case ProcedureColumnInOut : 123 return DatabasesXmlTags.VAL_inout; 124 case ProcedureColumnReturn : 125 return DatabasesXmlTags.VAL_return; 126 case ProcedureColumnResult : 127 return DatabasesXmlTags.VAL_result; 128 case ProcedureColumnUnknown : 129 default : 130 return DatabasesXmlTags.VAL_unknown; 131 } 132 } 133 134 140 public static int getColumnTypeFromString(String type) 141 { 142 if (type.equalsIgnoreCase(DatabasesXmlTags.VAL_in)) 143 return ProcedureColumnIn; 144 if (type.equalsIgnoreCase(DatabasesXmlTags.VAL_out)) 145 return ProcedureColumnOut; 146 if (type.equalsIgnoreCase(DatabasesXmlTags.VAL_inout)) 147 return ProcedureColumnInOut; 148 if (type.equalsIgnoreCase(DatabasesXmlTags.VAL_return)) 149 return ProcedureColumnReturn; 150 if (type.equalsIgnoreCase(DatabasesXmlTags.VAL_result)) 151 return ProcedureColumnResult; 152 else 153 return ProcedureColumnUnknown; 154 } 155 156 163 public DatabaseProcedureParameter(String name, int columnType, int nullable) 164 { 165 this(name, columnType, Types.VARCHAR, "VARCHAR", 0, 0, 0, 0, nullable, ""); 166 } 167 168 181 public DatabaseProcedureParameter(String name, int columnType, int dataType, 182 String typeName, float precision, int length, int scale, int radix, 183 int nullable, String remarks) 184 { 185 this.name = name; 186 this.columnType = columnType; 187 this.dataType = dataType; 188 this.typeName = typeName; 189 this.precision = precision; 190 this.length = length; 191 this.scale = scale; 192 this.radix = radix; 193 this.nullable = nullable; 194 this.remarks = remarks; 195 } 196 197 200 public final int getColumnType() 201 { 202 return columnType; 203 } 204 205 208 public final void setColumnType(int columnType) 209 { 210 this.columnType = columnType; 211 } 212 213 216 public final int getDataType() 217 { 218 return dataType; 219 } 220 221 224 public final void setDataType(int dataType) 225 { 226 this.dataType = dataType; 227 } 228 229 232 public final int getLength() 233 { 234 return length; 235 } 236 237 240 public final void setLength(int length) 241 { 242 this.length = length; 243 } 244 245 248 public final String getName() 249 { 250 return name; 251 } 252 253 256 public final void setName(String name) 257 { 258 this.name = name; 259 } 260 261 264 public final int getNullable() 265 { 266 return nullable; 267 } 268 269 272 public final void setNullable(int nullable) 273 { 274 this.nullable = nullable; 275 } 276 277 280 public final float getPrecision() 281 { 282 return precision; 283 } 284 285 288 public final void setPrecision(int precision) 289 { 290 this.precision = precision; 291 } 292 293 296 public final int getRadix() 297 { 298 return radix; 299 } 300 301 304 public final void setRadix(int radix) 305 { 306 this.radix = radix; 307 } 308 309 312 public final String getRemarks() 313 { 314 return remarks; 315 } 316 317 320 public final void setRemarks(String remarks) 321 { 322 this.remarks = remarks; 323 } 324 325 328 public final int getScale() 329 { 330 return scale; 331 } 332 333 336 public final void setScale(int scale) 337 { 338 this.scale = scale; 339 } 340 341 344 public final String getTypeName() 345 { 346 return typeName; 347 } 348 349 352 public final void setTypeName(String typeName) 353 { 354 this.typeName = typeName; 355 } 356 357 364 public boolean equals(Object other) 365 { 366 if ((other == null) || !(other instanceof DatabaseProcedureParameter)) 367 return false; 368 369 DatabaseProcedureParameter p = (DatabaseProcedureParameter) other; 370 371 if (!(p.columnType == columnType && p.dataType == dataType 373 && p.precision == precision && p.length == length && p.scale == scale 374 && p.radix == radix && p.nullable == nullable)) 375 { 376 return false; 377 } 378 379 if (!(name == null ? p.name == null : name.equals(p.name))) 381 { 382 return false; 383 } 384 385 if (!(typeName == null ? p.typeName == null : typeName.equals(p.typeName))) 386 { 387 return false; 388 } 389 390 return remarks == null ? p.remarks == null : remarks.equals(p.remarks); 391 } 392 393 398 public String getXml() 399 { 400 StringBuffer info = new StringBuffer (); 401 info.append("<" + DatabasesXmlTags.ELT_DatabaseProcedureColumn + " " 402 + DatabasesXmlTags.ATT_name + "=\"" + name + "\"" + " " 403 + DatabasesXmlTags.ATT_paramType + "=\"" 404 + getColumnTypeFromInt(columnType) + "\"" + " " 405 + DatabasesXmlTags.ATT_nullable + "=\"" + getNullFromInt(nullable) 406 + "\"/>"); 407 return info.toString(); 408 } 409 410 } | Popular Tags |