01: /*
02: * Copyright 2006 Davide Deidda
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: /*
18: * SqlString.java
19: *
20: * Created on 29 novembre 2003, 13.38
21: */
22:
23: package it.biobytes.ammentos.fieldtypes;
24:
25: import java.sql.Types;
26:
27: import it.biobytes.ammentos.*;
28: import it.biobytes.ammentos.util.*;
29:
30: /**
31: *
32: * @author davide
33: */
34: public class StringType implements FieldType {
35:
36: /** Creates a new instance of SqlString */
37: public StringType() {
38: }
39:
40: public String formatValue(Object value) {
41: return (String) value;
42: }
43:
44: public Object loadValue(java.sql.ResultSet rs, Field field)
45: throws java.sql.SQLException {
46: return rs.getString(field.getName());
47: }
48:
49: public Object parseValue(String str) throws PersistenceException {
50: return str;
51: }
52:
53: public void setParamValue(Object fieldValue,
54: java.sql.PreparedStatement pstmt, int paramIndex)
55: throws java.sql.SQLException {
56: pstmt.setString(paramIndex, (String) fieldValue);
57: }
58:
59: public Object generateValue() throws PersistenceException {
60: return Sequencer.nextString();
61: }
62:
63: public boolean isNumeric() {
64: return false;
65: }
66:
67: public Object[] getPossibleValues() {
68: return null;
69: }
70:
71: /**
72: * Returns the sum of the provided values, or null if summing is not possible
73: *
74: * @param value1 First value to add
75: * @param value2 Second value to add
76: */
77: public Object addValues(Object value1, Object value2) {
78: return null;
79: }
80:
81: /**
82: * Gets the underlying mapped Java class represented from elements of this
83: * type
84: *
85: * @return the Java class mapped from this FieldType
86: */
87: public Class getMappedClass() {
88: return String.class;
89: }
90:
91: public int getSqlType() {
92: return Types.VARCHAR;
93: }
94: }
|