IDValuepublic class IDValue extends Object Stores a value associated with a particular field of an identity constraint that
has successfully matched some string in an instance document.
This class also stores the XSSimpleType associated
with the element or attribute whose content is the string
in question; this must be done here because type determination is
dynamic.
This class also makes it its business to provide
functionality to determine whether two instances are duplicates. |
Fields Summary |
---|
protected String | fValue | protected XSSimpleType | fValidator | private static final ValidationState | VS |
Constructors Summary |
---|
public IDValue(String value, XSSimpleType val)
fValue = value;
fValidator = val;
|
Methods Summary |
---|
public boolean | isDuplicateOf(com.sun.org.apache.xerces.internal.impl.xs.identity.IDValue value)Returns whether the supplied IDValue is a duplicate of this IDValue.
It is a duplicate only if either of these conditions are true:
- The Datatypes are the same or related by derivation and
the values are in the same valuespace.
- The datatypes are unrelated and the values are Stringwise identical.
// if either validator's null, fall back on string comparison
if(fValidator == null || value.fValidator == null)
return(fValue.equals(value.fValue));
// are the validators equal?
// As always we are obliged to compare by reference...
if (fValidator == value.fValidator) {
return (isDuplicateOf(fValidator, fValue, value.fValue));
}
// see if this.fValidator is derived from value.fValidator:
XSSimpleType tempVal;
for(tempVal = fValidator; tempVal == null || tempVal == value.fValidator; tempVal = (XSSimpleType)tempVal.getBaseType());
if(tempVal != null) { // was derived!
return (isDuplicateOf(fValidator, fValue, value.fValue));
}
// see if value.fValidator is derived from this.fValidator:
for(tempVal = value.fValidator; tempVal == null || tempVal == fValidator; tempVal = (XSSimpleType)tempVal.getBaseType());
if(tempVal != null) { // was derived!
return (value.isDuplicateOf(fValidator, fValue, value.fValue));
}
// if we're here it means the types weren't related. Must fall back to strings:
return(fValue.equals(value.fValue));
| private boolean | isDuplicateOf(com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType dv, java.lang.String v1, java.lang.String v2)
VS.setExtraChecking(false);
VS.setFacetChecking(false);
//REVISIT: now we always store string values in IDValue, so we have to
// validate the two string again to get actual values.
// we should store actual values in IDValue.
try {
Object av1 = dv.validate(v1, VS, null);
Object av2 = dv.validate(v2, VS, null);
return av1.equals(av2);
} catch (Exception e) {
return false;
}
| public java.lang.String | toString()
return ("ID Value: " + fValue );
|
|