leosutic 2003/08/10 15:19:24
Modified: attributes/api/src/java/org/apache/avalon/attributes
Attributes.java CachedRepository.java
DefaultCachedRepository.java
EmptyCachedRepository.java
Log:
1. Moved all build stuff into Maven.
2. Wrote a proper test case.
3. Included support for attributes attached to fields and constructors.
4. Slight code cleanups.
Revision Changes Path
1.4 +4 -2
avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/Attributes.java
Index: Attributes.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/Attributes.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Attributes.java 10 Aug 2003 21:47:57 -0000 1.3
+++ Attributes.java 10 Aug 2003 22:19:23 -0000 1.4
@@ -5,9 +5,11 @@
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
/**
@@ -52,7 +54,7 @@
classRepositories.put (clazz, cached); // Should be keyed on
ClassLoader as well.
- initList.removeLast ();
+ initList.remove (initList.size () - 1);
return cached;
}
@@ -89,7 +91,7 @@
/**
* Selects from a collection of attributes only those with a given class.
*/
- private static Collection getAttributes (Collection attrs, Class
attributeClass) throws Exception {
+ private static Collection getAttributes (Collection attrs, Class
attributeClass) {
HashSet result = new HashSet ();
Iterator iter = attrs.iterator ();
while (iter.hasNext ()) {
1.3 +7 -4
avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/CachedRepository.java
Index: CachedRepository.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/CachedRepository.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CachedRepository.java 10 Aug 2003 21:48:15 -0000 1.2
+++ CachedRepository.java 10 Aug 2003 22:19:23 -0000 1.3
@@ -5,12 +5,15 @@
import java.lang.reflect.Method;
import java.util.Collection;
+/**
+ * An attribute repository cache. Used internally to speed up operation.
+ */
interface CachedRepository {
public static final CachedRepository EMPTY = new EmptyCachedRepository ();
- public Collection getAttributes () throws Exception;
- public Collection getAttributes (Field f) throws Exception;
- public Collection getAttributes (Method m) throws Exception;
- public Collection getAttributes (Constructor c) throws Exception;
+ public Collection getAttributes ();
+ public Collection getAttributes (Field f);
+ public Collection getAttributes (Method m);
+ public Collection getAttributes (Constructor c);
}
1.4 +3 -3
avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/DefaultCachedRepository.java
Index: DefaultCachedRepository.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/DefaultCachedRepository.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultCachedRepository.java 10 Aug 2003 21:48:15 -0000 1.3
+++ DefaultCachedRepository.java 10 Aug 2003 22:19:23 -0000 1.4
@@ -72,7 +72,7 @@
}
}
- private static Collection getInheritableAttributes (Collection attrs) throws
Exception {
+ private static Collection getInheritableAttributes (Collection attrs) {
HashSet result = new HashSet ();
Iterator iter = attrs.iterator ();
@@ -85,7 +85,7 @@
return result;
}
- private static Collection getInheritableClassAttributes (Class c) throws
Exception {
+ private static Collection getInheritableClassAttributes (Class c) {
if (c == null) {
return new ArrayList (0);
}
@@ -105,7 +105,7 @@
return result;
}
- private static Collection getInheritableMethodAttributes (Class c, String
methodName, Class[] methodParams) throws Exception {
+ private static Collection getInheritableMethodAttributes (Class c, String
methodName, Class[] methodParams) {
if (c == null) {
return new ArrayList (0);
}
1.3 +4 -4
avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/EmptyCachedRepository.java
Index: EmptyCachedRepository.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/attributes/api/src/java/org/apache/avalon/attributes/EmptyCachedRepository.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EmptyCachedRepository.java 10 Aug 2003 21:48:15 -0000 1.2
+++ EmptyCachedRepository.java 10 Aug 2003 22:19:23 -0000 1.3
@@ -13,19 +13,19 @@
private final static Collection EMPTY_COLLECTION = new ArrayList (0);
- public Collection getAttributes () throws Exception {
+ public Collection getAttributes () {
return EMPTY_COLLECTION;
}
- public Collection getAttributes (Field f) throws Exception {
+ public Collection getAttributes (Field f) {
return EMPTY_COLLECTION;
}
- public Collection getAttributes (Method m) throws Exception {
+ public Collection getAttributes (Method m) {
return EMPTY_COLLECTION;
}
- public Collection getAttributes (Constructor c) throws Exception {
+ public Collection getAttributes (Constructor c) {
return EMPTY_COLLECTION;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]