Package de.odysseus.calyxo.panels.conf.impl

Source Code of de.odysseus.calyxo.panels.conf.impl.NamespaceConfigImpl

/*
* 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.panels.conf.impl;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import de.odysseus.calyxo.base.conf.ConfigException;
import de.odysseus.calyxo.base.conf.impl.ConfigImpl;
import de.odysseus.calyxo.base.util.ListOrderedMap;
import de.odysseus.calyxo.panels.conf.ListConfig;
import de.odysseus.calyxo.panels.conf.NamespaceConfig;
import de.odysseus.calyxo.panels.conf.ParamConfig;
import de.odysseus.calyxo.panels.conf.PanelConfig;

/**
* Namespace configuration implementation.
*
* @author Christoph Beck
*/
public abstract class NamespaceConfigImpl extends ConfigImpl implements NamespaceConfig {
  private Map params = ListOrderedMap.decorate(new HashMap());
  private Map panels = ListOrderedMap.decorate(new HashMap());
  private Map lists = 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());
    list.add(getPanelConfigs());
    list.add(getListConfigs());
  }

  /**
   * Add panel element
   */
  public void add(PanelConfigImpl value) throws ConfigException {
    if (panels.containsKey(value.getName())) {
      throw new ConfigException("Duplicate panel '" + value.getName() + "' in " + toInlineString());
    }
    panels.put(value.getName(), value);
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.panels.conf.NamespaceConfig#getPanelConfig(java.lang.String)
   */
  public PanelConfig getPanelConfig(String name) {
    return (PanelConfig)panels.get(name);
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.panels.conf.NamespaceConfig#getPanelConfigs()
   */
  public Iterator getPanelConfigs() {
    return panels.values().iterator();
  }

  /**
   * Add param element
   */
  public void add(ParamConfigImpl value) throws ConfigException {
    if (params.containsKey(value.getName())) {
      throw new ConfigException("Duplicate param '" + value.getName() + "' in " + toInlineString());
    }
    params.put(value.getName(), value);
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.panels.conf.NamespaceConfig#getParamConfigs()
   */
  public Iterator getParamConfigs() {
    return params.values().iterator();
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.panels.conf.NamespaceConfig#getParamConfig(java.lang.String)
   */
  public ParamConfig getParamConfig(String name) {
    return (ParamConfig)params.get(name);
  }

  /**
   * Add list element
   */
  public void add(ListConfigImpl value) throws ConfigException {
    if (lists.containsKey(value.getName())) {
      throw new ConfigException("Duplicate list '" + value.getName() + "' in " + toInlineString());
    }
    lists.put(value.getName(), value);
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.panels.conf.NamespaceConfig#getListConfigs()
   */
  public Iterator getListConfigs() {
    return lists.values().iterator();
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.panels.conf.NamespaceConfig#getListConfig(java.lang.String)
   */
  public ListConfig getListConfig(String name) {
    return (ListConfig)lists.get(name);
  }
}
TOP

Related Classes of de.odysseus.calyxo.panels.conf.impl.NamespaceConfigImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.