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

📄 getenv.java

📁 决策树分类中经典算法的ID3和C4.5代码公共包!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        //ASSERT(enumValue >= 0);
        return enumValue;
    }
    
    
    /** Reads the value of an option as an MEnum object.
     * @param optionName The name of the option for which a value is requested.
     * @param optionEnum The MEnum object that will hold the option values.
     * @param deflt The default value for the option if it is not found in the option file.
     * @param help Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @param noPrompt TRUE if prompting always occurs regardless of wether option is set, FALSE
     * otherwise.
     * @return The value for the requested option.
     */
    public String MEnumOption(String optionName, MEnum optionEnum,
    String deflt, String help, boolean nuisance, boolean noPrompt){
        String value = deflt;
        value = get_option_string(optionName);
        return value;
    }
    
    /** Returns the value of an string option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param optionHelp Help display string for using this option.
     * @return The value for the requested option.
     */
    public String get_option_string_no_default(String optionName, String optionHelp) {
        return get_option_string(optionName);
    }
    
    /** Returns the value of an boolean option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param optionHelp Help display string for using this option.
     * @return The value for the requested option.
     */
    public boolean get_option_bool(String optionName, boolean defaultValue, String optionHelp) {
        return get_option_bool(optionName,defaultValue,optionHelp,false);
    }
    
    /** Returns the value of an integer option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param optionHelp Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @param noPrompt TRUE if prompting always occurs regardless of wether option is set, FALSE
     * otherwise.
     * @return The value for the requested option.
     */
    public int get_option_int(String optionName, int defaultValue, String optionHelp, boolean nuisance, boolean noPrompt) {
        BufferedReader file;
        try{
            file = new BufferedReader(new FileReader(optfile));
            
            try{
                while(file.ready()) {
                    String line = file.readLine();
                    if (line == null) break;	//Change made for the JDK1.3 -JL
                    StringTokenizer tokens = new StringTokenizer(line," ");
                    while(tokens.hasMoreTokens())
                        if(tokens.nextToken().equals(optionName))
                            return new Integer(tokens.nextToken()).intValue();
                }
                file.close();
            }catch(IOException e)
            {  Error.err("Could not open Options File!"); }
            
        }catch(FileNotFoundException e)
        {   Error.err("Options File " +
            OptionsFile+" not found!");
        }
        return defaultValue;  //error if reached here!
    }
    
    /** Returns the value of an integer option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param optionHelp Help display string for using this option.
     * @return The value for the requested option.
     */
    public int get_option_int(String optionName, int defaultValue, String optionHelp) {
        return get_option_int(optionName,defaultValue,optionHelp,false,false);
    }
    
    /** Returns the value of an integer option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @return The value for the requested option.
     */
    public int get_option_int(String optionName, int defaultValue) {
        return get_option_int(optionName,defaultValue,"",false,false);
    }
    
    /** Returns the value of an integer option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param optionHelp Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @return The value for the requested option.
     */
    public int get_option_int(String optionName, int defaultValue, String optionHelp, boolean nuisance) {
        return get_option_int(optionName,defaultValue,optionHelp,nuisance,false);
    }
    
    /** Returns the value of an string option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param optionHelp Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @return The value for the requested option.
     */
    public String get_option_string_no_default(String optionName, String optionHelp, boolean nuisance) {
        return get_option_string(optionName);
    }
    
    /** Returns the value of an string option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param optionHelp Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @param noPrompt TRUE if prompting always occurs regardless of wether option is set, FALSE
     * otherwise.
     * @return The value for the requested option.
     */
    public String get_option_string(String optionName, String defaultValue, String optionHelp, boolean nuisance, boolean noPrompt) {
        String value = get_option_string(optionName);
        if(value == null) value = defaultValue;
        return value;
    }
    
    /** Returns the value of an integer option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param optionHelp Help display string for using this option.
     * @return The value for the requested option.
     */
    public int get_option_int(String optionName, String optionHelp) {
        return get_option_int(optionName);
    }
    
    /** Returns the value of an integer option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param optionHelp Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @return The value for the requested option.
     */
    public int get_option_int(String optionName, String optionHelp, boolean nuisance) {
        return get_option_int(optionName);
    }
    
    /** Returns the value of an integer option of the specified name between the given
     * bounds.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param lowerBound The lower bound for possible option values.
     * @param upperBound The upper bound for possible values.
     * @param optionHelp Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @param noPrompt TRUE if prompting always occurs regardless of wether option is set, FALSE
     * otherwise.
     * @return The value for the requested option.
     */
    public int get_option_int_range(String optionName, int defaultValue, int lowerBound, int upperBound, String optionHelp, boolean nuisance, boolean noPrompt) {
        int i = get_option_int(optionName,defaultValue,optionHelp,nuisance,noPrompt);
        return i;
    }
    
    /** Returns the value of an integer option of the specified name between the given
     * bounds.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param lowerBound The lower bound for possible option values.
     * @param upperBound The upper bound for possible values.
     * @param optionHelp Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @return The value for the requested option.
     */
    public int get_option_int_range(String optionName, int defaultValue, int lowerBound, int upperBound, String optionHelp, boolean nuisance) {
        return get_option_int_range(optionName,defaultValue,lowerBound,upperBound,optionHelp,nuisance,false);
    }
    
    /** Returns the value of an integer option of the specified name between the given
     * bounds.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param lowerBound The lower bound for possible option values.
     * @param upperBound The upper bound for possible values.
     * @param optionHelp Help display string for using this option.
     * @return The value for the requested option.
     */
    public int get_option_int_range(String optionName, int defaultValue, int lowerBound, int upperBound, String optionHelp) {
        return get_option_int_range(optionName,defaultValue,lowerBound,upperBound,optionHelp,false,false);
    }
    
    /** Returns the value of an integer option of the specified name between the given
     * bounds.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param lowerBound The lower bound for possible option values.
     * @param upperBound The upper bound for possible values.
     * @return The value for the requested option.
     */
    public int get_option_int_range(String optionName, int defaultValue, int lowerBound, int upperBound) {
        return get_option_int_range(optionName,defaultValue,lowerBound,upperBound,"",false,false);
    }
    
    /** Returns the value of an integer option of the specified name between the given
     * bounds.
     * @param optionName The name of the option for which a value is requested.
     * @param lowerBound The lower bound for possible option values.
     * @param upperBound The upper bound for possible values.
     * @param optionHelp Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @return The value for the requested option.
     */
    public int get_option_int_range(String optionName, int lowerBound, int upperBound, String optionHelp, boolean nuisance) {
        return get_option_int(optionName);
    }
    
    /** Returns the value of an double option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param optionHelp Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @param noPrompt TRUE if prompting always occurs regardless of wether option is set, FALSE
     * otherwise.
     * @return The value for the requested option.
     */
    public double get_option_real(String optionName, double defaultValue, String optionHelp, boolean nuisance, boolean noPrompt) {
        BufferedReader file;
        try{
            file = new BufferedReader(new FileReader(optfile));
            
            try{
                while(file.ready()) {
                    String line = file.readLine();
                    if (line == null) break;	//Change made for the JDK1.3 -JL
                    StringTokenizer tokens = new StringTokenizer(line," ");
                    while(tokens.hasMoreTokens())
                        if(tokens.nextToken().equals(optionName))
                            return new Double(tokens.nextToken()).doubleValue();
                }
                file.close();
            }catch(IOException e)
            {  Error.err("FATAL ERROR - Could not open Options File!"); }
            
        }catch(FileNotFoundException e)
        {   Error.err("FATAL ERROR - Options File " +
            OptionsFile+" not found!");
        }
        return defaultValue;
    }
    
    /** Returns the value of an double option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param optionHelp Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @return The value for the requested option.
     */
    public double get_option_real(String optionName, double defaultValue, String optionHelp, boolean nuisance) {
        return get_option_real(optionName,defaultValue,optionHelp,nuisance,false);
    }
    
    /** Returns the value of an double option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @param optionHelp Help display string for using this option.
     * @return The value for the requested option.
     */
    public double get_option_real(String optionName, double defaultValue, String optionHelp) {
        return get_option_real(optionName,defaultValue,optionHelp,false,false);
    }
    
    /** Returns the value of an double option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param defaultValue The default value for the option if it is not found in the option file.
     * @return The value for the requested option.
     */
    public double get_option_real(String optionName, double defaultValue) {
        return get_option_real(optionName,defaultValue,"",false,false);
    }
    
    /** Returns the value of an double option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param optionHelp Help display string for using this option.
     * @param nuisance TRUE if prompting is required when option is not set, FALSE otherwise.
     * @return The value for the requested option.
     */
    public double get_option_real(String optionName, String optionHelp, boolean nuisance) {
        return get_option_real(optionName,0,optionHelp,nuisance,false);
    }
    
    /** Returns the value of an double option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @param optionHelp Help display string for using this option.
     * @return The value for the requested option.
     */
    public double get_option_real(String optionName, String optionHelp) {
        return get_option_real(optionName,0,optionHelp,false,false);
    }
    
    /** Returns the value of an double option of the specified name.
     * @param optionName The name of the option for which a value is requested.
     * @return The value for the requested option.
     */
    public double get_option_real(String optionName) {
        return get_option_real(optionName,0,"",false,false);
    }
    
}

⌨️ 快捷键说明

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