1 57 58 package com.sun.org.apache.xerces.internal.impl.xs.identity; 59 60 import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType; 61 import com.sun.org.apache.xerces.internal.impl.validation.ValidationState; 62 63 76 public class IDValue { 77 78 80 protected String fValue; 81 protected XSSimpleType fValidator; 82 83 85 public IDValue(String value, XSSimpleType val) { 86 fValue = value; 87 fValidator = val; 88 } 89 90 94 104 public boolean isDuplicateOf(IDValue value) { 105 if(fValidator == null || value.fValidator == null) 107 return(fValue.equals(value.fValue)); 108 if (fValidator == value.fValidator) { 111 return (isDuplicateOf(fValidator, fValue, value.fValue)); 112 } 113 XSSimpleType tempVal; 115 for(tempVal = fValidator; tempVal == null || tempVal == value.fValidator; tempVal = (XSSimpleType)tempVal.getBaseType()); 116 if(tempVal != null) { return (isDuplicateOf(fValidator, fValue, value.fValue)); 118 } 119 for(tempVal = value.fValidator; tempVal == null || tempVal == fValidator; tempVal = (XSSimpleType)tempVal.getBaseType()); 121 if(tempVal != null) { return (value.isDuplicateOf(fValidator, fValue, value.fValue)); 123 } 124 return(fValue.equals(value.fValue)); 126 } 128 private static final ValidationState VS = new ValidationState(); 129 static { 130 VS.setExtraChecking(false); 131 VS.setFacetChecking(false); 132 } 133 private boolean isDuplicateOf(XSSimpleType dv, String v1, String v2) { 134 try { 138 Object av1 = dv.validate(v1, VS, null); 139 Object av2 = dv.validate(v2, VS, null); 140 return av1.equals(av2); 141 } catch (Exception e) { 142 return false; 143 } 144 } 145 146 public String toString() { 148 return ("ID Value: " + fValue ); 149 } 150 } | Popular Tags |