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: * DataType.java
19: *
20: * Created on 29 novembre 2003, 12.24
21: */
22:
23: package it.biobytes.ammentos;
24:
25: import java.sql.*;
26:
27: /**
28: * Describes a valid type of data for a Field
29: * @author davide
30: */
31: public interface FieldType {
32: public void setParamValue(Object fieldValue,
33: PreparedStatement pstmt, int paramIndex)
34: throws SQLException;
35:
36: public Object loadValue(java.sql.ResultSet rs, Field field)
37: throws SQLException;
38:
39: public Object parseValue(String str) throws PersistenceException;
40:
41: public String formatValue(Object value);
42:
43: public Object generateValue() throws PersistenceException;
44:
45: public boolean isNumeric();
46:
47: public Object[] getPossibleValues();
48:
49: /**
50: * Gets the underlying mapped Java class represented from elements of this
51: * type
52: *
53: * @return the Java class mapped from this FieldType
54: */
55: public Class getMappedClass();
56:
57: /**
58: * Returns the SQL type (as enumerated in java.sql.Types) of this field type.
59: * @see java.sql.Types
60: */
61: public int getSqlType();
62:
63: /**
64: * Returns the sum of the provided values, or null if summing is not possible
65: *
66: * @param value1 First value to add
67: * @param value2 Second value to add
68: */
69: public Object addValues(Object value1, Object value2);
70: }
|