db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata DescriptorRepository.java
Date Wed, 02 Jun 2004 20:09:04 GMT
brj         2004/06/02 13:09:04

  Modified:    src/java/org/apache/ojb/broker/metadata
                        DescriptorRepository.java
  Log:
  modified getAllConcreteSubclassDescriptors to return descriptors in predictable order
  
  Revision  Changes    Path
  1.50      +21 -6     db-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
  
  Index: DescriptorRepository.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- DescriptorRepository.java	4 Apr 2004 23:53:34 -0000	1.49
  +++ DescriptorRepository.java	2 Jun 2004 20:09:03 -0000	1.50
  @@ -309,7 +309,8 @@
       /**
        *
        * Utility method to discover all concrete subclasses of a given super class. <br>
  -     * This method was introduced in order to get Extent Aware Iterators.
  +     * This method was introduced in order to get Extent Aware Iterators. <br>
  +     * Attention: The order of the returned collection is not predictable !
        * @deprecated use getAllConcreteSubclassDescriptors
        * @return a List of Class objects
        */
  @@ -349,8 +350,10 @@
        */
       public Collection getAllConcreteSubclassDescriptors(ClassDescriptor aCld)
       {
  -        // BRJ: set to prevent duplicates
  -        Set concreteSubclassClds = new HashSet();
  +        // BRJ: As long as we do not have an ordered Set
  +        // duplicates have to be prevented manually.
  +        // a HashSet should not be used because the order is unpredictable
  +        Collection concreteSubclassClds = new ArrayList();
           Iterator iter = aCld.getExtentClasses().iterator();
   
           while (iter.hasNext())
  @@ -364,15 +367,27 @@
               }
               if (!extCld.isInterface())
               {
  -                concreteSubclassClds.add(extCld);
  +                if (!concreteSubclassClds.contains(extCld))
  +                {
  +                    concreteSubclassClds.add(extCld);
  +                }
               }
   
               // recurse
  -            concreteSubclassClds.addAll(getAllConcreteSubclassDescriptors(extCld));
  +            Iterator subIter = getAllConcreteSubclassDescriptors(extCld).iterator();
  +            while (subIter.hasNext())
  +            {
  +                ClassDescriptor subCld = (ClassDescriptor)subIter.next();  
  +                if (!concreteSubclassClds.contains(subCld))
  +                {
  +                    concreteSubclassClds.add(subCld);
  +                }
  +            }
           }
   
           return concreteSubclassClds;
       }
  +
   
       /**
        * Checks if repository contains given class.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message