KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > sitemap > SitemapParameters


1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
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 package org.apache.cocoon.sitemap;
17
18 import java.util.HashMap JavaDoc;
19
20 import org.apache.avalon.framework.parameters.Parameters;
21 import org.apache.cocoon.util.location.Locatable;
22 import org.apache.cocoon.util.location.Location;
23
24 /**
25  * Extension to the Avalon Parameters to give location information
26  *
27  * @version CVS $Id: SitemapParameters.java 232400 2005-08-12 22:14:26Z sylvain $
28  */

29 public class SitemapParameters extends Parameters implements Locatable {
30     
31     private Location location = Location.UNKNOWN;
32     
33     public SitemapParameters(Location location) {
34         this.location = location;
35     }
36     
37     /*
38      * Get the location of the statement defining these parameters.
39      *
40      * @since 2.1.8
41      * @see org.apache.cocoon.util.location.Locatable#getLocation()
42      */

43     public Location getLocation() {
44         return this.location;
45     }
46     
47     /**
48      * Get the location of a <code>Parameters</code> object, returning
49      * {@link Location#UNKNOWN} if no location could be found.
50      *
51      * @param param
52      * @return the location
53      * @since 2.1.8
54      */

55     public static Location getLocation(Parameters param) {
56         Location loc = null;
57         if (param instanceof Locatable) {
58             loc = ((Locatable)param).getLocation();
59         }
60         return loc == null ? Location.UNKNOWN : loc;
61     }
62
63     /**
64      * @deprecated use {@link #getLocation(Parameters)}
65      */

66     public static String JavaDoc getStatementLocation(Parameters param) {
67         return getLocation(param).toString();
68     }
69
70     /**
71      * For internal use only.
72      */

73     public static class LocatedHashMap extends HashMap JavaDoc implements Locatable {
74         private Location loc;
75
76         public Location getLocation() {
77             return this.loc;
78         }
79         
80         public LocatedHashMap(Location loc) {
81             this.loc = loc;
82         }
83
84         public LocatedHashMap(Location loc, int size) {
85             super(size);
86             this.loc = loc;
87         }
88     }
89 }
90
Popular Tags