01: package org.apache.ojb.broker.core.proxy;
02:
03: /* Copyright 2003-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * 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;
19: import java.util.Set;
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
34: implements Set {
35:
36: /**
37: * Constructor for SetProxy.
38: * @param aKey
39: * @param aQuery
40: */
41: public SetProxyDefaultImpl(PBKey aKey, Query aQuery) {
42: this (aKey, ManageableHashSet.class, aQuery);
43: }
44:
45: /**
46: * Constructor for SetProxy.
47: * @param aKey
48: * @param aCollClass
49: * @param aQuery
50: */
51: public SetProxyDefaultImpl(PBKey aKey, Class aCollClass,
52: Query aQuery) {
53: super (aKey, aCollClass, aQuery);
54: }
55:
56: protected Set getSetData() {
57: return (Set) super .getData();
58: }
59:
60: /**
61: * @see org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl#loadData()
62: */
63: protected Collection loadData() throws PersistenceBrokerException {
64: Collection result = super .loadData();
65:
66: if (result instanceof Set) {
67: return result;
68: } else {
69: throw new PersistenceBrokerException(
70: "loaded data does not implement java.util.Set");
71: }
72:
73: }
74:
75: }
|