1 package com.thaiopensource.datatype.xsd; 2 3 import org.relaxng.datatype.ValidationContext; 4 5 class FloatDatatype extends DoubleDatatype { 6 7 Object getValue(String str, ValidationContext vc) { 8 if (str.equals("INF")) 9 return new Float (Float.POSITIVE_INFINITY); 10 if (str.equals("-INF")) 11 return new Float (Float.NEGATIVE_INFINITY); 12 if (str.equals("NaN")) 13 return new Float (Float.NaN); 14 return new Float (str); 15 } 16 17 public boolean isLessThan(Object obj1, Object obj2) { 18 return ((Float )obj1).floatValue() < ((Float )obj2).floatValue(); 19 } 20 21 public boolean sameValue(Object value1, Object value2) { 22 float f1 = ((Float )value1).floatValue(); 23 float f2 = ((Float )value2).floatValue(); 24 return f1 == f2 || (f1 != f1 && f2 != f2); 26 } 27 } 28 | Popular Tags |