You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2004/04/09 12:36:02 UTC
cvs commit: jakarta-commons/collections/data/test TransformedSortedMap.fullCollection.version3.1.obj TransformedSortedMap.emptyCollection.version3.1.obj PredicatedMap.fullCollection.version3.1.obj PredicatedSortedMap.emptyCollection.version3.1.obj FixedSizeSortedMap.emptyCollection.version3.1.obj LazyMap.fullCollection.version3.1.obj TransformedMap.fullCollection.version3.1.obj LazySortedMap.fullCollection.version3.1.obj LazySortedMap.emptyCollection.version3.1.obj ListOrderedMap.fullCollection.version3.1.obj FixedSizeSortedMap.fullCollection.version3.1.obj FixedSizeMap.fullCollection.version3.1.obj PredicatedSortedMap.fullCollection.version3.1.obj
scolebourne 2004/04/09 03:36:02
Modified: collections/src/java/org/apache/commons/collections/map
TransformedMap.java LazySortedMap.java LazyMap.java
PredicatedSortedMap.java TransformedSortedMap.java
FixedSizeMap.java ListOrderedMap.java
PredicatedMap.java FixedSizeSortedMap.java
collections/data/test
TransformedSortedMap.fullCollection.version3.1.obj
TransformedSortedMap.emptyCollection.version3.1.obj
PredicatedMap.fullCollection.version3.1.obj
PredicatedSortedMap.emptyCollection.version3.1.obj
FixedSizeSortedMap.emptyCollection.version3.1.obj
LazyMap.fullCollection.version3.1.obj
TransformedMap.fullCollection.version3.1.obj
LazySortedMap.fullCollection.version3.1.obj
LazySortedMap.emptyCollection.version3.1.obj
ListOrderedMap.fullCollection.version3.1.obj
FixedSizeSortedMap.fullCollection.version3.1.obj
FixedSizeMap.fullCollection.version3.1.obj
PredicatedSortedMap.fullCollection.version3.1.obj
Log:
Simplify the decorator serialization, add javadoc [18815]
Revision Changes Path
1.8 +3 -1 jakarta-commons/collections/src/java/org/apache/commons/collections/map/TransformedMap.java
Index: TransformedMap.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/TransformedMap.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TransformedMap.java 9 Apr 2004 09:43:09 -0000 1.7
+++ TransformedMap.java 9 Apr 2004 10:36:01 -0000 1.8
@@ -37,6 +37,8 @@
* Thus objects must be removed or searched for using their transformed form.
* For example, if the transformation converts Strings to Integers, you must
* use the Integer form to remove objects.
+ * <p>
+ * This class is Serializable from Commons Collections 3.1.
*
* @since Commons Collections 3.0
* @version $Revision$ $Date$
1.6 +4 -23 jakarta-commons/collections/src/java/org/apache/commons/collections/map/LazySortedMap.java
Index: LazySortedMap.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/LazySortedMap.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LazySortedMap.java 7 Apr 2004 23:05:37 -0000 1.5
+++ LazySortedMap.java 9 Apr 2004 10:36:01 -0000 1.6
@@ -15,12 +15,7 @@
*/
package org.apache.commons.collections.map;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
import java.util.Comparator;
-import java.util.Map;
import java.util.SortedMap;
import org.apache.commons.collections.Factory;
@@ -47,6 +42,8 @@
* After the above code is executed, <code>obj</code> will contain
* a new <code>Date</code> instance. Furthermore, that <code>Date</code>
* instance is mapped to the "NOW" key in the map.
+ * <p>
+ * This class is Serializable from Commons Collections 3.1.
*
* @since Commons Collections 3.0
* @version $Revision$ $Date$
@@ -56,7 +53,7 @@
*/
public class LazySortedMap
extends LazyMap
- implements SortedMap, Serializable {
+ implements SortedMap {
/** Serialization version */
private static final long serialVersionUID = 2715322183617658933L;
@@ -107,22 +104,6 @@
}
//-----------------------------------------------------------------------
- /**
- * Write the map out using a custom routine.
- */
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.defaultWriteObject();
- out.writeObject(map);
- }
-
- /**
- * Read the map in using a custom routine.
- */
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- map = (Map) in.readObject();
- }
-
/**
* Gets the map being decorated.
*
1.6 +12 -1 jakarta-commons/collections/src/java/org/apache/commons/collections/map/LazyMap.java
Index: LazyMap.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/LazyMap.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LazyMap.java 7 Apr 2004 23:05:37 -0000 1.5
+++ LazyMap.java 9 Apr 2004 10:36:01 -0000 1.6
@@ -46,6 +46,8 @@
* After the above code is executed, <code>obj</code> will contain
* a new <code>Date</code> instance. Furthermore, that <code>Date</code>
* instance is mapped to the "NOW" key in the map.
+ * <p>
+ * This class is Serializable from Commons Collections 3.1.
*
* @since Commons Collections 3.0
* @version $Revision$ $Date$
@@ -119,6 +121,10 @@
//-----------------------------------------------------------------------
/**
* Write the map out using a custom routine.
+ *
+ * @param out the output stream
+ * @throws IOException
+ * @since Commons Collections 3.1
*/
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
@@ -127,6 +133,11 @@
/**
* Read the map in using a custom routine.
+ *
+ * @param in the input stream
+ * @throws IOException
+ * @throws ClassNotFoundException
+ * @since Commons Collections 3.1
*/
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
1.6 +4 -32 jakarta-commons/collections/src/java/org/apache/commons/collections/map/PredicatedSortedMap.java
Index: PredicatedSortedMap.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/PredicatedSortedMap.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PredicatedSortedMap.java 9 Apr 2004 09:43:09 -0000 1.5
+++ PredicatedSortedMap.java 9 Apr 2004 10:36:01 -0000 1.6
@@ -15,12 +15,7 @@
*/
package org.apache.commons.collections.map;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
import java.util.Comparator;
-import java.util.Map;
import java.util.SortedMap;
import org.apache.commons.collections.Predicate;
@@ -31,6 +26,8 @@
* <p>
* If an object cannot be added to the map, an IllegalArgumentException
* is thrown.
+ * <p>
+ * This class is Serializable from Commons Collections 3.1.
*
* @since Commons Collections 3.0
* @version $Revision$ $Date$
@@ -40,7 +37,7 @@
*/
public class PredicatedSortedMap
extends PredicatedMap
- implements SortedMap, Serializable {
+ implements SortedMap {
/** Serialization version */
private static final long serialVersionUID = 3359846175935304332L;
@@ -74,31 +71,6 @@
}
//-----------------------------------------------------------------------
- /**
- * Write the map out using a custom routine.
- *
- * @param out the output stream
- * @throws IOException
- * @since Commons Collections 3.1
- */
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.defaultWriteObject();
- out.writeObject(map);
- }
-
- /**
- * Read the map in using a custom routine.
- *
- * @param in the input stream
- * @throws IOException
- * @throws ClassNotFoundException
- * @since Commons Collections 3.1
- */
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- map = (Map) in.readObject();
- }
-
/**
* Gets the map being decorated.
*
1.6 +4 -32 jakarta-commons/collections/src/java/org/apache/commons/collections/map/TransformedSortedMap.java
Index: TransformedSortedMap.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/TransformedSortedMap.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TransformedSortedMap.java 9 Apr 2004 09:43:09 -0000 1.5
+++ TransformedSortedMap.java 9 Apr 2004 10:36:01 -0000 1.6
@@ -15,12 +15,7 @@
*/
package org.apache.commons.collections.map;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
import java.util.Comparator;
-import java.util.Map;
import java.util.SortedMap;
import org.apache.commons.collections.Transformer;
@@ -32,6 +27,8 @@
* Thus objects must be removed or searched for using their transformed form.
* For example, if the transformation converts Strings to Integers, you must
* use the Integer form to remove objects.
+ * <p>
+ * This class is Serializable from Commons Collections 3.1.
*
* @since Commons Collections 3.0
* @version $Revision$ $Date$
@@ -40,7 +37,7 @@
*/
public class TransformedSortedMap
extends TransformedMap
- implements SortedMap, Serializable {
+ implements SortedMap {
/** Serialization version */
private static final long serialVersionUID = -8751771676410385778L;
@@ -77,31 +74,6 @@
}
//-----------------------------------------------------------------------
- /**
- * Write the map out using a custom routine.
- *
- * @param out the output stream
- * @throws IOException
- * @since Commons Collections 3.1
- */
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.defaultWriteObject();
- out.writeObject(map);
- }
-
- /**
- * Read the map in using a custom routine.
- *
- * @param in the input stream
- * @throws IOException
- * @throws ClassNotFoundException
- * @since Commons Collections 3.1
- */
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- map = (Map) in.readObject();
- }
-
/**
* Gets the map being decorated.
*
1.7 +12 -1 jakarta-commons/collections/src/java/org/apache/commons/collections/map/FixedSizeMap.java
Index: FixedSizeMap.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/FixedSizeMap.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FixedSizeMap.java 2 Apr 2004 21:15:05 -0000 1.6
+++ FixedSizeMap.java 9 Apr 2004 10:36:01 -0000 1.7
@@ -40,6 +40,8 @@
* IllegalArgumentException is thrown. This is because the put method can
* succeed if the mapping's key already exists in the map, so the put method
* is not always unsupported.
+ * <p>
+ * This class is Serializable from Commons Collections 3.1.
*
* @since Commons Collections 3.0
* @version $Revision$ $Date$
@@ -78,6 +80,10 @@
//-----------------------------------------------------------------------
/**
* Write the map out using a custom routine.
+ *
+ * @param out the output stream
+ * @throws IOException
+ * @since Commons Collections 3.1
*/
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
@@ -86,6 +92,11 @@
/**
* Read the map in using a custom routine.
+ *
+ * @param in the input stream
+ * @throws IOException
+ * @throws ClassNotFoundException
+ * @since Commons Collections 3.1
*/
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
1.15 +12 -1 jakarta-commons/collections/src/java/org/apache/commons/collections/map/ListOrderedMap.java
Index: ListOrderedMap.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/ListOrderedMap.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ListOrderedMap.java 7 Apr 2004 23:17:25 -0000 1.14
+++ ListOrderedMap.java 9 Apr 2004 10:36:01 -0000 1.15
@@ -50,6 +50,8 @@
* <p>
* If an object is added to the Map for a second time, it will remain in the
* original position in the iteration.
+ * <p>
+ * This class is Serializable from Commons Collections 3.1.
*
* @since Commons Collections 3.0
* @version $Revision$ $Date$
@@ -94,6 +96,10 @@
//-----------------------------------------------------------------------
/**
* Write the map out using a custom routine.
+ *
+ * @param out the output stream
+ * @throws IOException
+ * @since Commons Collections 3.1
*/
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
@@ -102,6 +108,11 @@
/**
* Read the map in using a custom routine.
+ *
+ * @param in the input stream
+ * @throws IOException
+ * @throws ClassNotFoundException
+ * @since Commons Collections 3.1
*/
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
1.9 +3 -1 jakarta-commons/collections/src/java/org/apache/commons/collections/map/PredicatedMap.java
Index: PredicatedMap.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/PredicatedMap.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PredicatedMap.java 9 Apr 2004 09:43:09 -0000 1.8
+++ PredicatedMap.java 9 Apr 2004 10:36:01 -0000 1.9
@@ -35,6 +35,8 @@
* <p>
* If an object cannot be added to the map, an IllegalArgumentException
* is thrown.
+ * <p>
+ * This class is Serializable from Commons Collections 3.1.
*
* @since Commons Collections 3.0
* @version $Revision$ $Date$
1.7 +20 -72 jakarta-commons/collections/src/java/org/apache/commons/collections/map/FixedSizeSortedMap.java
Index: FixedSizeSortedMap.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/FixedSizeSortedMap.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FixedSizeSortedMap.java 2 Apr 2004 23:12:34 -0000 1.6
+++ FixedSizeSortedMap.java 9 Apr 2004 10:36:01 -0000 1.7
@@ -15,20 +15,9 @@
*/
package org.apache.commons.collections.map;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
+import java.util.Comparator;
import java.util.SortedMap;
-import org.apache.commons.collections.BoundedMap;
-import org.apache.commons.collections.collection.UnmodifiableCollection;
-import org.apache.commons.collections.set.UnmodifiableSet;
-
/**
* Decorates another <code>SortedMap</code> to fix the size blocking add/remove.
* <p>
@@ -41,6 +30,8 @@
* IllegalArgumentException is thrown. This is because the put method can
* succeed if the mapping's key already exists in the map, so the put method
* is not always unsupported.
+ * <p>
+ * This class is Serializable from Commons Collections 3.1.
*
* @since Commons Collections 3.0
* @version $Revision$ $Date$
@@ -49,8 +40,8 @@
* @author Paul Jack
*/
public class FixedSizeSortedMap
- extends AbstractSortedMapDecorator
- implements SortedMap, BoundedMap, Serializable {
+ extends FixedSizeMap
+ implements SortedMap {
/**
* Factory method to create a fixed size sorted map.
@@ -75,59 +66,12 @@
//-----------------------------------------------------------------------
/**
- * Write the map out using a custom routine.
- */
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.defaultWriteObject();
- out.writeObject(map);
- }
-
- /**
- * Read the map in using a custom routine.
+ * Gets the map being decorated.
+ *
+ * @return the decorated map
*/
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- map = (Map) in.readObject();
- }
-
- //-----------------------------------------------------------------------
- public Object put(Object key, Object value) {
- if (map.containsKey(key) == false) {
- throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
- }
- return map.put(key, value);
- }
-
- public void putAll(Map mapToCopy) {
- for (Iterator it = mapToCopy.keySet().iterator(); it.hasNext(); ) {
- if (mapToCopy.containsKey(it.next()) == false) {
- throw new IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
- }
- }
- map.putAll(mapToCopy);
- }
-
- public void clear() {
- throw new UnsupportedOperationException("Map is fixed size");
- }
-
- public Object remove(Object key) {
- throw new UnsupportedOperationException("Map is fixed size");
- }
-
- public Set entrySet() {
- Set set = map.entrySet();
- return UnmodifiableSet.decorate(set);
- }
-
- public Set keySet() {
- Set set = map.keySet();
- return UnmodifiableSet.decorate(set);
- }
-
- public Collection values() {
- Collection coll = map.values();
- return UnmodifiableCollection.decorate(coll);
+ protected SortedMap getSortedMap() {
+ return (SortedMap) map;
}
//-----------------------------------------------------------------------
@@ -146,12 +90,16 @@
return new FixedSizeSortedMap(map);
}
- public boolean isFull() {
- return true;
+ public Comparator comparator() {
+ return getSortedMap().comparator();
}
- public int maxSize() {
- return size();
+ public Object firstKey() {
+ return getSortedMap().firstKey();
}
-
+
+ public Object lastKey() {
+ return getSortedMap().lastKey();
+ }
+
}
1.2 +2 -2 jakarta-commons/collections/data/test/TransformedSortedMap.fullCollection.version3.1.obj
<<Binary file>>
1.2 +2 -2 jakarta-commons/collections/data/test/TransformedSortedMap.emptyCollection.version3.1.obj
<<Binary file>>
1.2 +1 -1 jakarta-commons/collections/data/test/PredicatedMap.fullCollection.version3.1.obj
<<Binary file>>
1.2 +2 -2 jakarta-commons/collections/data/test/PredicatedSortedMap.emptyCollection.version3.1.obj
<<Binary file>>
1.2 +2 -1 jakarta-commons/collections/data/test/FixedSizeSortedMap.emptyCollection.version3.1.obj
<<Binary file>>
1.2 +1 -1 jakarta-commons/collections/data/test/LazyMap.fullCollection.version3.1.obj
<<Binary file>>
1.2 +1 -1 jakarta-commons/collections/data/test/TransformedMap.fullCollection.version3.1.obj
<<Binary file>>
1.2 +2 -2 jakarta-commons/collections/data/test/LazySortedMap.fullCollection.version3.1.obj
<<Binary file>>
1.2 +2 -2 jakarta-commons/collections/data/test/LazySortedMap.emptyCollection.version3.1.obj
<<Binary file>>
1.2 +1 -1 jakarta-commons/collections/data/test/ListOrderedMap.fullCollection.version3.1.obj
<<Binary file>>
1.2 +3 -2 jakarta-commons/collections/data/test/FixedSizeSortedMap.fullCollection.version3.1.obj
<<Binary file>>
1.2 +2 -1 jakarta-commons/collections/data/test/FixedSizeMap.fullCollection.version3.1.obj
<<Binary file>>
1.2 +2 -2 jakarta-commons/collections/data/test/PredicatedSortedMap.fullCollection.version3.1.obj
<<Binary file>>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org