package frame.object.dao;
|
|
import java.lang.reflect.Method;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
public abstract class MethodPublisher {
|
|
protected Map<String, Method> methodMap;
|
protected Map<String, Method> allMethodMap;
|
|
|
public MethodPublisher() {
|
methodMap = new HashMap<String, Method>();
|
allMethodMap = new HashMap<String, Method>();
|
|
collectMethod();
|
publishMethod();
|
}
|
|
public Method getMethod(String lower) {
|
// TODO Auto-generated method stub
|
return null;
|
}
|
|
protected void collectMethod() {
|
Method[] methods = this.getClass().getDeclaredMethods();
|
|
for (Method one : methods) {
|
allMethodMap.put(one.getName().toLowerCase(), one);
|
}
|
}
|
|
protected abstract void publishMethod();
|
|
protected void addMethod(String name) {
|
if (name == null) {
|
return;
|
}
|
|
name = name.toLowerCase();
|
Method method = allMethodMap.get(name);
|
|
if (method != null) {
|
method.setAccessible(true);
|
methodMap.put(name, method);
|
}
|
}
|
|
public Map<String, Method> getMethodMap() {
|
return methodMap;
|
}
|
|
}
|