integerdescription.java

来自「Boosting算法软件包」· Java 代码 · 共 60 行

JAVA
60
字号
package jboost.examples;import jboost.controller.Configuration;import jboost.tokenizer.BadAttException;/** * the description for number attributes. */class IntegerDescription extends AttributeDescription {  IntegerDescription(String name, Configuration c) throws ClassNotFoundException {    attributeName = name;    attributeClass = Class.forName("jboost.examples.IntegerAttribute");    //  Need to make a SAFE version of configuration, which implements an error() function, which//  can return and error message.        crucial=c.getBool("crucial",false);    ignoreAttribute=c.getBool("ignoreAttribute",false);    existence=c.getBool("existence",false);    existence=c.getBool("order",true);  }    /** checks format of string in datafile and converts to float    *     *  If the attribute is missing it creates a new   *  real attribute, that is not defined.   */  public Attribute str2Att(String string) throws BadAttException {    if(string == null) return(new RealAttribute());    string=string.trim();    if(string.length()==0) return(new RealAttribute());    double att = 0.; // initialized because try complains otherwise.    try {      att = Double.parseDouble(string);    }    catch (NumberFormatException e) {      System.err.println(string + " is not a float.");      throw new BadAttException(string+" is not a float",0,0);    }    return new RealAttribute (att);  }    public String toString() {    String retval=new String(attributeName);    retval+=" "+attributeClass.getName();    retval+=" crucial: "+crucial;    retval+=" ignoreAttribute: "+ignoreAttribute;    retval+=" existence: "+existence;    retval+=" order: "+order;    return(retval);  }    public String toString(Attribute attr) {    String retval=new String();    if(attr==null) return("undefined");    retval+=((RealAttribute)attr).toString();    return(retval);  }}

⌨️ 快捷键说明

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