001 /* 002 * Created on Aug 5, 2005 003 * 004 */ 005 package aima.learning.framework; 006 007 /** 008 * @author Ravi Mohan 009 * 010 */ 011 public class NumericAttributeSpecification implements AttributeSpecification { 012 013 // a simple attribute representing a number reprsented as a double . 014 private String name; 015 016 public NumericAttributeSpecification(String name) { 017 this.name = name; 018 } 019 020 public boolean isValid(String string) { 021 try { 022 Double.parseDouble(string); 023 return true; 024 } catch (Exception e) { 025 return false; 026 } 027 } 028 029 public String getAttributeName() { 030 return name; 031 } 032 033 public Attribute createAttribute(String rawValue) { 034 return new NumericAttribute(Double.parseDouble(rawValue), this); 035 } 036 037 }