use of org.apache.tapestry5.dom.Visitor in project tapestry-5 by apache.
the class AnnotationNode method accept.
/**
* Makes the given visitor visit a given annotation value.
*
* @param annotationVisitor an annotation visitor. Maybe {@literal null}.
* @param name the value name.
* @param value the actual value.
*/
public static void accept(final AnnotationVisitor annotationVisitor, final String name, final Object value) {
if (annotationVisitor != null) {
if (value instanceof String[]) {
String[] typeValue = (String[]) value;
annotationVisitor.visitEnum(name, typeValue[0], typeValue[1]);
} else if (value instanceof AnnotationNode) {
AnnotationNode annotationValue = (AnnotationNode) value;
annotationValue.accept(annotationVisitor.visitAnnotation(name, annotationValue.desc));
} else if (value instanceof List) {
AnnotationVisitor arrayAnnotationVisitor = annotationVisitor.visitArray(name);
if (arrayAnnotationVisitor != null) {
List<?> arrayValue = (List<?>) value;
for (int i = 0, n = arrayValue.size(); i < n; ++i) {
accept(arrayAnnotationVisitor, null, arrayValue.get(i));
}
arrayAnnotationVisitor.visitEnd();
}
} else {
annotationVisitor.visit(name, value);
}
}
}
use of org.apache.tapestry5.dom.Visitor in project tapestry-5 by apache.
the class FieldNode method accept.
/**
* Makes the given class visitor visit this field.
*
* @param classVisitor a class visitor.
*/
public void accept(final ClassVisitor classVisitor) {
FieldVisitor fieldVisitor = classVisitor.visitField(access, name, desc, signature, value);
if (fieldVisitor == null) {
return;
}
// Visit the annotations.
if (visibleAnnotations != null) {
for (int i = 0, n = visibleAnnotations.size(); i < n; ++i) {
AnnotationNode annotation = visibleAnnotations.get(i);
annotation.accept(fieldVisitor.visitAnnotation(annotation.desc, true));
}
}
if (invisibleAnnotations != null) {
for (int i = 0, n = invisibleAnnotations.size(); i < n; ++i) {
AnnotationNode annotation = invisibleAnnotations.get(i);
annotation.accept(fieldVisitor.visitAnnotation(annotation.desc, false));
}
}
if (visibleTypeAnnotations != null) {
for (int i = 0, n = visibleTypeAnnotations.size(); i < n; ++i) {
TypeAnnotationNode typeAnnotation = visibleTypeAnnotations.get(i);
typeAnnotation.accept(fieldVisitor.visitTypeAnnotation(typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, true));
}
}
if (invisibleTypeAnnotations != null) {
for (int i = 0, n = invisibleTypeAnnotations.size(); i < n; ++i) {
TypeAnnotationNode typeAnnotation = invisibleTypeAnnotations.get(i);
typeAnnotation.accept(fieldVisitor.visitTypeAnnotation(typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, false));
}
}
// Visit the non standard attributes.
if (attrs != null) {
for (int i = 0, n = attrs.size(); i < n; ++i) {
fieldVisitor.visitAttribute(attrs.get(i));
}
}
fieldVisitor.visitEnd();
}
use of org.apache.tapestry5.dom.Visitor in project tapestry-5 by apache.
the class MethodNode method accept.
/**
* Makes the given class visitor visit this method.
*
* @param classVisitor a class visitor.
*/
public void accept(final ClassVisitor classVisitor) {
String[] exceptionsArray = exceptions == null ? null : exceptions.toArray(new String[0]);
MethodVisitor methodVisitor = classVisitor.visitMethod(access, name, desc, signature, exceptionsArray);
if (methodVisitor != null) {
accept(methodVisitor);
}
}
Aggregations