1 16 17 package org.apache.xerces.impl.dv.xs; 18 19 import org.apache.xerces.impl.dv.InvalidDatatypeValueException; 20 import org.apache.xerces.impl.dv.ValidationContext; 21 22 32 public class BooleanDV extends TypeValidator{ 33 34 private static final String fValueSpace[] = {"false", "true", "0", "1"}; 35 36 public short getAllowedFacets(){ 37 return (XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE); 38 } 39 40 public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException { 41 Boolean ret = null; 42 43 if (content.equals(fValueSpace[0]) || content.equals(fValueSpace[2])) 44 ret = Boolean.FALSE; 45 else if (content.equals(fValueSpace[1]) || content.equals(fValueSpace[3])) 46 ret = Boolean.TRUE; 47 else 48 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object []{content, "boolean"}); 49 return ret; 50 } 51 52 } | Popular Tags |