1 16 package org.apache.cocoon.components.modules.input; 17 18 import java.util.Iterator ; 19 import java.util.Map ; 20 21 import org.apache.avalon.framework.configuration.Configuration; 22 import org.apache.avalon.framework.configuration.ConfigurationException; 23 24 72 public abstract class AbstractJXPathModule extends AbstractInputModule { 73 74 79 protected JXPathHelperConfiguration configuration; 80 81 84 protected String parameter; 85 86 93 public void configure(Configuration config) throws ConfigurationException { 94 95 this.configuration = JXPathHelper.setup(config); 96 } 97 98 99 public Object getAttribute(String name, Configuration modeConf, Map objectModel) 100 throws ConfigurationException { 101 102 Object contextObj = getContextObject(modeConf, objectModel); 103 if (modeConf != null) { 104 name = modeConf.getChild("parameter").getValue(this.parameter != null ? this.parameter : name); 105 } 106 return JXPathHelper.getAttribute(name, modeConf, this.configuration, contextObj); 107 } 108 109 110 public Iterator getAttributeNames(Configuration modeConf, Map objectModel) 111 throws ConfigurationException { 112 113 Object contextObj = getContextObject(modeConf, objectModel); 114 return JXPathHelper.getAttributeNames(this.configuration, contextObj); 115 } 116 117 118 public Object [] getAttributeValues(String name, Configuration modeConf, Map objectModel) 119 throws ConfigurationException { 120 121 Object contextObj = getContextObject(modeConf, objectModel); 122 if (modeConf != null) { 123 name = modeConf.getChild("parameter").getValue(this.parameter != null ? this.parameter : name); 124 } 125 return JXPathHelper.getAttributeValues(name, modeConf, this.configuration, contextObj); 126 } 127 128 129 135 protected abstract Object getContextObject(Configuration modeConf, 136 Map objectModel) 137 throws ConfigurationException; 138 } 139 | Popular Tags |