001    package com.thaiopensource.datatype.xsd;
002    
003    import org.relaxng.datatype.ValidationContext;
004    
005    abstract class ValueRestrictDatatype extends RestrictDatatype {
006      ValueRestrictDatatype(DatatypeBase base) {
007        super(base);
008      }
009    
010      boolean allowsValue(String str, ValidationContext vc) {
011        return getValue(str, vc) != null;
012      }
013    
014      Object getValue(String str, ValidationContext vc) {
015        Object obj = base.getValue(str, vc);
016        if (obj == null || !satisfiesRestriction(obj))
017          return null;
018        return obj;
019      }
020    
021      abstract boolean satisfiesRestriction(Object value);
022    }