KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > core > proxy > SetProxyDefaultImpl


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

17
18 import java.util.Collection JavaDoc;
19 import java.util.Set JavaDoc;
20
21 import org.apache.ojb.broker.PBKey;
22 import org.apache.ojb.broker.PersistenceBrokerException;
23 import org.apache.ojb.broker.query.Query;
24 import org.apache.ojb.broker.util.collections.ManageableHashSet;
25
26 /**
27  * A placeHolder for a whole set to support deferred loading of
28  * relationships. The complete relationship is loaded on request.
29  *
30  * @author <a HREF="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
31  * @version $Id: SetProxyDefaultImpl.java,v 1.1.2.1 2005/12/21 22:25:30 tomdz Exp $
32  */

33 public class SetProxyDefaultImpl extends CollectionProxyDefaultImpl implements Set JavaDoc
34 {
35
36     /**
37      * Constructor for SetProxy.
38      * @param aKey
39      * @param aQuery
40      */

41     public SetProxyDefaultImpl(PBKey aKey, Query aQuery)
42     {
43         this(aKey, ManageableHashSet.class, aQuery);
44     }
45
46     /**
47      * Constructor for SetProxy.
48      * @param aKey
49      * @param aCollClass
50      * @param aQuery
51      */

52     public SetProxyDefaultImpl(PBKey aKey, Class JavaDoc aCollClass, Query aQuery)
53     {
54         super(aKey, aCollClass, aQuery);
55     }
56
57     protected Set JavaDoc getSetData()
58     {
59         return (Set JavaDoc)super.getData();
60     }
61     
62     /**
63      * @see org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl#loadData()
64      */

65     protected Collection JavaDoc loadData() throws PersistenceBrokerException
66     {
67         Collection JavaDoc result = super.loadData();
68
69         if (result instanceof Set JavaDoc)
70         {
71             return result;
72         }
73         else
74         {
75             throw new PersistenceBrokerException("loaded data does not implement java.util.Set");
76         }
77         
78     }
79
80 }
81
Popular Tags