haul 2004/02/15 11:04:58
Modified: src/java/org/apache/cocoon/components/modules/input
AbstractInputModule.java
Log:
provide implementations of previously abstract methods so that descendents
would need
to implement barely one of getAttribute() and getAttributeValues() resulting
in less modules
in the wild that "forget" to implement the others
Revision Changes Path
1.3 +48 -1
cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/AbstractInputModule.java
Index: AbstractInputModule.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/AbstractInputModule.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractInputModule.java 12 Mar 2003 13:27:04 -0000 1.2
+++ AbstractInputModule.java 15 Feb 2004 19:04:58 -0000 1.3
@@ -51,6 +51,10 @@
package org.apache.cocoon.components.modules.input;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
+
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
@@ -71,6 +75,19 @@
implements InputModule, Configurable, Disposable {
/**
+ * For those modules that access only one attribute, have a
+ * fixed collection we can return an iterator for.
+ */
+ final static Vector returnNames;
+ static {
+ Vector tmp = new Vector();
+ tmp.add("attribute");
+ returnNames = tmp;
+ }
+
+
+
+ /**
* Stores (global) configuration parameters as <code>key</code> /
* <code>value</code> pairs.
*/
@@ -102,5 +119,35 @@
public void dispose() {
// Purposely empty so that we don't need to implement it in every
// class.
+ }
+
+ //
+ // you need to implement at least one of the following two methods
+ // since the ones below have a cyclic dependency!
+ //
+
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+ */
+ public Object getAttribute(String name, Configuration modeConf, Map
objectModel) throws ConfigurationException {
+ Object[] result = this.getAttributeValues(name, modeConf,
objectModel);
+ return (result == null ? null : result[0]);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+ */
+ public Object[] getAttributeValues(String name, Configuration modeConf,
Map objectModel)
+ throws ConfigurationException {
+ Object result = this.getAttribute(name, modeConf, objectModel);
+ return (result == null ? null : new Object[] {result});
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
java.util.Map)
+ */
+ public Iterator getAttributeNames(Configuration modeConf, Map
objectModel) throws ConfigurationException {
+ return AbstractInputModule.returnNames.iterator();
}
}