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

📄 abstractconfiguration.java

📁 1、采用UTF-8编码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                throw new IllegalArgumentException(                    '\'' + token + "' does not contain an equals sign");            }        }        return props;    }    /**     *  Gets a property from the configuration.     *     *  @param key property to retrieve     *  @return value as object. Will return user value if exists,     *          if not then default value if exists, otherwise null     */    public Object getProperty(String key)    {        // first, try to get from the 'user value' store        Object o = getPropertyDirect(key);        if (o == null)        {            // if there isn't a value there, get it from the defaults if we have            // them            if (defaults != null)            {                o = defaults.getProperty(key);            }        }        //        // We must never give a Container Object out. So if the        // Return Value is a Container, we fix it up to be a        // Vector        //        if (o instanceof Container)        {            o = ((Container) o).asVector();        }        return o;   }    /**     * Get a boolean associated with the given configuration key.     *     * @param key The configuration key.     *     * @return The associated boolean.     *     * @throws NoSuchElementException is thrown if the key doesn't     * map to an existing object.     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Boolean.     */    public boolean getBoolean(String key)    {        Boolean b = getBoolean(key, (Boolean) null);        if (b != null)        {            return b.booleanValue();        }        else        {            throw new NoSuchElementException(                '\'' + key + "' doesn't map to an existing object");        }    }    /**     * Get a boolean associated with the given configuration key.     *     * @param key The configuration key.     * @param defaultValue The default value.     *     * @return The associated boolean.     *     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Boolean.     */    public boolean getBoolean(String key, boolean defaultValue)    {        return getBoolean(key, new Boolean(defaultValue)).booleanValue();    }    /**     * Get a boolean associated with the given configuration key.     *     * @param key The configuration key.     * @param defaultValue The default value.     *     * @return The associated boolean if key is found and has valid     * format, default value otherwise.     *     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Boolean.     */    public Boolean getBoolean(String key, Boolean defaultValue)    {        Object value = resolveContainerStore(key);        if (value instanceof Boolean)        {            return (Boolean) value;        }        else if (value instanceof String)        {            return testBoolean((String) value);        }        else if (value == null)        {            if (defaults != null)            {                return defaults.getBoolean(key, defaultValue);            }            else            {                log.warn("Use Boolean default value for key '" + key + "' (" + defaultValue + ")");                return defaultValue;            }        }        else        {            throw new ClassCastException(                '\'' + key + "' doesn't map to a Boolean object");        }    }    /**     * Get a byte associated with the given configuration key.     *     * @param key The configuration key.     *     * @return The associated byte.     *     * @throws NoSuchElementException is thrown if the key doesn't     * map to an existing object.     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Byte.     * @throws NumberFormatException is thrown if the value mapped     * by the key has not a valid number format.     */    public byte getByte(String key)    {        Byte b = getByte(key, null);        if (b != null)        {            return b.byteValue();        }        else        {            throw new NoSuchElementException(                '\'' + key + " doesn't map to an existing object");        }    }    /**     * Get a byte associated with the given configuration key.     *     * @param key The configuration key.     * @param defaultValue The default value.     *     * @return The associated byte.     *     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Byte.     * @throws NumberFormatException is thrown if the value mapped     * by the key has not a valid number format.     */    public byte getByte(String key, byte defaultValue)    {        return getByte(key, new Byte(defaultValue)).byteValue();    }    /**     * Get a byte associated with the given configuration key.     *     * @param key The configuration key.     * @param defaultValue The default value.     *     * @return The associated byte if key is found and has valid format, default     *         value otherwise.     *     * @throws ClassCastException is thrown if the key maps to an object that     *            is not a Byte.     * @throws NumberFormatException is thrown if the value mapped by the key     *            has not a valid number format.     */    public Byte getByte(String key, Byte defaultValue)    {        Object value = resolveContainerStore(key);        if (value instanceof Byte)        {            return (Byte) value;        }        else if (value instanceof String)        {            Byte b = new Byte((String) value);            return b;        }        else if (value == null)        {            if (defaults != null)            {                return defaults.getByte(key, defaultValue);            }            else            {                log.warn("Use Byte default value for key '" + key + "' (" + defaultValue + ")");                return defaultValue;            }        }        else        {            throw new ClassCastException(                '\'' + key + "' doesn't map to a Byte object");        }    }    /**     * Get a double associated with the given configuration key.     *     * @param key The configuration key.     *     * @return The associated double.     *     * @throws NoSuchElementException is thrown if the key doesn't     * map to an existing object.     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Double.     * @throws NumberFormatException is thrown if the value mapped     * by the key has not a valid number format.     */    public double getDouble(String key)    {        Double d = getDouble(key, null);        if (d != null)        {            return d.doubleValue();        }        else        {            throw new NoSuchElementException(                '\'' + key + "' doesn't map to an existing object");        }    }    /**     * Get a double associated with the given configuration key.     *     * @param key The configuration key.     * @param defaultValue The default value.     *     * @return The associated double.     *     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Double.     * @throws NumberFormatException is thrown if the value mapped     * by the key has not a valid number format.     */    public double getDouble(String key, double defaultValue)    {        return getDouble(key, new Double(defaultValue)).doubleValue();    }    /**     * Get a double associated with the given configuration key.     *     * @param key The configuration key.     * @param defaultValue The default value.     *     * @return The associated double if key is found and has valid     * format, default value otherwise.     *     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Double.     * @throws NumberFormatException is thrown if the value mapped     * by the key has not a valid number format.     */    public Double getDouble(String key, Double defaultValue)    {        Object value = resolveContainerStore(key);        if (value instanceof Double)        {            return (Double) value;        }        else if (value instanceof String)        {            Double d = new Double((String) value);            return d;        }        else if (value == null)        {            if (defaults != null)            {                return defaults.getDouble(key, defaultValue);            }            else            {                log.warn("Use Double default value for key '" + key + "' (" + defaultValue + ")");                return defaultValue;            }        }        else        {            throw new ClassCastException(                '\'' + key + "' doesn't map to a Double object");        }    }    /**     * Get a float associated with the given configuration key.     *     * @param key The configuration key.     *     * @return The associated float.     *     * @throws NoSuchElementException is thrown if the key doesn't     * map to an existing object.     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Float.     * @throws NumberFormatException is thrown if the value mapped     * by the key has not a valid number format.     */    public float getFloat(String key)    {        Float f = getFloat(key, null);        if (f != null)        {            return f.floatValue();        }        else        {            throw new NoSuchElementException(                '\'' + key + "' doesn't map to an existing object");        }    }    /**     * Get a float associated with the given configuration key.     *     * @param key The configuration key.     * @param defaultValue The default value.     *     * @return The associated float.     *     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Float.     * @throws NumberFormatException is thrown if the value mapped     * by the key has not a valid number format.     */    public float getFloat(String key, float defaultValue)    {        return getFloat(key, new Float(defaultValue)).floatValue();    }    /**     * Get a float associated with the given configuration key.     *     * @param key The configuration key.     * @param defaultValue The default value.     *     * @return The associated float if key is found and has valid     * format, default value otherwise.     *     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Float.     * @throws NumberFormatException is thrown if the value mapped     * by the key has not a valid number format.     */    public Float getFloat(String key, Float defaultValue)    {        Object value = resolveContainerStore(key);        if (value instanceof Float)        {            return (Float) value;        }        else if (value instanceof String)        {            Float f = new Float((String) value);            return f;        }        else if (value == null)        {            if (defaults != null)            {                return defaults.getFloat(key, defaultValue);            }            else            {                log.warn("Use Float default value for key '" + key + "' (" + defaultValue + ")");                return defaultValue;            }        }        else        {            throw new ClassCastException(                '\'' + key + "' doesn't map to a Float object");        }    }    /**     * Get a int associated with the given configuration key.     *     * @param key The configuration key.     *     * @return The associated int.     *     * @throws NoSuchElementException is thrown if the key doesn't     * map to an existing object.     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Integer.     * @throws NumberFormatException is thrown if the value mapped     * by the key has not a valid number format.     */    public int getInt(String key)    {        Integer i = getInteger(key, null);        if (i != null)        {            return i.intValue();        }        else        {            throw new NoSuchElementException(                '\'' + key + "' doesn't map to an existing object");        }    }    /**     * Get a int associated with the given configuration key.     *     * @param key The configuration key.     * @param defaultValue The default value.     *     * @return The associated int.     *     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Integer.     * @throws NumberFormatException is thrown if the value mapped     * by the key has not a valid number format.     */    public int getInt(String key, int defaultValue)    {        Integer i = getInteger(key, null);        if (i == null)        {            return defaultValue;        }        return i.intValue();    }    /**     * Get a int associated with the given configuration key.     *     * @param key The configuration key.     * @param defaultValue The default value.     *     * @return The associated int if key is found and has valid format, default     *         value otherwise.     *     * @throws ClassCastException is thrown if the key maps to an object that     *         is not a Integer.     * @throws NumberFormatException is thrown if the value mapped by the key     *         has not a valid number format.     */    public Integer getInteger(String key, Integer defaultValue)    {        Object value = resolveContainerStore(key);        if (value instanceof Integer)        {            return (Integer) value;        }        else if (value instanceof String)        {            Integer i = new Integer((String) value);            return i;        }        else if (value == null)        {            if (defaults != null)            {                return defaults.getInteger(key, defaultValue);            }            else            {                log.warn("Use Integer default value for key '" + key + "' (" + defaultValue + ")");                return defaultValue;            }        }        else        {            throw new ClassCastException(                '\'' + key + "' doesn't map to a Integer object");        }    }    /**     * Get a long associated with the given configuration key.     *     * @param key The configuration key.     *     * @return The associated long.     *     * @throws NoSuchElementException is thrown if the key doesn't     * map to an existing object.     * @throws ClassCastException is thrown if the key maps to an     * object that is not a Long.     * @throws NumberFormatException is thrown if the value mapped     * by the key has not a valid number format.     */    public long getLong(String key)

⌨️ 快捷键说明

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