< prev index next >

src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java

Print this page
rev 2127 : 8048021: Remove @version tag in jaxp repo
Reviewed-by: joehw


  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xerces.internal.impl.dv.xs;
  22 
  23 import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
  24 import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext;
  25 import com.sun.org.apache.xerces.internal.xs.datatypes.XSFloat;
  26 
  27 /**
  28  * Represent the schema type "float"
  29  *
  30  * @xerces.internal
  31  *
  32  * @author Neeraj Bajaj, Sun Microsystems, inc.
  33  * @author Sandy Gao, IBM
  34  *
  35  * @version $Id: FloatDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $
  36  */
  37 public class FloatDV extends TypeValidator {
  38 
  39     public short getAllowedFacets(){
  40         return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE  | XSSimpleTypeDecl.FACET_MINEXCLUSIVE  );
  41     }//getAllowedFacets()
  42 
  43     //convert a String to Float form, we have to take care of cases specified in spec like INF, -INF and NaN
  44     public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
  45         try{
  46             return new XFloat(content);
  47         } catch (NumberFormatException ex){
  48             throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "float"});
  49         }
  50     }//getActualValue()
  51 
  52     // Can't call Float#compareTo method, because it's introduced in jdk 1.2
  53     public int compare(Object value1, Object value2){
  54         return ((XFloat)value1).compareTo((XFloat)value2);
  55     }//compare()




  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xerces.internal.impl.dv.xs;
  22 
  23 import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
  24 import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext;
  25 import com.sun.org.apache.xerces.internal.xs.datatypes.XSFloat;
  26 
  27 /**
  28  * Represent the schema type "float"
  29  *
  30  * @xerces.internal
  31  *
  32  * @author Neeraj Bajaj, Sun Microsystems, inc.
  33  * @author Sandy Gao, IBM
  34  *

  35  */
  36 public class FloatDV extends TypeValidator {
  37 
  38     public short getAllowedFacets(){
  39         return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE  | XSSimpleTypeDecl.FACET_MINEXCLUSIVE  );
  40     }//getAllowedFacets()
  41 
  42     //convert a String to Float form, we have to take care of cases specified in spec like INF, -INF and NaN
  43     public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
  44         try{
  45             return new XFloat(content);
  46         } catch (NumberFormatException ex){
  47             throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "float"});
  48         }
  49     }//getActualValue()
  50 
  51     // Can't call Float#compareTo method, because it's introduced in jdk 1.2
  52     public int compare(Object value1, Object value2){
  53         return ((XFloat)value1).compareTo((XFloat)value2);
  54     }//compare()


< prev index next >