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

📄 cmsregistry.java

📁 内容管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        return getModuleData(module, "nicename");
    }
    
    /**
     * Gets a parameter for a module.
     *
     * @param modulename java.lang.String the name of the module.
     * @param parameter java.lang.String the name of the parameter to set.
     * @return value java.lang.String the value to set for the parameter.
     */
    public String getModuleParameter(String modulename, String parameter) {
        String retValue = null;
        try {
            Element param = getModuleParameterElement(modulename, parameter);
            retValue = param.getElementsByTagName("value").item(0).getFirstChild().getNodeValue();
        } catch (Exception exc) {
            // ignore the exception - parameter is not existent
        }
        return retValue;
    }

    /**
     * Gets a parameter for a module.
     *
     * @param modulename java.lang.String the name of the module.
     * @param parameter java.lang.String the name of the parameter to set.
     * @param defaultValue the default value.
     * @return value java.lang.String the value to set for the parameter.
     */
    public String getModuleParameter(String modulename, String parameter, String defaultValue) {
        String retValue = null;
        try {
            Element param = getModuleParameterElement(modulename, parameter);
            retValue = param.getElementsByTagName("value").item(0).getFirstChild().getNodeValue();
        } catch (Exception exc) {
            retValue = defaultValue;
            // ignore the exception - parameter is not existent
        }
        return retValue;
    }

    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @return boolean the value for the parameter in the module.
     */
    public boolean getModuleParameterBoolean(String modulname, String parameter) {
        String value = getModuleParameter(modulname, parameter);
        return (value != null && "true".equalsIgnoreCase(value));
    }

    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public Boolean getModuleParameterBoolean(String modulname, String parameter, Boolean defaultValue) {
        return new Boolean(getModuleParameterBoolean(modulname, parameter, defaultValue.booleanValue()));
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public boolean getModuleParameterBoolean(String modulname, String parameter, boolean defaultValue) {
        if (getModuleParameterBoolean(modulname, parameter)) {
            return true;
        } else {
            return defaultValue;
        }
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public byte getModuleParameterByte(String modulname, String parameter) {
        return Byte.parseByte(getModuleParameter(modulname, parameter));
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public byte getModuleParameterByte(String modulname, String parameter, byte defaultValue) {
        return Byte.parseByte(getModuleParameter(modulname, parameter, Byte.toString(defaultValue)));
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public Byte getModuleParameterByte(String modulname, String parameter, Byte defaultValue) {
        return new Byte(getModuleParameterByte(modulname, parameter, defaultValue.byteValue()));
    }
    
    /**
     * Returns a description for parameter in a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @return String the description for the parameter in the module.
     */
    public String getModuleParameterDescription(String modulname, String parameter) {
        String retValue = null;
        try {
            Element param = getModuleParameterElement(modulname, parameter);
            retValue = param.getElementsByTagName("description").item(0).getFirstChild().getNodeValue();
        } catch (Exception exc) {
            // ignore the exception - parameter is not existent
        }
        return retValue;
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @return boolean the value for the parameter in the module.
     */
    public double getModuleParameterDouble(String modulname, String parameter) {
        return Double.valueOf(getModuleParameter(modulname, parameter)).doubleValue();
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public double getModuleParameterDouble(String modulname, String parameter, double defaultValue) {
        return Double.valueOf(getModuleParameter(modulname, parameter, Double.toString(defaultValue))).doubleValue();
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public Double getModuleParameterDouble(String modulname, String parameter, Double defaultValue) {
        return new Double(getModuleParameterDouble(modulname, parameter, defaultValue.doubleValue()));
    }

    /**
     * Private method to get them XML-Element for a parameter in a module.
     *
     * @param modulename String the name of the module.
     * @param parameter String the name of the parameter.
     * @return Element the XML-Element corresponding to the parameter.
     */
    private Element getModuleParameterElement(String modulename, String parameter) {
        Element retValue = null;
        try {
            Element module = getModuleElement(modulename);
            Element parameters = (Element) (module.getElementsByTagName("parameters").item(0));
            NodeList para = parameters.getElementsByTagName("para");
            for (int i = 0; i < para.getLength(); i++) {
                if (((Element)para.item(i))
                    .getElementsByTagName("name")
                    .item(0)
                    .getFirstChild()
                    .getNodeValue()
                    .equals(parameter)) {
                    // this is the element for the parameter.
                    retValue = (Element)para.item(i);
                    // stop searching - parameter was found
                    break;
                }
            }
        } catch (Exception exc) {
            // ignore the exception - reg is not welformed
        }
        return retValue;
    }

    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public float getModuleParameterFloat(String modulname, String parameter) {
        return Float.valueOf(getModuleParameter(modulname, parameter)).floatValue();
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public float getModuleParameterFloat(String modulname, String parameter, float defaultValue) {
        return Float.valueOf(getModuleParameter(modulname, parameter, Float.toString(defaultValue))).floatValue();
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public Float getModuleParameterFloat(String modulname, String parameter, Float defaultValue) {
        return new Float(getModuleParameterFloat(modulname, parameter, defaultValue.floatValue()));
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @return boolean the value for the parameter in the module.
     */
    public int getModuleParameterInteger(String modulname, String parameter) {
        return Integer.parseInt(getModuleParameter(modulname, parameter));
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public int getModuleParameterInteger(String modulname, String parameter, int defaultValue) {
        return Integer.parseInt(getModuleParameter(modulname, parameter, Integer.toString(defaultValue)));
    }
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public Integer getModuleParameterInteger(String modulname, String parameter, Integer defaultValue) {
        return new Integer(getModuleParameterInteger(modulname, parameter, defaultValue.intValue()));
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public long getModuleParameterLong(String modulname, String parameter) {
        return Long.valueOf(getModuleParameter(modulname, parameter)).longValue();
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public long getModuleParameterLong(String modulname, String parameter, long defaultValue) {
        return Long.valueOf(getModuleParameter(modulname, parameter, Long.toString(defaultValue))).longValue();
    }
    
    /**
     * Returns a parameter for a module.
     *
     * @param modulname String the name of the module.
     * @param parameter String the name of the parameter.
     * @param default the default value.
     * @return boolean the value for the parameter in the module.
     */
    public Long getModuleParameterLong(String modulname, String parameter, Long defaultValue) {
        return new Long(getModuleParameterLong(modulname, parameter, defaultValue.longValue()));
    }
    
    /**
     * Gets all parameter-names for a module.
     *
     * @param modulename String the name of the module.
     * @return value String[] the names of the parameters for a module.
     */
    public String[] getModuleParameterNames(String modulename) {

⌨️ 快捷键说明

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