for(int i=0; i<o.length; i++) o2[map[i]] = o[i];
return plant(o2);
}
+ public int[] buildSequence(Production p) {
+ Annotation[][] annotations = _bindable.getArgAnnotations();
+ String[] names = _bindable.getArgNames();
+ String name = _bindable.getSimpleName();
+ int len = annotations.length;
+ int ofs = 0;
+ bind.arg[] argtags = new bind.arg[len];
+ for(int i=0; i<names.length; i++)
+ for(Annotation a : annotations[i+ofs])
+ if (a instanceof bind.arg)
+ argtags[i+ofs] = (bind.arg)a;
+ return Target.this.buildSequence(p, names, argtags);
+ }
}
}
ofs++;
}
*/
- String[] names = new String[len];
- bind.arg[] argtags = new bind.arg[len];
+ String[] names = new String[len];
+ bind.arg[] argtags = new bind.arg[len];
for(int i=0; i<names.length; i++)
for(Annotation a : annotations[i+ofs])
if (a instanceof bind.arg)
public abstract <A extends Annotation> A getAnnotation(Class<A> c);
public abstract Object impose(Object[] fields);
public boolean isAnnotationPresent(Class<? extends Annotation> 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);
public String getSimpleName() { return _method.getName(); }
public <A extends Annotation> A getAnnotation(Class<A> 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;
public String getSimpleName() { return _constructor.getName(); }
public <A extends Annotation> A getAnnotation(Class<A> 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;
public String getSimpleName() { return _class.getSimpleName(); }
public <A extends Annotation> A getAnnotation(Class<A> 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<fields.length; i++)
+ ret[i] = fields[i].getAnnotations();
+ return ret;
+ }
+ public String[] getArgNames() {
+ Field[] fields = _class.getFields();
+ String[] ret = new String[fields.length];
+ for(int i=0; i<fields.length; i++)
+ ret[i] = fields[i].getName();
+ return ret;
+ }
}
}