KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > access > types > ExtendedType


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

19
20 package org.apache.cayenne.access.types;
21
22 import java.sql.CallableStatement JavaDoc;
23 import java.sql.PreparedStatement JavaDoc;
24 import java.sql.ResultSet JavaDoc;
25
26 import org.apache.cayenne.map.DbAttribute;
27 import org.apache.cayenne.validation.ValidationResult;
28
29 /**
30  * Defines methods to read Java objects from JDBC ResultSets and write as parameters of
31  * PreparedStatements.
32  *
33  * @author Andrus Adamchik
34  */

35 public interface ExtendedType {
36
37     /**
38      * Returns a full name of Java class that this ExtendedType supports.
39      */

40     String JavaDoc getClassName();
41
42     /**
43      * Performs validation of an object property. Property is considered valid if this it
44      * satisfies the database constraints known to this ExtendedType. In case of
45      * validation failure, failures are appended to the ValidationResult object and
46      * <code>false</code> is returned.
47      *
48      * @since 1.1
49      * @deprecated since 3.0 as validation should not be done at the DataNode level.
50      */

51     boolean validateProperty(
52             Object JavaDoc source,
53             String JavaDoc property,
54             Object JavaDoc value,
55             DbAttribute dbAttribute,
56             ValidationResult validationResult);
57
58     /**
59      * Initializes a single parameter of a PreparedStatement with object value.
60      */

61     void setJdbcObject(
62             PreparedStatement JavaDoc statement,
63             Object JavaDoc value,
64             int pos,
65             int type,
66             int precision) throws Exception JavaDoc;
67
68     /**
69      * Reads an object from JDBC ResultSet column, converting it to class returned by
70      * 'getClassName' method.
71      *
72      * @throws Exception if read error ocurred, or an object can't be converted to a
73      * target Java class.
74      */

75     Object JavaDoc materializeObject(ResultSet JavaDoc rs, int index, int type) throws Exception JavaDoc;
76
77     /**
78      * Reads an object from a stored procedure OUT parameter, converting it to class
79      * returned by 'getClassName' method.
80      *
81      * @throws Exception if read error ocurred, or an object can't be converted to a
82      * target Java class.
83      */

84     Object JavaDoc materializeObject(CallableStatement JavaDoc rs, int index, int type) throws Exception JavaDoc;
85 }
86
Popular Tags