XMLDatatypeUtil { public static boolean isValidValue(String value, IRI datatype) { boolean result = true; if (datatype.equals(XSD.DECIMAL)) { result = isValidDecimal(value); } else if (datatype.equals(XSD.INTEGER)) { result = isValidInteger(value); } else if (datatype.equals(XSD.NEGATIVE_INTEGER)) { result = isValidNegativeInteger(value); } else if (datatype.equals(XSD.NON_POSITIVE_INTEGER)) { result = isValidNonPositiveInteger(value); } else if (datatype.equals(XSD.NON_NEGATIVE_INTEGER)) { result = isValidNonNegativeInteger(value); } else if (datatype.equals(XSD.POSITIVE_INTEGER)) { result = isValidPositiveInteger(value); } else if (datatype.equals(XSD.LONG)) { result = isValidLong(value); } else if (datatype.equals(XSD.INT)) { result = isValidInt(value); } else if (datatype.equals(XSD.SHORT)) { result = isValidShort(value); } else if (datatype.equals(XSD.BYTE)) { result = isValidByte(value); } else if (datatype.equals(XSD.UNSIGNED_LONG)) { result = isValidUnsignedLong(value); } else if (datatype.equals(XSD.UNSIGNED_INT)) { result = isValidUnsignedInt(value); } else if (datatype.equals(XSD.UNSIGNED_SHORT)) { result = isValidUnsignedShort(value); } else if (datatype.equals(XSD.UNSIGNED_BYTE)) { result = isValidUnsignedByte(value); } else if (datatype.equals(XSD.FLOAT)) { result = isValidFloat(value); } else if (datatype.equals(XSD.DOUBLE)) { result = isValidDouble(value); } else if (datatype.equals(XSD.BOOLEAN)) { result = isValidBoolean(value); } else if (datatype.equals(XSD.DATETIME)) { result = isValidDateTime(value); } else if (datatype.equals(XSD.DATETIMESTAMP)) { result = isValidDateTimeStamp(value); } else if (datatype.equals(XSD.DATE)) { result = isValidDate(value); } else if (datatype.equals(XSD.TIME)) { result = isValidTime(value); } else if (datatype.equals(XSD.GDAY)) { result = isValidGDay(value); } else if (datatype.equals(XSD.GMONTH)) { result = isValidGMonth(value); } else if (datatype.equals(XSD.GMONTHDAY)) { result = isValidGMonthDay(value); } else if (datatype.equals(XSD.GYEAR)) { result = isValidGYear(value); } else if (datatype.equals(XSD.GYEARMONTH)) { result = isValidGYearMonth(value); } else if (datatype.equals(XSD.DURATION)) { result = isValidDuration(value); } else if (datatype.equals(XSD.DAYTIMEDURATION)) { result = isValidDayTimeDuration(value); } else if (datatype.equals(XSD.YEARMONTHDURATION)) { result = isValidYearMonthDuration(value); } else if (datatype.equals(XSD.QNAME)) { result = isValidQName(value); } else if (datatype.equals(XSD.ANYURI)) { result = isValidAnyURI(value); } else if (datatype.equals(XSD.LANGUAGE)) { result = Literals.isValidLanguageTag(value); } return result; }  static boolean isPrimitiveDatatype(IRI datatype); static boolean isDerivedDatatype(IRI datatype); static boolean isBuiltInDatatype(IRI datatype); static boolean isNumericDatatype(IRI datatype); static boolean isDecimalDatatype(IRI datatype); static boolean isIntegerDatatype(IRI datatype); static boolean isFloatingPointDatatype(IRI datatype); static boolean isCalendarDatatype(IRI datatype); static boolean isDurationDatatype(IRI datatype); static boolean isOrderedDatatype(IRI datatype); static boolean isValidValue(String value, IRI datatype); static boolean isValidDecimal(String value); static boolean isValidInteger(String value); static boolean isValidNegativeInteger(String value); static boolean isValidNonPositiveInteger(String value); static boolean isValidNonNegativeInteger(String value); static boolean isValidPositiveInteger(String value); static boolean isValidLong(String value); static boolean isValidInt(String value); static boolean isValidShort(String value); static boolean isValidByte(String value); static boolean isValidUnsignedLong(String value); static boolean isValidUnsignedInt(String value); static boolean isValidUnsignedShort(String value); static boolean isValidUnsignedByte(String value); static boolean isValidFloat(String value); static boolean isValidDouble(String value); static boolean isValidBoolean(String value); static boolean isValidDuration(String value); static boolean isValidDayTimeDuration(String value); static boolean isValidYearMonthDuration(String value); static boolean isValidDateTime(String value); static boolean isValidDateTimeStamp(String value); static boolean isValidDate(String value); static boolean isValidTime(String value); static boolean isValidGDay(String value); static boolean isValidGMonth(String value); static boolean isValidGMonthDay(String value); static boolean isValidGYear(String value); static boolean isValidGYearMonth(String value); static boolean isValidQName(String value); static boolean isValidAnyURI(String value); static String normalize(String value, IRI datatype); static String normalizeBoolean(String value); static String normalizeDecimal(String decimal); static String normalizeInteger(String value); static String normalizeNegativeInteger(String value); static String normalizeNonPositiveInteger(String value); static String normalizeNonNegativeInteger(String value); static String normalizePositiveInteger(String value); static String normalizeLong(String value); static String normalizeInt(String value); static String normalizeShort(String value); static String normalizeByte(String value); static String normalizeUnsignedLong(String value); static String normalizeUnsignedInt(String value); static String normalizeUnsignedShort(String value); static String normalizeUnsignedByte(String value); static String normalizeFloat(String value); static String normalizeDouble(String value); static String normalizeFPNumber(String value); static String normalizeDateTime(String value); static String collapseWhiteSpace(String s); static int compare(String value1, String value2, IRI datatype); static int compareDecimals(String dec1, String dec2); static int compareCanonicalDecimals(String dec1, String dec2); static int compareIntegers(String int1, String int2); static int compareCanonicalIntegers(String int1, String int2); static int compareNegativeIntegers(String int1, String int2); static int compareNonPositiveIntegers(String int1, String int2); static int compareNonNegativeIntegers(String int1, String int2); static int comparePositiveIntegers(String int1, String int2); static int compareLongs(String int1, String int2); static int compareInts(String int1, String int2); static int compareShorts(String int1, String int2); static int compareBytes(String int1, String int2); static int compareUnsignedLongs(String int1, String int2); static int compareUnsignedInts(String int1, String int2); static int compareUnsignedShorts(String int1, String int2); static int compareUnsignedBytes(String int1, String int2); static int compareFloats(String float1, String float2); static int compareCanonicalFloats(String float1, String float2); static int compareDoubles(String double1, String double2); static int compareCanonicalDoubles(String double1, String double2); static int compareFPNumbers(String fp1, String fp2); static int compareCanonicalFPNumbers(String float1, String float2); static int compareDateTime(String value1, String value2); static boolean parseBoolean(String s); static byte parseByte(String s); static short parseShort(String s); static int parseInt(String s); static long parseLong(String s); static float parseFloat(String s); static double parseDouble(String s); static BigInteger parseInteger(String s); static BigDecimal parseDecimal(String s); static XMLGregorianCalendar parseCalendar(String s); static Duration parseDuration(String s); static IRI qnameToURI(QName qname); static String toString(Number value); static final String POSITIVE_INFINITY; static final String NEGATIVE_INFINITY; static final String NaN; }
@Test public void testIsValidValue() { testValidation(VALID_FLOATS, XSD.FLOAT, true); testValidation(INVALID_FLOATS, XSD.FLOAT, false); testValidation(VALID_DATES, XSD.DATE, true); testValidation(INVALID_DATES, XSD.DATE, false); testValidation(VALID_DATETIMESTAMPS, XSD.DATETIMESTAMP, true); testValidation(INVALID_DATETIMESTAMPS, XSD.DATETIMESTAMP, false); testValidation(VALID_TIMES, XSD.TIME, true); testValidation(INVALID_TIMES, XSD.TIME, false); testValidation(VALID_GDAY, XSD.GDAY, true); testValidation(INVALID_GDAY, XSD.GDAY, false); testValidation(VALID_GMONTH, XSD.GMONTH, true); testValidation(INVALID_GMONTH, XSD.GMONTH, false); testValidation(VALID_GMONTHDAY, XSD.GMONTHDAY, true); testValidation(INVALID_GMONTHDAY, XSD.GMONTHDAY, false); testValidation(VALID_GYEAR, XSD.GYEAR, true); testValidation(INVALID_GYEAR, XSD.GYEAR, false); testValidation(VALID_GYEARMONTH, XSD.GYEARMONTH, true); testValidation(INVALID_GYEARMONTH, XSD.GYEARMONTH, false); testValidation(VALID_DURATION, XSD.DURATION, true); testValidation(INVALID_DURATION, XSD.DURATION, false); testValidation(VALID_DAYTIMEDURATION, XSD.DAYTIMEDURATION, true); testValidation(INVALID_DAYTIMEDURATION, XSD.DAYTIMEDURATION, false); testValidation(VALID_QNAMES, XSD.QNAME, true); testValidation(INVALID_QNAMES, XSD.QNAME, false); testValidation(VALID_URI, XSD.ANYURI, true); testValidation(INVALID_URI, XSD.ANYURI, false); }