001 package org.apache.ojb.broker.core.proxy;
002
003 /* Copyright 2003-2005 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 import java.util.Collection;
019 import java.util.Set;
020
021 import org.apache.ojb.broker.PBKey;
022 import org.apache.ojb.broker.PersistenceBrokerException;
023 import org.apache.ojb.broker.query.Query;
024 import org.apache.ojb.broker.util.collections.ManageableHashSet;
025
026 /**
027 * A placeHolder for a whole set to support deferred loading of
028 * relationships. The complete relationship is loaded on request.
029 *
030 * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
031 * @version $Id: SetProxyDefaultImpl.java,v 1.1 2007-08-24 22:17:32 ewestfal Exp $
032 */
033 public class SetProxyDefaultImpl extends CollectionProxyDefaultImpl implements Set
034 {
035
036 /**
037 * Constructor for SetProxy.
038 * @param aKey
039 * @param aQuery
040 */
041 public SetProxyDefaultImpl(PBKey aKey, Query aQuery)
042 {
043 this(aKey, ManageableHashSet.class, aQuery);
044 }
045
046 /**
047 * Constructor for SetProxy.
048 * @param aKey
049 * @param aCollClass
050 * @param aQuery
051 */
052 public SetProxyDefaultImpl(PBKey aKey, Class aCollClass, Query aQuery)
053 {
054 super(aKey, aCollClass, aQuery);
055 }
056
057 protected Set getSetData()
058 {
059 return (Set)super.getData();
060 }
061
062 /**
063 * @see org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl#loadData()
064 */
065 protected Collection loadData() throws PersistenceBrokerException
066 {
067 Collection result = super.loadData();
068
069 if (result instanceof Set)
070 {
071 return result;
072 }
073 else
074 {
075 throw new PersistenceBrokerException("loaded data does not implement java.util.Set");
076 }
077
078 }
079
080 }