01: package com.bm.ejb3metadata.annotations.analyzer.classes;
02:
03: import com.bm.ejb3metadata.annotations.analyzer.AbsAnnotationVisitor;
04: import com.bm.ejb3metadata.annotations.impl.JCommonBean;
05: import com.bm.ejb3metadata.annotations.metadata.ClassAnnotationMetadata;
06:
07: /**
08: * This class manages the handling of common annotations used by beans.
09: * @param <T> a class extending JCommonBean.
10: * @author Daniel Wiese
11: */
12: public abstract class AbsCommonEjbVisitor<T extends JCommonBean>
13: extends AbsAnnotationVisitor<ClassAnnotationMetadata> {
14:
15: /**
16: * Name attribute of the annotation.
17: */
18: private static final String NAME = "name";
19:
20: /**
21: * mappedName attribute of the annotation.
22: */
23: private static final String MAPPED_NAME = "mappedName";
24:
25: /**
26: * description attribute of the annotation.
27: */
28: private static final String DESCRIPTION = "description";
29:
30: /**
31: * Constructor.
32: * @param classAnnotationMetadata linked to a class metadata
33: */
34: public AbsCommonEjbVisitor(
35: final ClassAnnotationMetadata classAnnotationMetadata) {
36: super (classAnnotationMetadata);
37: }
38:
39: /**
40: * Visits a primitive value of the annotation.<br>
41: * @param name the value name.
42: * @param value the actual value, whose type must be {@link Byte},
43: * {@link Boolean}, {@link Character}, {@link Short},
44: * {@link Integer}, {@link Long}, {@link Float}, {@link Double},
45: * {@link String} or {@link org.ejb3unit.asm.Type}.
46: */
47: @Override
48: public void visit(final String name, final Object value) {
49: if (name.equals(NAME)) {
50: getJCommonBean().setName((String) value);
51: } else if (name.equals(MAPPED_NAME)) {
52: getJCommonBean().setMappedName((String) value);
53: } else if (name.equals(DESCRIPTION)) {
54: getJCommonBean().setDescription((String) value);
55: }
56: }
57:
58: /**
59: * Visits the end of the annotation. <br> Creates the object and store it.
60: */
61: @Override
62: public void visitEnd() {
63: getAnnotationMetadata().setJCommonBean(getJCommonBean());
64: }
65:
66: /**
67: * @return the object used by all beans.
68: */
69: public abstract T getJCommonBean();
70:
71: }
|