try SimpleValue min = (SimpleValue)sType.getFacet(SchemaType.FACET_LENGTH); if (min == null) min = (SimpleValue)sType.getFacet(SchemaType.FACET_MIN_LENGTH); if (min != null) result = result + result; SimpleValue max = (SimpleValue)sType.getFacet(SchemaType.FACET_LENGTH); if (max == null) max = (SimpleValue)sType.getFacet(SchemaType.FACET_MAX_LENGTH); if (max != null)
private static boolean check(String v, SchemaType sType) { int length = v==null ? 0 : v.length(); // check against length XmlObject len = sType.getFacet(SchemaType.FACET_LENGTH); if (len != null) { int m = ((SimpleValue)len).getBigIntegerValue().intValue(); if (!(length != m)) return false; } // check against min length XmlObject min = sType.getFacet(SchemaType.FACET_MIN_LENGTH); if (min != null) { int m = ((SimpleValue)min).getBigIntegerValue().intValue(); if (!(length >= m)) return false; } // check against min length XmlObject max = sType.getFacet(SchemaType.FACET_MAX_LENGTH); if (max != null) { int m = ((SimpleValue)max).getBigIntegerValue().intValue(); if (!(length <= m)) return false; } return true; }
private static boolean check(String v, SchemaType sType) { // check against length XmlObject len = sType.getFacet(SchemaType.FACET_LENGTH); if (len != null) { int m = ((XmlObjectBase)len).getBigIntegerValue().intValue(); if (!(v.length() != m)) return false; } // check against min length XmlObject min = sType.getFacet(SchemaType.FACET_MIN_LENGTH); if (min != null) { int m = ((XmlObjectBase)min).getBigIntegerValue().intValue(); if (!(v.length() >= m)) return false; } // check against min length XmlObject max = sType.getFacet(SchemaType.FACET_MAX_LENGTH); if (max != null) { int m = ((XmlObjectBase)max).getBigIntegerValue().intValue(); if (!(v.length() <= m)) return false; } return true; }
private int pickLength(SchemaType sType) { XmlInteger length = (XmlInteger) sType.getFacet(SchemaType.FACET_LENGTH); if (length != null) return length.getBigIntegerValue().intValue(); XmlInteger min = (XmlInteger) sType.getFacet(SchemaType.FACET_MIN_LENGTH); XmlInteger max = (XmlInteger) sType.getFacet(SchemaType.FACET_MAX_LENGTH); int minInt, maxInt; if (min == null) minInt = 0; else minInt = min.getBigIntegerValue().intValue(); if (max == null) maxInt = Integer.MAX_VALUE; else maxInt = max.getBigIntegerValue().intValue(); // We try to keep the length of the array within reasonable limits, // at least 1 item and at most 3 if possible if (minInt == 0 && maxInt >= 1) minInt = 1; if (maxInt > minInt + 2) maxInt = minInt + 2; if (maxInt < minInt) maxInt = minInt; return minInt + pick(maxInt-minInt); }
xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); BigDecimal min = xmlD != null ? xmlD.getBigDecimalValue() : null; xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); BigDecimal max = xmlD != null ? xmlD.getBigDecimalValue() : null; boolean minInclusive = true, maxInclusive = true; xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (xmlD != null) xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (xmlD != null) xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_TOTAL_DIGITS); int totalDigits = -1; if (xmlD != null) xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_FRACTION_DIGITS); int fractionDigits = -1; BigDecimal increment;
private static void validateValue(long v, SchemaType sType, ValidationContext context) XmlObject td = sType.getFacet(SchemaType.FACET_TOTAL_DIGITS); if (td != null) XmlObject mine = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (mine != null) XmlObject mini = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (mini != null) XmlObject maxi = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (maxi != null) XmlObject maxe = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (maxe != null)
private static void validateValue(int v, SchemaType sType, ValidationContext context) XmlObject td = sType.getFacet(SchemaType.FACET_TOTAL_DIGITS); if (td != null) XmlObject mine = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (mine != null) XmlObject mini = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (mini != null) XmlObject maxi = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (maxi != null) XmlObject maxe = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (maxe != null)
int i; if ((x = sType.getFacet(SchemaType.FACET_LENGTH)) != null) if ((i = ((SimpleValue)x).getBigIntegerValue().intValue()) != v.length()) context.invalid(XmlErrorCodes.DATATYPE_LENGTH_VALID$STRING, new Object[] { "anyURI", v, new Integer(i), QNameHelper.readable(sType) }); if ((x = sType.getFacet(SchemaType.FACET_MIN_LENGTH)) != null) if ((i = ((SimpleValue)x).getBigIntegerValue().intValue()) > v.length()) context.invalid(XmlErrorCodes.DATATYPE_MIN_LENGTH_VALID$STRING, new Object[] { "anyURI", v, new Integer(i), QNameHelper.readable(sType) }); if ((x = sType.getFacet(SchemaType.FACET_MAX_LENGTH)) != null) if ((i = ((SimpleValue)x).getBigIntegerValue().intValue()) < v.length()) context.invalid(XmlErrorCodes.DATATYPE_MAX_LENGTH_VALID$STRING,
XmlObject fd = sType.getFacet(SchemaType.FACET_FRACTION_DIGITS); if (fd != null) XmlObject td = sType.getFacet(SchemaType.FACET_TOTAL_DIGITS); if (td != null) XmlObject mine = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (mine != null) XmlObject mini = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (mini != null) XmlObject maxi = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (maxi != null) XmlObject maxe = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (maxe != null)
private static void validateValue(BigInteger v, SchemaType sType, ValidationContext context) XmlPositiveInteger td = (XmlPositiveInteger)sType.getFacet(SchemaType.FACET_TOTAL_DIGITS); if (td != null) XmlObject mine = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (mine != null) XmlObject mini = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (mini != null) XmlObject maxi = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (maxi != null) XmlObject maxe = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (maxe != null)
GDuration g; if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null) if (v.compareToGDuration(g = ((XmlObjectBase)x).gDurationValue()) <= 0) context.invalid(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID, new Object[] { "duration", v, g, QNameHelper.readable(sType) }); if ((x = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE)) != null) if (v.compareToGDuration(g = ((XmlObjectBase)x).gDurationValue()) < 0) context.invalid(XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_VALID, new Object[] { "duration", v, g, QNameHelper.readable(sType) }); if ((x = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE)) != null) if (v.compareToGDuration(g = ((XmlObjectBase)x).gDurationValue()) >= 0) context.invalid(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_VALID, new Object[] { "duration", v, g, QNameHelper.readable(sType) }); if ((x = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE)) != null) if (v.compareToGDuration(g = ((XmlObjectBase)x).gDurationValue()) > 0) context.invalid(XmlErrorCodes.DATATYPE_MAX_INCLUSIVE_VALID,
context.invalid(XmlErrorCodes.DATE, new Object[] { "Date (" + v + ") does not have the set of fields required for " + QNameHelper.readable(sType) }); if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null) if (v.compareToGDate(g = ((XmlObjectBase)x).gDateValue()) <= 0) context.invalid(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID, new Object[] { "date", v, g, QNameHelper.readable(sType) }); if ((x = sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE)) != null) if (v.compareToGDate(g = ((XmlObjectBase)x).gDateValue()) < 0) context.invalid(XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_VALID, new Object[] { "date", v, g, QNameHelper.readable(sType) }); if ((x = sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE)) != null) if (v.compareToGDate(g = ((XmlObjectBase)x).gDateValue()) >= 0) context.invalid(XmlErrorCodes.DATATYPE_MAX_EXCLUSIVE_VALID, new Object[] { "date", v, g, QNameHelper.readable(sType) }); if ((x = sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE)) != null) if (v.compareToGDate(g = ((XmlObjectBase)x).gDateValue()) > 0) context.invalid(XmlErrorCodes.DATATYPE_MAX_INCLUSIVE_VALID,
private String formatDuration(SchemaType sType) (XmlDuration) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); GDuration minInclusive = null; if (d != null) minInclusive = d.getGDurationValue(); d = (XmlDuration) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); GDuration maxInclusive = null; if (d != null) maxInclusive = d.getGDurationValue(); d = (XmlDuration) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); GDuration minExclusive = null; if (d != null) minExclusive = d.getGDurationValue(); d = (XmlDuration) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); GDuration maxExclusive = null; if (d != null)