01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.cocoon.components.modules.input;
19:
20: import org.apache.avalon.framework.configuration.Configuration;
21: import org.apache.avalon.framework.configuration.ConfigurationException;
22: import org.apache.avalon.framework.thread.ThreadSafe;
23:
24: import java.util.Iterator;
25: import java.util.LinkedList;
26: import java.util.List;
27: import java.util.Map;
28: import java.util.Vector;
29:
30: /**
31: * StringConstantModule returns a constant string.
32: * Constant must be the only content of the configuration object.
33: *
34: * @author <a href="mailto:haul@apache.org">Christian Haul</a>
35: * @version $Id: StringConstantModule.java 433543 2006-08-22 06:22:54Z crossley $
36: */
37: public class StringConstantModule extends AbstractInputModule implements
38: ThreadSafe {
39:
40: final static Vector returnNames;
41: static {
42: Vector tmp = new Vector();
43: tmp.add("stringConstant");
44: returnNames = tmp;
45: }
46:
47: public Object getAttribute(String name, Configuration modeConf,
48: Map objectModel) throws ConfigurationException {
49:
50: if (modeConf == null) {
51: return null;
52: } else {
53: return modeConf.getValue();
54: }
55: }
56:
57: public Iterator getAttributeNames(Configuration modeConf,
58: Map objectModel) throws ConfigurationException {
59:
60: return StringConstantModule.returnNames.iterator();
61: }
62:
63: public Object[] getAttributeValues(String name,
64: Configuration modeConf, Map objectModel)
65: throws ConfigurationException {
66:
67: List values = new LinkedList();
68: values.add(this.getAttribute(name, modeConf, objectModel));
69:
70: return values.toArray();
71:
72: }
73:
74: }
|