Package br.com.caelum.vraptor.asm

Examples of br.com.caelum.vraptor.asm.AnnotationVisitor


     */
    protected FieldVisitor fv;

    @Override
    public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
        AnnotationVisitor av = super.visitAnnotation(desc, visible);
        if (fv != null) {
            ((TraceAnnotationVisitor) av).av = fv.visitAnnotation(desc, visible);
        }
        return av;
    }


    // Implementation of the MethodVisitor interface
    // ------------------------------------------------------------------------

    @Override
    public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
        AnnotationVisitor av = super.visitAnnotation(desc, visible);
        if (mv != null) {
            ((TraceAnnotationVisitor) av).av = mv.visitAnnotation(desc, visible);
        }
        return av;
    }

    }

    @Override
    public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
        text.add("\n");
        AnnotationVisitor tav = super.visitAnnotation(desc, visible);
        if (cv != null) {
            ((TraceAnnotationVisitor) tav).av = cv.visitAnnotation(desc, visible);
        }
        return tav;
    }

                av.visitEnum(name, typeconst[0], typeconst[1]);
            } else if (value instanceof AnnotationNode) {
                AnnotationNode an = (AnnotationNode) value;
                an.accept(av.visitAnnotation(name, an.desc));
            } else if (value instanceof List) {
                AnnotationVisitor v = av.visitArray(name);
                List array = (List) value;
                for (int j = 0; j < array.size(); ++j) {
                    accept(v, null, array.get(j));
                }
                v.visitEnd();
            } else {
                av.visit(name, value);
            }
        }
    }

    }

    public void visit(final String name, final Object value) {
        Class c = value.getClass();
        if (c.isArray()) {
            AnnotationVisitor av = visitArray(name);
            if (value instanceof byte[]) {
                byte[] b = (byte[]) value;
                for (int i = 0; i < b.length; i++) {
                    av.visit(null, new Byte(b[i]));
                }

            } else if (value instanceof char[]) {
                char[] b = (char[]) value;
                for (int i = 0; i < b.length; i++) {
                    av.visit(null, new Character(b[i]));
                }

            } else if (value instanceof short[]) {
                short[] b = (short[]) value;
                for (int i = 0; i < b.length; i++) {
                    av.visit(null, new Short(b[i]));
                }

            } else if (value instanceof boolean[]) {
                boolean[] b = (boolean[]) value;
                for (int i = 0; i < b.length; i++) {
                    av.visit(null, Boolean.valueOf(b[i]));
                }

            } else if (value instanceof int[]) {
                int[] b = (int[]) value;
                for (int i = 0; i < b.length; i++) {
                    av.visit(null, new Integer(b[i]));
                }

            } else if (value instanceof long[]) {
                long[] b = (long[]) value;
                for (int i = 0; i < b.length; i++) {
                    av.visit(null, new Long(b[i]));
                }

            } else if (value instanceof float[]) {
                float[] b = (float[]) value;
                for (int i = 0; i < b.length; i++) {
                    av.visit(null, new Float(b[i]));
                }

            } else if (value instanceof double[]) {
                double[] b = (double[]) value;
                for (int i = 0; i < b.length; i++) {
                    av.visit(null, new Double(b[i]));
                }

            }
            av.visitEnd();
        } else {
            addValueElement("annotationValue", name, Type.getDescriptor(c), value.toString());
        }
    }

            }
        }

        @Override
        public void end(final String name) {
            AnnotationVisitor av = (AnnotationVisitor) pop();
            if (av != null) {
                av.visitEnd();
            }
        }

            push(((MethodVisitor) peek()).visitParameterAnnotation(parameter, desc, visible));
        }

        @Override
        public void end(final String name) {
            AnnotationVisitor av = (AnnotationVisitor) pop();
            if (av != null) {
                av.visitEnd();
            }
        }

    private final class AnnotationValueRule extends Rule {

        @Override
        public void begin(final String nm, final Attributes attrs) throws SAXException {
            AnnotationVisitor av = (AnnotationVisitor) peek();
            if (av != null) {
                av.visit(attrs.getValue("name"), getValue(attrs.getValue("desc"), attrs.getValue("value")));
            }
        }

    private final class AnnotationValueEnumRule extends Rule {

        @Override
        public void begin(final String nm, final Attributes attrs) {
            AnnotationVisitor av = (AnnotationVisitor) peek();
            if (av != null) {
                av.visitEnum(attrs.getValue("name"), attrs.getValue("desc"), attrs.getValue("value"));
            }
        }

    private final class AnnotationValueAnnotationRule extends Rule {

        @Override
        public void begin(final String nm, final Attributes attrs) {
            AnnotationVisitor av = (AnnotationVisitor) peek();
            push(av == null ? null : av.visitAnnotation(attrs.getValue("name"), attrs.getValue("desc")));
        }

TOP

Related Classes of br.com.caelum.vraptor.asm.AnnotationVisitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.