Subversion Repositories bacoAlunos

Rev

Rev 1310 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package jomm.utils;

import java.io.InputStreamReader;
import java.util.List;
import java.util.Properties;

/**
 * @author Jorge Machado
 * @date 29/Dez/2007
 * @time 1:47:22
 */

public abstract class ConfigProperties {

    private 1.5.0/docs/api/java/util/Properties.html">Properties props = null;

    public abstract 1.5.0/docs/api/java/lang/String.html">String getPath();

    /**
     * Load properties
     * @return properties
     */

    public 1.5.0/docs/api/java/util/Properties.html">Properties getProperties()
    {
        if(props == null)
        {
            props = new 1.5.0/docs/api/java/util/Properties.html">Properties();
            try
            {
                props.load(new 1.5.0/docs/api/java/io/InputStreamReader.html">InputStreamReader(ConfigProperties.class.getResourceAsStream(getPath()),"UTF-8"));
            }
            catch (1.5.0/docs/api/java/lang/Exception.html">Exception ex)
            {
                throw new 1.5.0/docs/api/java/lang/ExceptionInInitializerError.html">ExceptionInInitializerError(ex);
            }
        }
        return props;
    }


    public 1.5.0/docs/api/java/util/Properties.html">Properties getProps()
    {
        return props;
    }

    /**
     * Get property and convert it to float
     *
     * @param property to get and convert
     * @return float value
     */

    public float getFloat(1.5.0/docs/api/java/lang/String.html">String property)
    {
        return PropertiesUtils.getFloatProperty(property, getProperties());
    }

    /**
     * Get property and convert it to float
     *
     * @param property to get and convert
     * @return boolean value
     */

    public boolean getBoolean(1.5.0/docs/api/java/lang/String.html">String property)
    {
        return PropertiesUtils.getBooleanProperty(property, getProperties());
    }



    /**
     * Get property and convert it to short
     *
     * @param property to get and convert
     * @return float value
     */

    public short getShort(1.5.0/docs/api/java/lang/String.html">String property)
    {

        return PropertiesUtils.getShortProperty(property, getProperties());
    }

    /**
     * Get property and convert it to int
     *
     * @param property to get and convert
     * @return int value
     */

    public int getInt(1.5.0/docs/api/java/lang/String.html">String property)
    {

        return PropertiesUtils.getIntProperty(property, getProperties());
    }


    /**
     *
     * @param property to load
     * @return property value
     */

    public 1.5.0/docs/api/java/lang/String.html">String getProp(1.5.0/docs/api/java/lang/String.html">String property)
    {
        return getProperties().getProperty(property);
    }

    /**
     * @param propertyPrefix to load
     * @return a list of all property names hat starts with the given
     * prefix
     */

    public List<String> getListProps(1.5.0/docs/api/java/lang/String.html">String propertyPrefix)
    {
        return PropertiesUtils.getListProperties(getProperties(),propertyPrefix);
    }

    /**
     * @param propertyPrefix to load
     * @return a list of all property names hat starts with the given
     * prefix
     */

    public List<String> getListVals(1.5.0/docs/api/java/lang/String.html">String propertyPrefix)
    {
        return PropertiesUtils.getListValuesOrderedByPropertyName(getProperties(),propertyPrefix);
    }

   
    /**
     * @param propertyPrefix to load
     * @return a list of all property names hat starts with the given
     * prefix
     */

    public List<String> getListValsOrderedByValue(1.5.0/docs/api/java/lang/String.html">String propertyPrefix)
    {
        return PropertiesUtils.getListValuesOrderedByValue(getProperties(),propertyPrefix);
    }

   
    /**
     * @param propertyPrefix to load
     * @return a list of all property names hat starts with the given
     * prefix
     */

    public List<String> getListValsOrderedByPropertyName(1.5.0/docs/api/java/lang/String.html">String propertyPrefix)
    {
        return PropertiesUtils.getListValuesOrderedByPropertyName(getProperties(),propertyPrefix);
    }
}