KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > DefaultSitemapConfigurationHolder


1 /*
2  * Copyright 1999-2004 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.components;
17
18 import java.util.HashMap JavaDoc;
19 import java.util.Map JavaDoc;
20
21 /**
22  *
23  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
24  * @version CVS $Id: DefaultSitemapConfigurationHolder.java 30932 2004-07-29 17:35:38Z vgritsenko $
25  */

26 public final class DefaultSitemapConfigurationHolder
27     implements SitemapConfigurationHolder {
28
29     /** The role of the sitemap component */
30     private String JavaDoc role;
31     
32     /** The prepared configurations indexed by the ChainedConfiguration */
33     private Map JavaDoc preparedConfigurations;
34     
35     public DefaultSitemapConfigurationHolder(String JavaDoc role) {
36         this.role = role;
37     }
38     
39     /**
40      * @see SitemapConfigurationHolder#getConfiguration()
41      */

42     public ChainedConfiguration getConfiguration() {
43         Map JavaDoc confs = CocoonComponentManager.getCurrentProcessor().getComponentConfigurations();
44         return (ChainedConfiguration) (confs == null ? null : confs.get(this.role));
45     }
46
47     /**
48      * @see SitemapConfigurationHolder#getPreparedConfiguration()
49      */

50     public Object JavaDoc getPreparedConfiguration() {
51         if ( null != this.preparedConfigurations ) {
52             ChainedConfiguration conf = this.getConfiguration();
53             if ( null != conf ) {
54                 return this.preparedConfigurations.get( conf );
55             }
56         }
57         return null;
58     }
59
60     /**
61      * @see SitemapConfigurationHolder#setPreparedConfiguration(ChainedConfiguration, java.lang.Object)
62      */

63     public void setPreparedConfiguration(ChainedConfiguration configuration,
64                                           Object JavaDoc preparedConfig) {
65         if ( null == this.preparedConfigurations ) {
66             this.preparedConfigurations = new HashMap JavaDoc(5);
67         }
68         this.preparedConfigurations.put(configuration, preparedConfig);
69     }
70
71 }
72
Popular Tags