KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > modules > input > StringConstantModule


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
17 package org.apache.cocoon.components.modules.input;
18
19 import org.apache.avalon.framework.configuration.Configuration;
20 import org.apache.avalon.framework.configuration.ConfigurationException;
21 import org.apache.avalon.framework.thread.ThreadSafe;
22
23 import java.util.Iterator JavaDoc;
24 import java.util.LinkedList JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Map JavaDoc;
27 import java.util.Vector JavaDoc;
28
29 /**
30  * StringConstantModule returns a constant string.
31  * Constant must be the only content of the configuration object.
32  *
33  * @author <a HREF="mailto:haul@apache.org">Christian Haul</a>
34  * @version CVS $Id: StringConstantModule.java 30932 2004-07-29 17:35:38Z vgritsenko $
35  */

36 public class StringConstantModule extends AbstractInputModule implements ThreadSafe {
37
38     final static Vector JavaDoc returnNames;
39     static {
40         Vector JavaDoc tmp = new Vector JavaDoc();
41         tmp.add("stringConstant");
42         returnNames = tmp;
43     }
44
45     public Object JavaDoc getAttribute( String JavaDoc name, Configuration modeConf, Map JavaDoc objectModel ) throws ConfigurationException {
46         
47         if (modeConf == null) {
48             return null;
49         } else {
50             return modeConf.getValue();
51         }
52     }
53
54
55     public Iterator JavaDoc getAttributeNames( Configuration modeConf, Map JavaDoc objectModel ) throws ConfigurationException {
56
57         return StringConstantModule.returnNames.iterator();
58     }
59
60
61     public Object JavaDoc[] getAttributeValues( String JavaDoc name, Configuration modeConf, Map JavaDoc objectModel )
62         throws ConfigurationException {
63
64             List JavaDoc values = new LinkedList JavaDoc();
65             values.add( this.getAttribute(name, modeConf, objectModel) );
66
67             return values.toArray();
68             
69     }
70
71 }
72
Popular Tags