/** * PUBLIC: * Configure the mapping to use an instance of the specified container class * to hold the target objects. * <p>The container class must implement (directly or indirectly) the * <code>java.util.Collection</code> interface. */ public void useCollectionClass(Class concreteClass) { ContainerPolicy policy = ContainerPolicy.buildPolicyFor(concreteClass, hasOrderBy()); setContainerPolicy(policy); }
/** * PUBLIC: * Configure the mapping to use an instance of the specified container class * to hold the target objects. * <p>The container class must implement (directly or indirectly) the * <code>java.util.SortedSet</code> interface. */ public void useSortedSetClass(Class concreteClass, Comparator comparator) { try { SortedCollectionContainerPolicy policy = (SortedCollectionContainerPolicy)ContainerPolicy.buildPolicyFor(concreteClass); policy.setComparator(comparator); setContainerPolicy(policy); } catch (ClassCastException e) { useCollectionClass(concreteClass); } }
/** * PUBLIC: * Configure the mapping to use an instance of the specified container * clas to hold the target objects. The key used to index a value in the * <code>Map</code> is the value returned by either a call to a * specified zero-argument method or the value of a field. * <p> To facilitate resolving the keyName to a method or field, * the mapping's referenceClass must set before calling this method. * <p> Note: If the keyName is for a method, that method must be implemented * by the class (or a superclass) of any value to be inserted into the * <code>Map</code>. * <p> The container class must implement (directly or indirectly) the * <code>java.util.Map</code> interface. */ public void useMapClass(Class concreteClass, String keyName) { // the reference class has to be specified before coming here if (getReferenceClassName() == null) { throw DescriptorException.referenceClassNotSpecified(this); } ContainerPolicy policy = ContainerPolicy.buildPolicyFor(concreteClass); policy.setKeyName(keyName, getReferenceClassName()); setContainerPolicy(policy); }
} else if (rawClass == Collection.class) { mapping.useTransparentCollection(); mapping.setContainerPolicy(new CollectionContainerPolicy(ClassConstants.IndirectList_Class)); } else if (rawClass == Set.class) { mapping.useTransparentSet();