1 57 58 package org.enhydra.apache.xerces.validators.datatype; 59 60 import java.text.Collator ; 61 import java.util.Hashtable ; 62 import java.util.Locale ; 63 64 78 public class QNameDatatypeValidator extends AbstractStringValidator { 79 80 81 private static DatatypeValidator fgStrValidator = null; 84 85 public QNameDatatypeValidator () throws InvalidDatatypeFacetException { 86 this ( null, null, false ); } 88 89 public QNameDatatypeValidator ( DatatypeValidator base, Hashtable facets, 90 boolean derivedByList ) throws InvalidDatatypeFacetException { 91 92 super (base, facets, derivedByList); 93 } 94 95 protected void assignAdditionalFacets(String key, Hashtable facets) throws InvalidDatatypeFacetException{ 96 throw new InvalidDatatypeFacetException( getErrorString(DatatypeMessageProvider.ILLEGAL_STRING_FACET, 97 DatatypeMessageProvider.MSG_NONE, new Object [] { key })); 98 } 99 100 101 protected void checkValueSpace (String content) throws InvalidDatatypeValueException { 102 103 try { 105 int posColon = content.indexOf(':'); 106 if (posColon >= 0) 107 fgStrValidator.validate(content.substring(0,posColon), null); 108 fgStrValidator.validate(content.substring(posColon+1), null); 109 } catch (InvalidDatatypeValueException idve) { 110 throw new InvalidDatatypeValueException("Value '"+content+"' is not a valid QName"); 111 } 112 } 113 114 public int compare( String content, String facetValue ){ 115 Locale loc = Locale.getDefault(); 116 Collator collator = Collator.getInstance( loc ); 117 return collator.compare( content, facetValue ); 118 } 119 120 protected static void setNCNameValidator (DatatypeValidator dv) { 121 if ( fgStrValidator == null) { 123 fgStrValidator = dv; 124 } 125 } 126 } 127 | Popular Tags |