KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > unitTests > services > T_CachedInteger


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

21
22 package org.apache.derbyTesting.unitTests.services;
23
24 import org.apache.derby.iapi.services.cache.*;
25
26 import org.apache.derby.iapi.error.StandardException;
27
28 /**
29
30 */

31 public class T_CachedInteger extends T_Cacheable {
32
33     protected T_Key keyValue;
34         
35     public T_CachedInteger() {
36     }
37
38     /*
39     ** Cacheable methods
40     */

41
42
43     /**
44         @exception StandardException Standard Derby Error policy
45     */

46     public Cacheable setIdentity(Object JavaDoc key) throws StandardException {
47
48         super.setIdentity(key);
49
50         T_Key tkey = (T_Key) key; // instanceof check provided by superclass
51

52         if (!(tkey.getValue() instanceof Integer JavaDoc)) {
53
54             return getCorrectObject(tkey.getValue()).setIdentity(key);
55         }
56
57         // potentially pretend to wait and potentally behave as not found.
58
if (!dummySet(tkey))
59             return null;
60         keyValue = tkey;
61
62         return this;
63     }
64
65     /**
66         @exception StandardException Standard Derby Error policy
67     */

68     public Cacheable createIdentity(Object JavaDoc key, Object JavaDoc createParameter) throws StandardException {
69         super.createIdentity(key, createParameter);
70
71         T_Key tkey = (T_Key) key; // instanceof check provided by superclass
72

73         if (!(tkey.getValue() instanceof Integer JavaDoc)) {
74
75             return getCorrectObject(tkey.getValue()).createIdentity(key, createParameter);
76         }
77
78
79         // potentially pretend to wait and potentally behave as not found.
80
if (!dummySet(tkey))
81             return null;
82
83         keyValue = tkey;
84
85         return this;
86     }
87
88
89
90     /**
91         Put the object into the No Identity state.
92
93         <BR> MT - single thread required - Method must only be called be cache manager
94         and the cache manager will guarantee only one thread can be calling it.
95
96     */

97     public void clearIdentity() {
98         keyValue = null;
99     }
100
101     /**
102         Get the identity of this object.
103
104         <BR> MT - thread safe.
105
106     */

107     public Object JavaDoc getIdentity() {
108         return keyValue;
109     }
110
111     /**
112         @exception StandardException Standard Derby Error policy
113     */

114     public void clean(boolean forRemove) throws StandardException {
115         super.clean(forRemove);
116     }
117 }
118
119
Popular Tags