All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.mind.plugin.ConfigurationElement Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (C) 2010 STMicroelectronics
 *
 * This file is part of "Mind Compiler" is free software: you can redistribute 
 * it and/or modify it under the terms of the GNU Lesser General Public License 
 * as published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see .
 *
 * Contact: [email protected]
 *
 * Authors: Matthieu Leclercq
 * Contributors: 
 */

package org.ow2.mind.plugin;

import java.util.Map;

/**
 * Base interface for configuration element.
 */
public interface ConfigurationElement {

  /**
   * Returns the name of this configuration element.
   * 
   * @return the name of this configuration element.
   */
  String getName();

  /**
   * Returns the value of the attribute with the given name.
   * 
   * @param name an attribute name.
   * @return the value of the attribute with the given name, or
   *         null if this configuration element have no attribute
   *         with the given name.
   */
  String getAttribute(String name);

  /**
   * Returns the value of the attribute with the given name, or the given
   * default value if this configuration element have no attribute with the
   * given name.
   * 
   * @param name an attribute name.
   * @param defaultValue the default value.
   * @return the value of the attribute with the given name, or the given
   *         default value if this configuration element have no attribute with
   *         the given name.
   */
  String getAttribute(String name, String defaultValue);

  /**
   * Returns the map of every attributes.
   * 
   * @return an unmodifiable map associating attribute names to their values.
   */
  Map getAttributes();

  /**
   * Interprets the attribute attrName as a fully qualified name of
   * a java class and returns an instance of this class.
   * 
   * @param  the expected type of the java class
   * @param attrName the name of the attribute
   * @param expectedType the class that is supposed to be a super class of the
   *          created instance.
   * @return an instance of the class whose name is the value of the attribute
   *         called attrName. Returns null if the
   *         attribute has no value.
   */
   T createInstance(String attrName, Class expectedType);

  /**
   * Returns the configuration element children.
   * 
   * @return the configuration element children. Returns an empty iterable if
   *         this {@link ConfigurationElement} has no child.
   */
  Iterable getChildren();

  /**
   * Returns the first configuration element child.
   * 
   * @return the first configuration element child. Returns null if
   *         this configuration element has no child.
   */
  ConfigurationElement getChild();

  /**
   * Returns the configuration element children with the given name.
   * 
   * @param name the name of the y objects to return.
   * @return configuration element children. Returns an empty iterable if this y
   *         has no child.
   */
  Iterable getChildren(String name);

  /**
   * Returns the first configuration element child with the given name.
   * 
   * @param name the name of the configuration element objects to return.
   * @return a configuration element child. Returns null if this
   *         configuration element has no child with the given name.
   */
  ConfigurationElement getChild(String name);

  /**
   * Returns the parent of this configuration element}.
   * 
   * @return the parent of this configuration element. Can be a
   *         {@link ConfigurationElement} or an {@link Extension}.
   */
  Object getParent();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy