private static boolean validateMaxLength(final String value, final EdmLiteralKind literalKind, final EdmFacets facets) { return facets == null || facets.getMaxLength() == null ? true : literalKind == EdmLiteralKind.URI ? // In URI representation, each byte is represented as two hexadecimal digits; // additionally, we have to account for the prefix and the surrounding "'"s. facets.getMaxLength() >= (value.length() - (value.startsWith("X") ? 3 : 8)) / 2 : // In default representation, every three bytes are represented as four base-64 characters. // Additionally, there could be up to two padding "=" characters if the number of bytes is // not a multiple of three, and there could be carriage return/line feed combinations. facets.getMaxLength() >= value.length() * 3 / 4 - (value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0) - crlfLength(value); }
private static boolean validateMaxLength(final String value, final EdmLiteralKind literalKind, final EdmFacets facets) { return facets == null || facets.getMaxLength() == null ? true : literalKind == EdmLiteralKind.URI ? // In URI representation, each byte is represented as two hexadecimal digits; // additionally, we have to account for the prefix and the surrounding "'"s. facets.getMaxLength() >= (value.length() - (value.startsWith("X") ? 3 : 8)) / 2 : // In default representation, every three bytes are represented as four base-64 characters. // Additionally, there could be up to two padding "=" characters if the number of bytes is // not a multiple of three, and there could be line feeds, possibly with carriage returns. facets.getMaxLength() * 4L >= (value.length() - crlfLength(value)) * 3L - (value.contains("==") ? 2 : value.contains("=") ? 1 : 0) * 4L; }
private static boolean validateMaxLength(final String value, final EdmLiteralKind literalKind, final EdmFacets facets) { return facets == null || facets.getMaxLength() == null ? true : literalKind == EdmLiteralKind.URI ? // In URI representation, each byte is represented as two hexadecimal digits; // additionally, we have to account for the prefix and the surrounding "'"s. facets.getMaxLength() >= (value.length() - (value.startsWith("X") ? 3 : 8)) / 2 : // In default representation, every three bytes are represented as four base-64 characters. // Additionally, there could be up to two padding "=" characters if the number of bytes is // not a multiple of three, and there could be line feeds, possibly with carriage returns. facets.getMaxLength() * 4L >= (value.length() - crlfLength(value)) * 3L - (value.contains("==") ? 2 : value.contains("=") ? 1 : 0) * 4L; }