KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > annotations > AnnotationLocation


1 // Copyright 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.annotations;
16
17 import org.apache.hivemind.Location;
18 import org.apache.hivemind.Resource;
19 import org.apache.hivemind.util.Defense;
20
21 /**
22  * Implementation of {@link org.apache.hivemind.Location} that is used to identify the class and/or
23  * method and annotation. This is useful for line-precise exception reporting of errors related to
24  * annotations.
25  *
26  * @author Howard Lewis Ship
27  * @since 4.0
28  */

29 public class AnnotationLocation implements Location
30 {
31     private final Resource _resource;
32
33     private final String JavaDoc _description;
34
35     public AnnotationLocation(Resource resource, String JavaDoc description)
36     {
37         Defense.notNull(resource, "resource");
38         Defense.notNull(description, "description");
39
40         _resource = resource;
41         _description = description;
42     }
43
44     /**
45      * Returns the location's description.
46      */

47
48     public String JavaDoc toString()
49     {
50         return _description;
51     }
52
53     /**
54      * Returns a resource corresponding to the Java class.
55      */

56
57     public Resource getResource()
58     {
59         return _resource;
60     }
61
62     /**
63      * Always returns 0.
64      */

65
66     public int getLineNumber()
67     {
68         return 0;
69     }
70
71     /**
72      * Always returns 0.
73      */

74
75     public int getColumnNumber()
76     {
77         return 0;
78     }
79
80     @Override JavaDoc
81     public boolean equals(Object JavaDoc other)
82     {
83         if (other instanceof AnnotationLocation)
84         {
85             AnnotationLocation otherLocation = (AnnotationLocation) other;
86
87             return _resource.equals(otherLocation._resource)
88                     && _description.equals(otherLocation._description);
89         }
90
91         return false;
92     }
93 }
94
Popular Tags