/** * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return A String containing only Base-N character data */ public String encodeToString(final byte[] pArray) { return StringUtils.utf8(encode(pArray)); }
public static <E extends Exception> void notEmpty(Class<E> exceptionClass, String msg, String... values) throws E { if (values != null) { for (String value : values) { if (StringUtils.isEmpty(value)) { throwException(exceptionClass, msg); } } } }
/** * Tests a given String to see if it contains only valid characters within the Base64 alphabet. Currently the * method treats whitespace as valid. * * @param base64 String to test * @return {@code true} if all characters in the String are valid characters in the Base64 alphabet or if * the String is empty; {@code false}, otherwise * @since 1.5 */ public static boolean isBase64(final String base64) { return isBase64(StringUtils.utf8(base64)); }
/** * Encodes binary data using the base64 algorithm but does not chunk the output. * NOTE: We changed the behaviour of this method from multi-line chunking (commons-codec-1.4) to * single-line non-chunking (commons-codec-1.5). * * @param binaryData binary data to encode * @return String containing Base64 characters. * @since 1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not). */ public static String encodeBase64String(final byte[] binaryData) { return StringUtils.utf8(encodeBase64(binaryData, false)); }
/** * Return an absolute URL under the context path. * * @param path Path * @return absolute URL */ public static String getContextURL(String path) { return createContextURLBuilder().path(path).toString(); }
/** * Tests a given String to see if it contains only valid characters within the alphabet. * The method treats whitespace and PAD as valid. * * @param basen String to test * @return {@code true} if all characters in the String are valid characters in the alphabet or if * the String is empty; {@code false}, otherwise * @see #isInAlphabet(byte[], boolean) */ public boolean isInAlphabet(final String basen) { return isInAlphabet(StringUtils.utf8(basen), true); }
/** * Parse a UTC date in ISO format YYYY-MM-DD ( ie: 2014-12-30 ) * * @param date Date string * @return date * @throws java.text.ParseException if the string was invalid */ public static Date parseISOUTCDate(String date) throws ParseException { return dateFormatter.parseISOUTCDate(date); }
/** * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The * url-safe variation emits - and _ instead of + and / characters. * <b>Note: no padding is added.</b> * * @param binaryData binary data to encode * @return String containing Base64 characters * @since 1.4 */ public static String encodeBase64URLSafeString(final byte[] binaryData) { return StringUtils.utf8(encodeBase64(binaryData, false, true)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return String containing only character data in the appropriate alphabet. */ public String encodeAsString(final byte[] pArray) { return StringUtils.utf8(encode(pArray)); }
/** * Tests a given String to see if it contains only valid characters within the Base64 alphabet. Currently the * method treats whitespace as valid. * * @param base64 String to test * @return {@code true} if all characters in the String are valid characters in the Base64 alphabet or if * the String is empty; {@code false}, otherwise * @since 1.5 */ public static boolean isBase64(final String base64) { return isBase64(StringUtils.utf8(base64)); }
/** * Tests a given String to see if it contains only valid characters within the alphabet. * The method treats whitespace and PAD as valid. * * @param basen String to test * @return {@code true} if all characters in the String are valid characters in the alphabet or if * the String is empty; {@code false}, otherwise * @see #isInAlphabet(byte[], boolean) */ public boolean isInAlphabet(final String basen) { return isInAlphabet(StringUtils.utf8(basen), true); }
public static <E extends Exception> void notEmpty(Class<E> exceptionClass, String msg, String... values) throws E { if (values != null) { for (String value : values) { if (StringUtils.isEmpty(value)) { throwException(exceptionClass, msg); } } } }
/** * Encodes binary data using the base64 algorithm but does not chunk the output. * NOTE: We changed the behaviour of this method from multi-line chunking (commons-codec-1.4) to * single-line non-chunking (commons-codec-1.5). * * @param binaryData binary data to encode * @return String containing Base64 characters. * @since 1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not). */ public static String encodeBase64String(final byte[] binaryData) { return StringUtils.utf8(encodeBase64(binaryData, false)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return A String containing only Base-N character data */ public String encodeToString(final byte[] pArray) { return StringUtils.utf8(encode(pArray)); }
/** * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The * url-safe variation emits - and _ instead of + and / characters. * <b>Note: no padding is added.</b> * * @param binaryData binary data to encode * @return String containing Base64 characters * @since 1.4 */ public static String encodeBase64URLSafeString(final byte[] binaryData) { return StringUtils.utf8(encodeBase64(binaryData, false, true)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return String containing only character data in the appropriate alphabet. */ public String encodeAsString(final byte[] pArray) { return StringUtils.utf8(encode(pArray)); }