⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configuration.java

📁 jConfig,JAVA读取XML的开源项目
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package org.jconfig;

import java.util.HashMap;
import java.util.Vector;
import java.util.Properties;
import org.jconfig.event.CategoryListener;
import org.jconfig.event.ConfigurationChangedEvent;
import org.jconfig.event.ConfigurationListener;
import org.jconfig.event.PropertyListener;
/**
 * A Configuraton provides access to all Category and Properties.
 * The Configuration was converted into an Interface after the
 * need for other Configuration implementations existed.
 *
 * @see org.jconfig.DefaultConfiguration
 * @see org.jconfig.ExtensibleConfiguration
 * @since 2.3
 * @author Andreas Mecky <andreas.mecky@xcom.de>
 * @author Terry Dye <terry.dye@xcom.de>
 */
public interface Configuration {
    
    /**
     * Adds a category to the current configuration.
     *
     * @param name Name of the category to be added.
     */
    public void setCategory(String name);
    
    public void setCategory(Category category);
    /**
     * Besides setting the category, it will also set this
     * category as default category if main is true. It will
     * only set (ie create) the category if it does not exist. If you
     * want delete a category then use @see #removeCategory(String)
     *
     * @param name the name of the category
     * @param main if true then this category is the default category
     */
    public void setCategory(String name, boolean main);
    
    /**
     * This method returns the name of the
     * default category
     *
     * @return name of the default category
     */
    public String getMainCategoryName();
    
    /**
     * This method returns a string array with all
     * category names.
     *
     * @return a string array with all category names
     */
    public String[] getCategoryNames();
    
    /**
     * This method returns the String value based on the given key.
     *
     * Implementation details: It calls getProperty(name,null,null).
     * It searches inside the default category for the property.
     *
     * @param key the name of the property
     * @return the value as String if it is found or null
     */
    public String getProperty(String key);
    
    /**
     * This method is the same as getProperty(key) but it
     * returns the defaultValue if the property cannot be found.
     *
     * Implementation details: It calls getProperty(key,defaultValue,null).
     *
     * @param key the name of the property
     * @param defaultValue the defaultValue that will be returned if the property cannot be found
     * @return the value as String
     */
    public String getProperty(String key, String defaultValue);
    
    /**
     * This is the real implementation. It will return the value of the property
     * with the specific name. First of all, it checks if the name of the category
     * exists. If not, then it will use the name of the default category.
     * The next step is that it will look for the property. If it is not found in
     * the category, it will look inside the default category (inheritance). If
     * it still cannot find the property, it will return the defaultValue
     *
     * @param key the name of the property
     * @param defaultValue the default value
     * @param categoryName the name of the category
     * @return the value as String
     */
    public String getProperty(String key,String defaultValue,String categoryName);
    
    /**
     * This method sets a property with the name and the value
     * in the default category. It calls setProperty(name.value,null).
     *
     * @param name the name of the property
     * @param value the value as String
     */
    public void setProperty(String name, String value);
    
    /**
     * This method sets the value for a property for the given
     * category. It also raises a PropertyEvent. If the category
     * is null then it uses the default category.
     *
     * @param name the name of the property
     * @param value the value as String
     * @param categoryName the name of the category
     */
    public void setProperty(String name, String value, String categoryName);
    
    /**
     * This method deletes a property from the default category.
     * It calls removeProperty(name,null).
     *
     * @param name the name of the property
     */
    public void removeProperty(String name);
    
    /**
     * This method deletes a property with the given name
     * from the specific category. If the category is null
     * then it will delete the property from the default category.
     *
     * @param name the name of the property
     * @param category the name of the category
     */
    public void removeProperty(String name, String category);
    
    /**
     * The method returns the number of categories inside this configuration.
     *
     * @return the number of categories
     */
    public int getNumberOfCategories();
    
    /**
     * This method deletes a category with all its properties
     *
     * @param category the name of the category
     */
    public void removeCategory(String category);
    
    /**
     * This method returns all properties for the default category
     * 
     * @return all properties for the default category
     */
    public Properties getProperties();
    
    /**
     * This method returns all properties for the category
     * with the given name
     * 
     * @param name the name of the category
     * @return all properties for the default category
     */
    public Properties getProperties(String name);
    
    /**
     * This method returns all the names of the properties
     * for the specific category
     *
     * @param category the name of the category
     * @return the names as string array
     */
    public String[] getPropertyNames(String category);
    
    /**
     * This method sets a variable inside the configuration.
     *
     * @param name the name of the variable
     * @param value the value of the variable
     */
    public void setVariable(String name, String value);
    
    /**
     * It returns a HashMap with all variables with the
     * variable name as key
     *
     * @return a HashMap with all variables
     */
    public HashMap getVariables();
    
    public String getVariable(String name);
    /**
     * @param name
     * @param defaultValue
     * @return
     */
    public int getIntProperty(String name, int defaultValue);
    
    /**
     * @param name
     * @param defaultValue
     * @param category
     * @return
     */
    public int getIntProperty(String name, int defaultValue, String category);
    
    /**
     * Wrapper method to keep API simple
     *
     * @see Category#getBooleanProperty(String, boolean)
     * @param name
     * @param defaultValue
     * @return
     */
    public boolean getBooleanProperty(String name, boolean defaultValue);
    
    /**
     * Wrapper method to Category method
     *
     * @see Category#getBooleanProperty(String, boolean, String)
     * @param defaultValue
     * @param categoryName
     * @return
     */
    public boolean getBooleanProperty(String name,boolean defaultValue,String categoryName);
    
    /**
     * Wrapper method to Category method
     *
     * @param key
     * @param value
     */
    public void setBooleanProperty(String key, boolean value);
    
    /**
     * Wrapper method to Category method
     *
     * @param key
     * @param value
     * @param category
     */
    public void setBooleanProperty(String key, boolean value, String category);
    
    /**
     * Wrapper method to Category method
     *
     * @param name
     * @param defaultValue
     * @return
     */
    public long getLongProperty(String name, long defaultValue);
    
    /**
     * Wrapper method to Category method
     *
     * @param name
     * @param defaultValue
     * @param category
     * @return
     */
    public long getLongProperty(String name,long defaultValue,String categoryName);
    
    /**
     * Wrapper method to Category method
     *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -