KickJava   Java API By Example, From Geeks To Geeks.

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


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  * A noop type that is sometimes useful to suppress extended types operations. It will set
31  * and get null values.
32  *
33  * @since 1.2
34  * @author Andrus Adamchik
35  */

36 class VoidType implements ExtendedType {
37
38     public String JavaDoc getClassName() {
39         return Void.TYPE.getName();
40     }
41
42     /**
43      * @deprecated since 3.0 as validation should not be done at the DataNode level.
44      */

45     public boolean validateProperty(
46             Object JavaDoc source,
47             String JavaDoc property,
48             Object JavaDoc value,
49             DbAttribute dbAttribute,
50             ValidationResult validationResult) {
51         return true;
52     }
53
54     public void setJdbcObject(
55             PreparedStatement JavaDoc statement,
56             Object JavaDoc value,
57             int pos,
58             int type,
59             int precision) throws Exception JavaDoc {
60         statement.setNull(pos, type);
61     }
62
63     public Object JavaDoc materializeObject(ResultSet JavaDoc rs, int index, int type) throws Exception JavaDoc {
64         return null;
65     }
66
67     public Object JavaDoc materializeObject(CallableStatement JavaDoc rs, int index, int type)
68             throws Exception JavaDoc {
69         return null;
70     }
71 }
72
Popular Tags