2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
7 import java.lang.annotation.Annotation;
8 import org.apidesign.bck2brwsr.core.JavaScriptBody;
12 * @author Jaroslav Tulach <jtulach@netbeans.org>
14 final class AnnotationImpl implements Annotation {
15 public Class<? extends Annotation> annotationType() {
19 @JavaScriptBody(args = { "a", "n", "values" }, body =
21 + "for (p in values) {"
22 + " a[p] = function() { return v[p]; }"
24 + "a['$instOf_' + n] = true;"
27 private static <T extends Annotation> T create(AnnotationImpl a, String n, Object values) {
30 static <T extends Annotation> T create(Class<T> annoClass, Object values) {
31 return create(new AnnotationImpl(), annoClass.getName().replace('.', '_'), values);
34 static Annotation[] create(Object anno) {
35 String[] names = findNames(anno);
36 Annotation[] ret = new Annotation[names.length];
37 for (int i = 0; i < names.length; i++) {
38 String n = names[i].substring(1, names[i].length() - 1).replace('/', '_');
39 ret[i] = create(new AnnotationImpl(), n, findData(anno, names[i]));
43 @JavaScriptBody(args = "anno", body =
44 "var arr = new Array();"
50 private static String[] findNames(Object anno) {
51 throw new UnsupportedOperationException();
54 @JavaScriptBody(args={ "anno", "p"}, body="return anno[p];")
55 private static Object findData(Object anno, String p) {
56 throw new UnsupportedOperationException();