1 16 17 package org.apache.cocoon.components.modules.input; 18 19 import java.util.Iterator ; 20 import java.util.Map ; 21 import java.util.Vector ; 22 23 import org.apache.avalon.framework.activity.Disposable; 24 import org.apache.avalon.framework.configuration.Configurable; 25 import org.apache.avalon.framework.configuration.Configuration; 26 import org.apache.avalon.framework.configuration.ConfigurationException; 27 import org.apache.avalon.framework.logger.AbstractLogEnabled; 28 29 import org.apache.cocoon.util.HashMap; 30 31 39 public abstract class AbstractInputModule extends AbstractLogEnabled 40 implements InputModule, Configurable, Disposable { 41 42 46 final static Vector returnNames; 47 static { 48 Vector tmp = new Vector (); 49 tmp.add("attribute"); 50 returnNames = tmp; 51 } 52 53 54 55 59 protected HashMap settings = null; 60 61 71 public void configure(Configuration conf) throws ConfigurationException { 72 Configuration[] parameters = conf.getChildren(); 73 this.settings = new HashMap(parameters.length); 74 for (int i = 0; i < parameters.length; i++) { 75 String key = parameters[i].getName(); 76 String val = parameters[i].getValue(""); 77 this.settings.put (key, val); 78 } 79 } 80 81 84 public void dispose() { 85 } 88 89 94 97 public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException { 98 Object [] result = this.getAttributeValues(name, modeConf, objectModel); 99 return (result == null ? null : result[0]); 100 } 101 102 105 public Object [] getAttributeValues(String name, Configuration modeConf, Map objectModel) 106 throws ConfigurationException { 107 Object result = this.getAttribute(name, modeConf, objectModel); 108 return (result == null ? null : new Object [] {result}); 109 } 110 111 112 115 public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException { 116 return AbstractInputModule.returnNames.iterator(); 117 } 118 } 119 | Popular Tags |