From 0f0ed458838eb080e12ad9a52a46a4060d40df43 Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 4 Jul 2006 22:44:00 -0400 Subject: [PATCH] checkpoint darcs-hash:20060705024400-5007d-5e283d25449c01dc75e7846dabadd203670aabef.gz --- src/edu/berkeley/sbp/misc/Demo.java | 17 +++++++++++++++-- src/edu/berkeley/sbp/util/Reflection.java | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/edu/berkeley/sbp/misc/Demo.java b/src/edu/berkeley/sbp/misc/Demo.java index d29a8f9..212e60e 100644 --- a/src/edu/berkeley/sbp/misc/Demo.java +++ b/src/edu/berkeley/sbp/misc/Demo.java @@ -273,6 +273,19 @@ public class Demo { for(int i=0; i A getAnnotation(Class c); public abstract Object impose(Object[] fields); public boolean isAnnotationPresent(Class c) { return getAnnotation(c) != null; } + + public abstract Annotation[][] getArgAnnotations(); + public abstract String[] getArgNames(); + public static Bindable create(Object o) { if (o instanceof Class) return new BindableClass((Class)o); if (o instanceof Method) return new BindableMethod((Method)o); @@ -344,6 +348,8 @@ public final class Reflection { public String getSimpleName() { return _method.getName(); } public A getAnnotation(Class c) { return _method.getAnnotation(c); } public Object impose(Object[] fields) { return Reflection.impose(_method, fields); } + public Annotation[][] getArgAnnotations() { return _method.getParameterAnnotations(); } + public String[] getArgNames() { return new String[_method.getParameterTypes().length]; } } private static class BindableConstructor extends Bindable { private final Constructor _constructor; @@ -352,6 +358,8 @@ public final class Reflection { public String getSimpleName() { return _constructor.getName(); } public A getAnnotation(Class c) { return _constructor.getAnnotation(c); } public Object impose(Object[] fields) { return Reflection.impose(_constructor, fields); } + public Annotation[][] getArgAnnotations() { return _constructor.getParameterAnnotations(); } + public String[] getArgNames() { return new String[_constructor.getParameterTypes().length]; } } private static class BindableClass extends Bindable { private final Class _class; @@ -360,6 +368,20 @@ public final class Reflection { public String getSimpleName() { return _class.getSimpleName(); } public A getAnnotation(Class c) { return (A)_class.getAnnotation(c); } public Object impose(Object[] fields) { return Reflection.impose(_class, fields); } + public Annotation[][] getArgAnnotations() { + Field[] fields = _class.getFields(); + Annotation[][] ret = new Annotation[fields.length][]; + for(int i=0; i