1 package com.thaiopensource.relaxng.impl; 2 3 import org.relaxng.datatype.Datatype; 4 5 class ValuePattern extends StringPattern { 6 private final Object obj; 7 private final Datatype dt; 8 9 ValuePattern(Datatype dt, Object obj) { 10 super(combineHashCode(VALUE_HASH_CODE, obj.hashCode())); 11 this.dt = dt; 12 this.obj = obj; 13 } 14 15 boolean samePattern(Pattern other) { 16 if (getClass() != other.getClass()) 17 return false; 18 if (!(other instanceof ValuePattern)) 19 return false; 20 return (dt.equals(((ValuePattern)other).dt) 21 && dt.sameValue(obj, ((ValuePattern)other).obj)); 22 } 23 24 void accept(PatternVisitor visitor) { 25 visitor.visitValue(dt, obj); 26 } 27 28 Object apply(PatternFunction f) { 29 return f.caseValue(this); 30 } 31 32 void checkRestrictions(int context, DuplicateAttributeDetector dad, Alphabet alpha) 33 throws RestrictionViolationException { 34 switch (context) { 35 case START_CONTEXT: 36 throw new RestrictionViolationException("start_contains_value"); 37 } 38 } 39 40 Datatype getDatatype() { 41 return dt; 42 } 43 44 Object getValue() { 45 return obj; 46 } 47 48 } 49 | Popular Tags |