KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > aval > support > validator > AValTargetValidator


1 /**
2  * Spoon - http://spoon.gforge.inria.fr/
3  * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
4  *
5  * This software is governed by the CeCILL-C License under French law and
6  * abiding by the rules of distribution of free software. You can use,
7  * modify and/or redistribute the software under the terms of the
8  * CeCILL-C
9  * license as circulated by CEA, CNRS and INRIA at the following URL:
10  * http://www.cecill.info.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C
15  * License for more details.
16  *
17  * The fact that you are presently reading this means that you have had
18  * knowledge of the CeCILL-C license and that you accept its terms.
19  */

20
21 package spoon.aval.support.validator;
22
23 import spoon.aval.Validator;
24 import spoon.aval.annotation.structure.AValTarget;
25 import spoon.aval.processing.AValProcessor;
26 import spoon.aval.processing.ValidationPoint;
27
28 /**
29  * Implementation for the &#64;Validator {@link AValTarget}
30  *
31  * <p>
32  * This class is responible for the validation of the target of an annotation.
33  * It takes the CtElement defined in the {@link AValTarget} and checks that it
34  * is the same type as the one in validation point. If it is not, it reports an
35  * ERROR
36  *
37  * @see AValTarget
38  */

39 public class AValTargetValidator implements Validator<AValTarget> {
40
41     /**
42      * Implementation of the Validator interface. Called by
43      * {@link AValProcessor}
44      */

45     public void check(ValidationPoint<AValTarget> vp) {
46         if (!vp.getValAnnotation().value().isAssignableFrom(
47                 vp.getProgramElement().getClass())) {
48             String JavaDoc message = vp.getValAnnotation().message().replace("?val", vp.getValAnnotation().value().toString());
49             ValidationPoint.report(vp.getValAnnotation().severity(), vp.getDslAnnotation(),
50                     message,vp.fixerFactory(vp.getValAnnotation().fixers()));
51         }
52     }
53
54 }
55
Popular Tags