KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > factory > parsing > Location


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

16
17 package org.springframework.beans.factory.parsing;
18
19 import org.springframework.core.io.Resource;
20 import org.springframework.util.Assert;
21
22 /**
23  * Class that models an arbitrary location in a {@link Resource resource}.
24  *
25  * <p>Typically used to track the location of problematic or erroneous
26  * metadata in XML configuration files. For example, a
27  * {@link #getSource() source} location might be 'The bean defined on
28  * line 76 of beans.properties has an invalid Class'; another source might
29  * be the actual DOM Element from a parsed XML {@link org.w3c.dom.Document};
30  * or the source object might simply be <code>null</code>.
31  *
32  * @author Rob Harrop
33  * @since 2.0
34  */

35 public class Location {
36
37     private final Resource resource;
38
39     private final Object JavaDoc source;
40
41
42     /**
43      * Create a new instance of the {@link Location} class.
44      * @param resource the resource with which this location is associated
45      */

46     public Location(Resource resource) {
47         this(resource, null);
48     }
49
50     /**
51      * Create a new instance of the {@link Location} class.
52      * @param resource the resource with which this location is associated
53      * @param source the actual location within the associated resource
54      * (may be <code>null</code>)
55      */

56     public Location(Resource resource, Object JavaDoc source) {
57         Assert.notNull(resource, "Resource must not be null");
58         this.resource = resource;
59         this.source = source;
60     }
61
62
63     /**
64      * Get the resource with which this location is associated.
65      */

66     public Resource getResource() {
67         return this.resource;
68     }
69
70     /**
71      * Get the actual location within the associated {@link #getResource() resource}
72      * (may be <code>null</code>).
73      * <p>See the {@link Location class level javadoc for this class} for examples
74      * of what the actual type of the returned object may be.
75      */

76     public Object JavaDoc getSource() {
77         return this.source;
78     }
79
80 }
81
Popular Tags