Author: sshafroi
Date: 2008-11-11 17:12:37 +0100 (Tue, 11 Nov 2008)
New Revision: 6922
Added:
trunk/generic.sesam/search-command-config/src/main/java/no/sesat/search/mode/config/FastCommandConfigBeanInfo.java
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/AbstractBeanInfoHelper.java
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/CommandConfigBeanInfo.java
Modified:
trunk/core-api/src/main/java/no/sesat/search/view/velocity/URLResourceLoader.java
trunk/generic.sesam/search-command-control/default/src/test/java/no/sesat/search/mode/config/SearchModeTest.java
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/CommandConfig.java
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/ModesSearchConfigurationDeserializer.java
Log:
Issue SKER4404: (Automatically assign config settings in
readSearchConfiguration where there is a setter)
Replaced the current implementation with a JavaBean based one.
Modified:
trunk/core-api/src/main/java/no/sesat/search/view/velocity/URLResourceLoader.java
===================================================================
---
trunk/core-api/src/main/java/no/sesat/search/view/velocity/URLResourceLoader.java
2008-11-11 08:03:33 UTC (rev 6921)
+++
trunk/core-api/src/main/java/no/sesat/search/view/velocity/URLResourceLoader.java
2008-11-11 16:12:37 UTC (rev 6922)
@@ -116,7 +116,6 @@
}
}catch( IOException e ){
- LOG.debug( ERR_RESOURCE_NOT_FOUND + url);
throw new ResourceNotFoundException( ERR_RESOURCE_NOT_FOUND + url
);
}
}
@@ -160,7 +159,6 @@
return findUrlImpl(url, currentSite);
}catch( IOException e ){
- LOG.error( ERR_RESOURCE_NOT_FOUND + url, e );
throw new ResourceNotFoundException( ERR_RESOURCE_NOT_FOUND + url
);
}
}
Added:
trunk/generic.sesam/search-command-config/src/main/java/no/sesat/search/mode/config/FastCommandConfigBeanInfo.java
===================================================================
---
trunk/generic.sesam/search-command-config/src/main/java/no/sesat/search/mode/config/FastCommandConfigBeanInfo.java
(rev 0)
+++
trunk/generic.sesam/search-command-config/src/main/java/no/sesat/search/mode/config/FastCommandConfigBeanInfo.java
2008-11-11 16:12:37 UTC (rev 6922)
@@ -0,0 +1,36 @@
+/* Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ * SESAT is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SESAT is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with SESAT. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package no.sesat.search.mode.config;
+
+import java.beans.IntrospectionException;
+
+/**
+ * BeanInfo for the FastCommandConfig class
+ *
+ */
+public class FastCommandConfigBeanInfo extends CommandConfigBeanInfo {
+
+ public FastCommandConfigBeanInfo() throws ClassNotFoundException,
IntrospectionException {
+ this(FastCommandConfig.class);
+ }
+
+ public FastCommandConfigBeanInfo(Class<?> cls) throws
ClassNotFoundException, IntrospectionException {
+ super(cls);
+ add("collections", "getCollections", "addCollections");
+ }
+}
\ No newline at end of file
Modified:
trunk/generic.sesam/search-command-control/default/src/test/java/no/sesat/search/mode/config/SearchModeTest.java
===================================================================
---
trunk/generic.sesam/search-command-control/default/src/test/java/no/sesat/search/mode/config/SearchModeTest.java
2008-11-11 08:03:33 UTC (rev 6921)
+++
trunk/generic.sesam/search-command-control/default/src/test/java/no/sesat/search/mode/config/SearchModeTest.java
2008-11-11 16:12:37 UTC (rev 6922)
@@ -63,9 +63,8 @@
webCrawl.addCollections(new String[]{"webcrawlno1",
"webcrawlno1deep1"});
webCrawl.addCollections(new String[]{"webcrawlno2"});
// webCrawl.addResultHandler(new TextOutputResultHandler());
- webCrawl.addResultField("url");
- webCrawl.addResultField("title");
- webCrawl.addResultField("body");
+ webCrawl.addResultFields(new String[]{"url"});
+ webCrawl.addResultFields(new String[]{"title", "body"});
webCrawl.setSpellchecklanguage("no");
webCrawl.setResultsToReturn(10);
Added:
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/AbstractBeanInfoHelper.java
===================================================================
---
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/AbstractBeanInfoHelper.java
(rev 0)
+++
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/AbstractBeanInfoHelper.java
2008-11-11 16:12:37 UTC (rev 6922)
@@ -0,0 +1,75 @@
+/* Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ * SESAT is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SESAT is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with SESAT. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package no.sesat.search.mode.config;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ * Helper class to make it easy to non standard PropertyDescriptors in a
BeanInfo.
+ */
+public class AbstractBeanInfoHelper extends SimpleBeanInfo{
+
+ private final ArrayList<PropertyDescriptor> descriptors = new
ArrayList<PropertyDescriptor>();
+ private final Class<?> cls;
+
+ /**
+ * Populate the descriptors with the standard JavaBean descriptors, using
the supplied class.
+ *
+ * @param cls Class that we are making a BeanInfo for.
+ * @throws IntrospectionException
+ */
+ public AbstractBeanInfoHelper(Class<?> cls) throws IntrospectionException {
+ this.cls = cls;
+ Collections.addAll(descriptors, Introspector.getBeanInfo(cls,
Introspector.IGNORE_ALL_BEANINFO)
+ .getPropertyDescriptors());
+ // remove this introspection from the cache to avoid reuse of the
+ // IGNORE_ALL_BEANINFO result
+ // (This sounds like a broken cache, if this is true)
+ Introspector.flushFromCaches(cls);
+ }
+
+ /**
+ * Add a descriptor
+ *
+ * @param name name of the property
+ * @param getter name of the getter, null if none
+ * @param setter name of the setter, null if none
+ * @throws IntrospectionException
+ */
+ protected final void add(String name, String getter, String setter) throws
IntrospectionException {
+ ArrayList<PropertyDescriptor> remove = new
ArrayList<PropertyDescriptor>();
+ for(PropertyDescriptor d : descriptors) {
+ if (d.getName().equals(name)) {
+ remove.add(d);
+ }
+ }
+ descriptors.removeAll(remove);
+ descriptors.add(new PropertyDescriptor(name, cls, getter, setter));
+ }
+
+ @Override
+ public final PropertyDescriptor[] getPropertyDescriptors() {
+ PropertyDescriptor[] res = new PropertyDescriptor[descriptors.size()];
+ return descriptors.toArray(res);
+ }
+}
\ No newline at end of file
Modified:
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/CommandConfig.java
===================================================================
---
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/CommandConfig.java
2008-11-11 08:03:33 UTC (rev 6921)
+++
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/CommandConfig.java
2008-11-11 16:12:37 UTC (rev 6922)
@@ -26,6 +26,8 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.TreeMap;
+
import no.sesat.search.query.transform.QueryTransformerConfig;
import no.sesat.search.result.handler.ResultHandlerConfig;
@@ -34,8 +36,8 @@
import java.util.List;
import no.sesat.search.mode.SearchModeFactory.Context;
import no.sesat.search.result.Navigator;
-import no.sesat.search.site.config.AbstractDocumentFactory;
-import no.sesat.search.site.config.AbstractDocumentFactory.ParseType;
+
+import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -71,7 +73,7 @@
private final List<QueryTransformerConfig> queryTransformers = new
ArrayList<QueryTransformerConfig>();
private final List<ResultHandlerConfig> resultHandlers = new
ArrayList<ResultHandlerConfig>();
- private final Map<String,String> resultFields = new
HashMap<String,String>();
+ private final Map<String,String> resultFields = new
TreeMap<String,String>();
private int resultsToReturn = -1;
private String queryParameter = "";
@@ -146,22 +148,15 @@
}
/**
- * @param resultField
- * String seperated with ' AS '.
- */
- private final void addResultField(final String resultField) {
- if (resultField != null && !resultField.equals("")) {
- addResultField(resultField.trim().split(" AS "));
- }
- }
-
- /**
* @param resultFields
* Result fields to add.
*/
- public final void addResultFields(final String[] resultFields) {
- for (String string : resultFields) {
- addResultField(string);
+ public final void addResultFields(final String[] resultFieldArray) {
+ for (String resultField : resultFieldArray) {
+ if (resultField != null && !resultField.equals("")) {
+ String [] split = resultField.trim().split(" AS ");
+ resultFields.put(split[0].trim(), (split.length >1 ? split[1]
: split[0]).trim());
+ }
}
}
@@ -359,7 +354,12 @@
@Override
public String toString() {
- return ModesSearchConfigurationDeserializer.toString(this);
+ try {
+ return this.getClass().getSimpleName() + " " +
BeanUtils.describe(this).toString();
+ } catch (Exception e) {
+ LOG.warn("Failed to do BeanUtils.describe", e);
+ }
+ return this.getClass().getSimpleName();
}
// Inner classes -------------------------------------------------
Added:
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/CommandConfigBeanInfo.java
===================================================================
---
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/CommandConfigBeanInfo.java
(rev 0)
+++
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/CommandConfigBeanInfo.java
2008-11-11 16:12:37 UTC (rev 6922)
@@ -0,0 +1,36 @@
+/* Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ * SESAT is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SESAT is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with SESAT. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package no.sesat.search.mode.config;
+
+import java.beans.IntrospectionException;
+
+/**
+ * BeanInfo for the CommnadConfig class
+ *
+ */
+public class CommandConfigBeanInfo extends AbstractBeanInfoHelper {
+
+ public CommandConfigBeanInfo() throws ClassNotFoundException,
IntrospectionException {
+ this(CommandConfig.class);
+ }
+
+ public CommandConfigBeanInfo(Class<?> clas) throws ClassNotFoundException,
IntrospectionException {
+ super(clas);
+ add("resultFields", "getResultFields", "addResultFields");
+ }
+}
Modified:
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/ModesSearchConfigurationDeserializer.java
===================================================================
---
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/ModesSearchConfigurationDeserializer.java
2008-11-11 08:03:33 UTC (rev 6921)
+++
trunk/search-command-config-spi/src/main/java/no/sesat/search/mode/config/ModesSearchConfigurationDeserializer.java
2008-11-11 16:12:37 UTC (rev 6922)
@@ -18,31 +18,35 @@
package no.sesat.search.mode.config;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import no.sesat.Interpreter;
-import no.sesat.Interpreter.Context;
-
import org.apache.log4j.Logger;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
public class ModesSearchConfigurationDeserializer {
-
private static final Logger LOG =
Logger.getLogger(ModesSearchConfigurationDeserializer.class);
- private final static
Map<Class<SearchConfiguration.ModesW3cDomDeserialiser>, Map<String,
MethodWrapper>> ClassMethodMap = new
HashMap<Class<SearchConfiguration.ModesW3cDomDeserialiser>, Map<String,
MethodWrapper>>();
- private static final String[] getters = {"get", "is"};
- private static final String[] setters = {"set", "add"};
+ public static void readSearchConfiguration(final
SearchConfiguration.ModesW3cDomDeserialiser config,
+ final Element element, final SearchConfiguration inherit) {
+ HashMap<String, PropertyDescriptor> descriptors = new HashMap<String,
PropertyDescriptor>();
+ String[] path = new String[]{"no.sesat.search.mode.config"};
+ Introspector.setBeanInfoSearchPath(path);
+ try {
+ BeanInfo info = Introspector.getBeanInfo(config.getClass());
+ for (PropertyDescriptor d : info.getPropertyDescriptors()) {
+ descriptors.put(d.getName(), d);
+ }
+ } catch (IntrospectionException e) {
+ LOG.error("Failed to get bean info from class " +
config.getClass().getSimpleName(), e);
+ }
- public static void readSearchConfiguration(final
SearchConfiguration.ModesW3cDomDeserialiser config, final Element element,
final SearchConfiguration inherit) {
- Set<String> methods = getMethodNames(config.getClass(), setters);
-
NamedNodeMap attribs = element.getAttributes();
for (int i = 0; i < attribs.getLength(); i++) {
Node attrib = attribs.item(i);
@@ -51,278 +55,80 @@
final StringBuilder beanName = new StringBuilder(name);
for (int j = 0; j < beanName.length(); ++j) {
final char c = beanName.charAt(j);
- if (j == 0) {
- beanName.replace(j, j + 1,
String.valueOf(Character.toUpperCase(c)));
- } else if ('-' == c) {
+ if ('-' == c) {
beanName.replace(j, j + 2,
String.valueOf(Character.toUpperCase(beanName.charAt(j + 1))));
++j;
}
}
- setAttribute(config, beanName.toString(),
attrib.getNodeValue());
- methods.remove(beanName.toString());
- }
- }
+ PropertyDescriptor descriptor =
descriptors.get(beanName.toString());
- // inherited attributes
- if (inherit != null) {
- for (String method : methods) {
- Object value = getAttribute(inherit, method);
- if (value != null) {
- setAttribute(config, method, value);
- }
- }
- }
- }
+ if (descriptor != null) {
+ Method setter = descriptor.getWriteMethod();
- private static boolean startsWith(String string, String[] prefixes) {
- for (String p : prefixes) {
- if (string.startsWith(p))
- return true;
- }
- return false;
- }
-
- /**
- * Fetch the method map for klass, if it has not been initialized this will
- * be done first.
- *
- * @param klass
- * @return A mapping between name and the MethodWrapper.
- */
- private static Map<String, MethodWrapper> getMethodMap(Class klass) {
- if (ClassMethodMap.containsKey(klass)) {
- return ClassMethodMap.get(klass);
- } else if (klass == null) {
- return null;
- }
-
- Method[] methods = klass.getMethods();
- Map<String, MethodWrapper> methodMap = new HashMap<String,
MethodWrapper>();
- ClassMethodMap.put(klass, methodMap);
-
- for (int i = 0; i < methods.length; i++) {
- Method method = methods[i];
- String name = method.getName();
- if (startsWith(name, setters)) {
- Class<?>[] paramTypes = method.getParameterTypes();
- if (paramTypes.length == 1) {
- MethodWrapper.Type type =
MethodWrapper.getType(paramTypes[0]);
- if (type == MethodWrapper.Type.Unsupported) {
- LOG
- .trace("Unsupported type for: " + name + " "
- +
method.getParameterTypes()[0].getSimpleName());
- } else {
-
- if (!methodMap.containsKey(name)) {
- methodMap.put(name, new MethodWrapper(type,
method));
+ if (setter != null) {
+ Class<?> type = setter.getParameterTypes()[0];
+ Object value = null;
+ String valueString = attrib.getNodeValue();
+ if (type == String.class)
+ value = valueString;
+ else if (type == String[].class)
+ value = valueString.split(",");
+ else if (type == int.class || type == Integer.class)
+ value = Integer.parseInt(valueString);
+ else if (type == boolean.class || type ==
Boolean.class)
+ value = Boolean.parseBoolean(valueString);
+ else if (type == char.class || type ==
Character.class) {
+ value = valueString.charAt(0);
+ if (valueString.length() > 1)
+ LOG.error("Setting char attribute where input
was more then a character long");
} else {
- LOG.error("Method already in map: " + name);
+ LOG.error("Failed to set attribute " +
setter.getName() + ", unnsuported type.");
}
- }
- }
- } else if (startsWith(name, getters) &&
method.getParameterTypes().length == 0) {
- MethodWrapper.Type type =
MethodWrapper.getType(method.getReturnType());
- if (type == MethodWrapper.Type.Unsupported) {
- LOG.trace("Unsupported type for: " + name + " " +
method.getReturnType().getSimpleName());
- } else {
- if (!methodMap.containsKey(name)) {
- methodMap.put(name, new MethodWrapper(type, method));
+ if (value != null) {
+ try {
+
+ setter.invoke(config, value);
+ } catch (Exception e) {
+ LOG.info("Failed to set attribute with name: "
+ setter.getName() + "(" + type + ").");
+ }
+ }
} else {
- LOG.error("Method already in map: " + name);
+ LOG.warn("Missing setter for: " + beanName.toString());
}
+ descriptors.remove(beanName.toString());
+ } else {
+ LOG.warn("Unknown attribute in configfile: " +
beanName.toString());
}
}
}
- getMethodMap(klass.getSuperclass());
- return methodMap;
- }
+ // inherited attributes
+ if (inherit != null) {
+ for (PropertyDescriptor d : descriptors.values()) {
+ Method getter = d.getReadMethod();
+ if (getter != null &&
getter.getDeclaringClass().isInstance(inherit)) {
+ Object value = null;
- /**
- * All method wrappers found for this class.
- *
- * @return Set with all method wrappers found for this class.
- */
- private static Set<String> getMethodNames(Class klass, String[] prefix) {
- Set<String> result = new HashSet<String>();
- Map<String, MethodWrapper> map = getMethodMap(klass);
- while (map != null) {
- for (String key : map.keySet()) {
- for (String s : prefix) {
- if (key.startsWith(s)) {
- result.add(key.substring(s.length()));
+ try {
+ value = getter.invoke(inherit);
+ } catch (Exception e) {
+ LOG.error("Failed to get value from " +
inherit.getName(), e);
}
- }
- }
+ if (value != null) {
+ Method setter = d.getWriteMethod();
+ if (setter != null) {
+ try {
- klass = klass.getSuperclass();
- map = getMethodMap(klass);
- }
- return result;
- }
+ setter.invoke(config, value);
- private static void
setAttribute(SearchConfiguration.ModesW3cDomDeserialiser config, final String
name, final Object value) {
- MethodWrapper method = getMethodWrapper(config.getClass(), name,
setters);
-
- if (method != null) {
- if (!method.setValue(config, value)) {
- LOG.error("Setting value on " +
config.getClass().getSimpleName() + " " + name + "==" + value + " failed.");
- }
- } else {
- LOG.error("Setting value on " + config.getClass().getSimpleName()
+ " " + name + "==" + value
- + " failed because method was not found.");
- }
-
- }
-
- private static Object getAttribute(final Object object, final String name)
{
- MethodWrapper method = getMethodWrapper(object.getClass(), name,
getters);
-
- return method != null ? method.getValue(object) : null;
- }
-
- private static MethodWrapper getMethodWrapper(Class klass, final String
name, final String[] pre) {
- Map<String, MethodWrapper> map = getMethodMap(klass);
- while (map != null) {
- for (String s : pre) {
- String g = s + name.substring(0, 1).toUpperCase() +
name.substring(1);
- if (map.containsKey(g)) {
- return map.get(g);
+ } catch (Exception e) {
+ LOG.error("Failed to set value from " +
inherit.getName() + " on " + config.getName(),
+ e);
+ }
+ }
+ }
}
}
- klass = klass.getSuperclass();
- map = getMethodMap(klass);
}
- return null;
}
-
- public static String toString(SearchConfiguration.ModesW3cDomDeserialiser
config) {
- String res = config.getClass().getSimpleName() + " ";
- Set<String> methods = getMethodNames(config.getClass(), getters);
- for (String s : methods) {
- res += s + "==";
- Object o = getAttribute(config, s);
- if (o instanceof String[]) {
- res += "[";
- for (String a : (String[]) o) {
- res += "\"" + a + "\" ";
- }
- res += "] ";
- } else if (o instanceof String) {
- res += "\"" + o + "\" ";
- } else {
- res += o + " ";
- }
- }
- return res;
- }
-
- /**
- * Helper class to encapsulate a method.
- */
- private static class MethodWrapper {
-
- enum Type {
- String, StringArray, Integer, Boolean, Char, Unsupported
- }
-
- private Method method;
- private final Type type;
-
- private MethodWrapper(Type type, Method method) {
- this.type = type;
- this.method = method;
- }
-
- private boolean setValue(Object obj, Object value) {
- if (value instanceof String) {
- String valueString = (String) value;
- switch (type) {
- case String:
- break;
- case StringArray:
- value = valueString.split(",");
- break;
- case Integer:
- value = Integer.parseInt(valueString);
- break;
- case Boolean:
- value = Boolean.parseBoolean(valueString);
- break;
- case Char:
- value = valueString.charAt(0);
- if (valueString.length() > 1)
- LOG.error("Setting char attribute where input was more
then a character long");
- break;
- default:
- LOG.error("Failed to set attribute " + method.getName() +
", unnsuported type.");
- return false;
- }
- }
- try {
- method.invoke(obj, value);
- } catch (Exception e) {
- LOG.info("Failed to set attribute with name: " +
method.getName() + "(" + type + ").");
- return false;
- }
- return true;
- }
-
- private Object getValue(Object obj) {
- try {
- return method.invoke(obj);
- } catch (Exception e) {
- LOG.error("Failed to get attribute with name: " + type + " " +
method.getName() + "(). "
- + e.getMessage(), e);
- }
- return null;
- }
-
- private static Type getType(Class klass) {
- Type type;
- String simpleName = klass.getSimpleName();
-
- if (simpleName.equals("String"))
- type = MethodWrapper.Type.String;
- else if (simpleName.equals("String[]"))
- type = MethodWrapper.Type.StringArray;
- else if (simpleName.equals("int") || simpleName.equals("Integer"))
- type = MethodWrapper.Type.Integer;
- else if (simpleName.equals("boolean") ||
simpleName.equals("Boolean"))
- type = MethodWrapper.Type.Boolean;
- else if (simpleName.equals("char") ||
simpleName.equals("Character"))
- type = MethodWrapper.Type.Char;
- else
- type = MethodWrapper.Type.Unsupported;
- return type;
- }
-
- public String toString() {
- return method.getName() + " Type: " + type;
- }
- }
-
- /**
- * Add some debug function to the interpreter.
- */
- static {
- Interpreter.addFunction("scmap", new Interpreter.Function() {
- public String execute(Context ctx) {
- String res = "";
- for (Class c : ClassMethodMap.keySet()) {
- res += "CLASS: " + c.getSimpleName() + "\n";
- for (String s : ClassMethodMap.get(c).keySet()) {
- res += " " + ClassMethodMap.get(c).get(s).toString()
+ "\n";
- }
- res += "\n";
- }
- return res;
- }
-
- public String describe() {
- return "Print out the ClassMethodMap cache in
AbstractSearchConfiguration.";
- }
-
- });
- }
}
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits