/*
* Copyright 2004, 2005, 2006 Odysseus Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.odysseus.calyxo.control.conf.impl;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import de.odysseus.calyxo.control.conf.ParamConfig;
import de.odysseus.calyxo.control.conf.ParamsConfig;
import de.odysseus.calyxo.base.conf.ConfigException;
import de.odysseus.calyxo.base.conf.impl.ConfigImpl;
import de.odysseus.calyxo.base.util.ListOrderedMap;
/**
* Params configuration implementation class.
*
* @author Christoph Beck
*/
public abstract class ParamsConfigImpl extends ConfigImpl implements ParamsConfig {
private Map paramConfigs = ListOrderedMap.decorate(new HashMap());
/*
* (non-Javadoc)
* @see de.odysseus.calyxo.base.conf.impl.ConfigImpl#_addChildren(de.odysseus.calyxo.base.conf.impl.ConfigImpl.Elements)
*/
protected void _addChildren(Elements list) {
super._addChildren(list);
list.add(getParamConfigs());
}
/**
* Add parameter
*/
public void add(ParamConfigImpl value) throws ConfigException {
if (paramConfigs.containsKey(value.getName())) {
throw new ConfigException("Duplicate param name '" + value.getName() + "' in " + toInlineString());
}
paramConfigs.put(value.getName(), value);
}
/*
* (non-Javadoc)
* @see de.odysseus.calyxo.control.conf.ParamsConfig#getParamConfigs()
*/
public Iterator getParamConfigs() {
return paramConfigs.values().iterator();
}
/*
* (non-Javadoc)
* @see de.odysseus.calyxo.control.conf.ParamsConfig#getParamConfig(java.lang.String)
*/
public ParamConfig getParamConfig(String name) {
return (ParamConfig)paramConfigs.get(name);
}
}