1 package com.thaiopensource.datatype.xsd; 2 3 import com.thaiopensource.datatype.xsd.regex.Regex; 4 import com.thaiopensource.datatype.xsd.regex.RegexEngine; 5 import com.thaiopensource.datatype.xsd.regex.RegexSyntaxException; 6 7 class RegexDatatype extends TokenDatatype { 8 private final String pattern; 9 private Regex regex; 10 11 RegexDatatype(String pattern) { 12 this.pattern = pattern; 13 } 14 15 synchronized void compile(RegexEngine engine) throws RegexSyntaxException { 16 if (regex == null) 17 regex = engine.compile(pattern); 18 } 19 20 public boolean lexicallyAllows(String str) { 21 return regex.matches(str); 22 } 23 24 public boolean alwaysValid() { 25 return false; 26 } 27 } 28 | Popular Tags |