You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by br...@apache.org on 2004/12/04 13:04:22 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata DescriptorRepository.java
brj 2004/12/04 04:04:22
Modified: src/java/org/apache/ojb/broker/util/collections
ManageableListImpl.java TrackingCollectionImpl.java
ManageableSetImpl.java
src/java/org/apache/ojb/broker/metadata
DescriptorRepository.java
Removed: src/java/org/apache/ojb/broker/util/collections
AbstractListWrapper.java
AbstractCollectionWrapper.java
Log:
use commons-collections 3.1
Revision Changes Path
1.2 +23 -33 db-ojb/src/java/org/apache/ojb/broker/util/collections/ManageableListImpl.java
Index: ManageableListImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/collections/ManageableListImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ManageableListImpl.java 13 Nov 2004 10:08:16 -0000 1.1
+++ ManageableListImpl.java 4 Dec 2004 12:04:22 -0000 1.2
@@ -1,35 +1,34 @@
package org.apache.ojb.broker.util.collections;
/* Copyright 2003-2004 The Apache Software Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import org.apache.commons.collections.list.AbstractSerializableListDecorator;
import org.apache.ojb.broker.ManageableCollection;
-
/**
* Manageable Wrapper for List.
*
* @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
* @version $Id$
*/
-public class ManageableListImpl extends AbstractListWrapper implements List, ManageableCollection
+public class ManageableListImpl extends AbstractSerializableListDecorator implements ManageableCollection
{
private static final long serialVersionUID = 3256726190730392115L;
@@ -50,33 +49,25 @@
}
/**
- * @param collection the wrapped Collection
- */
- protected ManageableListImpl(Collection collection)
- {
- super(collection);
- }
-
- /**
* @see org.apache.ojb.broker.ManageableCollection#ojbAdd(java.lang.Object)
*/
public void ojbAdd(Object anObject)
{
add(anObject);
}
-
+
/**
* @see org.apache.ojb.broker.ManageableCollection#ojbAddAll(org.apache.ojb.broker.ManageableCollection)
*/
public void ojbAddAll(ManageableCollection otherCollection)
{
- Iterator it = otherCollection.ojbIterator();
- while (it.hasNext())
- {
- ojbAdd(it.next());
- }
+ Iterator it = otherCollection.ojbIterator();
+ while (it.hasNext())
+ {
+ ojbAdd(it.next());
+ }
}
-
+
/**
* @see org.apache.ojb.broker.ManageableCollection#ojbIterator()
*/
@@ -84,6 +75,5 @@
{
return iterator();
}
-
}
1.4 +4 -2 db-ojb/src/java/org/apache/ojb/broker/util/collections/TrackingCollectionImpl.java
Index: TrackingCollectionImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/collections/TrackingCollectionImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TrackingCollectionImpl.java 3 Dec 2004 21:59:17 -0000 1.3
+++ TrackingCollectionImpl.java 4 Dec 2004 12:04:22 -0000 1.4
@@ -19,13 +19,15 @@
import java.util.Collection;
import java.util.Iterator;
+import org.apache.commons.collections.collection.AbstractSerializableCollectionDecorator;
+
/**
* A Wrapper to track modifications (add / remove) on a Collection.
*
* @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
* @version $Id$
*/
-public class TrackingCollectionImpl extends AbstractCollectionWrapper implements TrackingCollection
+public class TrackingCollectionImpl extends AbstractSerializableCollectionDecorator implements TrackingCollection
{
private static final long serialVersionUID = 3256726190730392115L;
1.2 +35 -3 db-ojb/src/java/org/apache/ojb/broker/util/collections/ManageableSetImpl.java
Index: ManageableSetImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/collections/ManageableSetImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ManageableSetImpl.java 13 Nov 2004 10:08:16 -0000 1.1
+++ ManageableSetImpl.java 4 Dec 2004 12:04:22 -0000 1.2
@@ -17,15 +17,19 @@
*/
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
+import org.apache.commons.collections.set.AbstractSerializableSetDecorator;
+import org.apache.ojb.broker.ManageableCollection;
+
/**
- * Manageable Wrapper for List.
+ * Manageable Wrapper for Set.
*
* @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
* @version $Id$
*/
-public class ManageableSetImpl extends ManageableListImpl implements Set
+public class ManageableSetImpl extends AbstractSerializableSetDecorator implements ManageableCollection
{
private static final long serialVersionUID = 3257847666854474551L;
@@ -43,6 +47,34 @@
public ManageableSetImpl(Set set)
{
super(set);
+ }
+
+ /**
+ * @see org.apache.ojb.broker.ManageableCollection#ojbAdd(java.lang.Object)
+ */
+ public void ojbAdd(Object anObject)
+ {
+ add(anObject);
+ }
+
+ /**
+ * @see org.apache.ojb.broker.ManageableCollection#ojbAddAll(org.apache.ojb.broker.ManageableCollection)
+ */
+ public void ojbAddAll(ManageableCollection otherCollection)
+ {
+ Iterator it = otherCollection.ojbIterator();
+ while (it.hasNext())
+ {
+ ojbAdd(it.next());
+ }
+ }
+
+ /**
+ * @see org.apache.ojb.broker.ManageableCollection#ojbIterator()
+ */
+ public Iterator ojbIterator()
+ {
+ return iterator();
}
}
1.58 +6 -13 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.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- DescriptorRepository.java 28 Nov 2004 03:13:45 -0000 1.57
+++ DescriptorRepository.java 4 Dec 2004 12:04:22 -0000 1.58
@@ -23,6 +23,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.commons.collections.set.ListOrderedSet;
import org.apache.commons.lang.SystemUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
@@ -336,10 +337,8 @@
if (concreteSubclassClds == null)
{
- // 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
- concreteSubclassClds = new ArrayList();
+ // BRJ: ListOrderedSet prevents duplicates and ensures the order.
+ concreteSubclassClds = new ListOrderedSet();
Iterator iter = aCld.getExtentClasses().iterator();
while (iter.hasNext())
@@ -353,10 +352,7 @@
}
if (!extCld.isInterface() && !extCld.isAbstract())
{
- if (!concreteSubclassClds.contains(extCld))
- {
- concreteSubclassClds.add(extCld);
- }
+ concreteSubclassClds.add(extCld);
}
// recurse
@@ -364,10 +360,7 @@
while (subIter.hasNext())
{
ClassDescriptor subCld = (ClassDescriptor)subIter.next();
- if (!concreteSubclassClds.contains(subCld))
- {
- concreteSubclassClds.add(subCld);
- }
+ concreteSubclassClds.add(subCld);
}
}
m_allConcreteSubClass.put(aCld.getClassOfObject(), concreteSubclassClds);
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org