@Override protected AbstractSimpleType getSimpleTypeInstance() { return EdmBinary.getInstance(); }
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); }
@Override public boolean validate(final String value, final EdmLiteralKind literalKind, final EdmFacets facets) { if (value == null) { return facets == null || facets.isNullable() == null || facets.isNullable(); } if (literalKind == null) { return false; } return validateLiteral(value, literalKind) && validateMaxLength(value, literalKind, facets); }
@Override public boolean validate(final String value, final EdmLiteralKind literalKind, final EdmFacets facets) { if (value == null) { return facets == null || facets.isNullable() == null || facets.isNullable(); } if (literalKind == null) { return false; } return validateLiteral(value, literalKind) && validateMaxLength(value, literalKind, facets); }
return EdmBinary.getInstance(); case Boolean: return EdmBoolean.getInstance();
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; }
@Override public boolean validate(final String value, final EdmLiteralKind literalKind, final EdmFacets facets) { if (value == null) { return facets == null || facets.isNullable() == null || facets.isNullable(); } if (literalKind == null) { return false; } return validateLiteral(value, literalKind) && validateMaxLength(value, literalKind, facets); }
return EdmBinary.getInstance(); case Boolean: return EdmBoolean.getInstance();
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; }
@Override protected <T> T internalValueOfString(final String value, final EdmLiteralKind literalKind, final EdmFacets facets, final Class<T> returnType) throws EdmSimpleTypeException { if (!validateLiteral(value, literalKind)) { throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)); if (!validateMaxLength(value, literalKind, facets)) { throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_FACETS_NOT_MATCHED.addContent(value, facets));
return EdmBinary.getInstance(); case Boolean: return EdmBoolean.getInstance();
@Override protected <T> T internalValueOfString(final String value, final EdmLiteralKind literalKind, final EdmFacets facets, final Class<T> returnType) throws EdmSimpleTypeException { if (!validateLiteral(value, literalKind)) { throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)); if (!validateMaxLength(value, literalKind, facets)) { throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_FACETS_NOT_MATCHED.addContent(value, facets));
@Override protected <T> T internalValueOfString(final String value, final EdmLiteralKind literalKind, final EdmFacets facets, final Class<T> returnType) throws EdmSimpleTypeException { if (!validateLiteral(value, literalKind)) { throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)); if (!validateMaxLength(value, literalKind, facets)) { throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_FACETS_NOT_MATCHED.addContent(value, facets));