@Test(expected = IllegalArgumentException.class) public void testHex2CharArrayIllegalArgumentLength() { String line = "4130010A0"; StringUtil.hex2CharArray(line); }
public static char[] hex2CharArray(String hex) { if (hex == null) { return null; } int length = hex.length(); if ((1 & length) != 0) { throw new IllegalArgumentException("'" + hex + "' has odd length!"); } length /= 2; char[] result = new char[length]; for (int indexDest = 0, indexSrc = 0; indexDest < length; ++indexDest) { int digit = Character.digit(hex.charAt(indexSrc), 16); if (digit < 0) { throw new IllegalArgumentException("'" + hex + "' digit " + indexSrc + " is not hexadecimal!"); } result[indexDest] = (char) (digit << 4); ++indexSrc; digit = Character.digit(hex.charAt(indexSrc), 16); if (digit < 0) { throw new IllegalArgumentException("'" + hex + "' digit " + indexSrc + " is not hexadecimal!"); } result[indexDest] |= (char) digit; ++indexSrc; } return result; }
StringUtil { public static char[] hex2CharArray(String hex) { if (hex == null) { return null; } int length = hex.length(); if ((1 & length) != 0) { throw new IllegalArgumentException("'" + hex + "' has odd length!"); } length /= 2; char[] result = new char[length]; for (int indexDest = 0, indexSrc = 0; indexDest < length; ++indexDest) { int digit = Character.digit(hex.charAt(indexSrc), 16); if (digit < 0) { throw new IllegalArgumentException("'" + hex + "' digit " + indexSrc + " is not hexadecimal!"); } result[indexDest] = (char) (digit << 4); ++indexSrc; digit = Character.digit(hex.charAt(indexSrc), 16); if (digit < 0) { throw new IllegalArgumentException("'" + hex + "' digit " + indexSrc + " is not hexadecimal!"); } result[indexDest] |= (char) digit; ++indexSrc; } return result; } }
StringUtil { public static char[] hex2CharArray(String hex) { if (hex == null) { return null; } int length = hex.length(); if ((1 & length) != 0) { throw new IllegalArgumentException("'" + hex + "' has odd length!"); } length /= 2; char[] result = new char[length]; for (int indexDest = 0, indexSrc = 0; indexDest < length; ++indexDest) { int digit = Character.digit(hex.charAt(indexSrc), 16); if (digit < 0) { throw new IllegalArgumentException("'" + hex + "' digit " + indexSrc + " is not hexadecimal!"); } result[indexDest] = (char) (digit << 4); ++indexSrc; digit = Character.digit(hex.charAt(indexSrc), 16); if (digit < 0) { throw new IllegalArgumentException("'" + hex + "' digit " + indexSrc + " is not hexadecimal!"); } result[indexDest] |= (char) digit; ++indexSrc; } return result; }  }
StringUtil { public static char[] hex2CharArray(String hex) { if (hex == null) { return null; } int length = hex.length(); if ((1 & length) != 0) { throw new IllegalArgumentException("'" + hex + "' has odd length!"); } length /= 2; char[] result = new char[length]; for (int indexDest = 0, indexSrc = 0; indexDest < length; ++indexDest) { int digit = Character.digit(hex.charAt(indexSrc), 16); if (digit < 0) { throw new IllegalArgumentException("'" + hex + "' digit " + indexSrc + " is not hexadecimal!"); } result[indexDest] = (char) (digit << 4); ++indexSrc; digit = Character.digit(hex.charAt(indexSrc), 16); if (digit < 0) { throw new IllegalArgumentException("'" + hex + "' digit " + indexSrc + " is not hexadecimal!"); } result[indexDest] |= (char) digit; ++indexSrc; } return result; }  static String lineSeparator(); static char[] hex2CharArray(String hex); static String charArray2hex(char[] charArray); static byte[] hex2ByteArray(String hex); static String byteArray2Hex(byte[] byteArray); static String byteArray2HexString(byte[] byteArray); static String byteArray2HexString(byte[] byteArray, char sep, int max); static byte[] base64ToByteArray(String base64); static String byteArrayToBase64(byte[] bytes); static String trunc(String text, int maxLength); static String toString(InetAddress address); static String toString(InetSocketAddress address); static String toDisplayString(InetSocketAddress address); static boolean isValidHostName(final String name); static String getUriHostname(InetAddress address); static String normalizeLoggingTag(String tag); static String getConfiguration(String name); static Long getConfigurationLong(String name); static boolean getConfigurationBoolean(String name); }
StringUtil { public static char[] hex2CharArray(String hex) { if (hex == null) { return null; } int length = hex.length(); if ((1 & length) != 0) { throw new IllegalArgumentException("'" + hex + "' has odd length!"); } length /= 2; char[] result = new char[length]; for (int indexDest = 0, indexSrc = 0; indexDest < length; ++indexDest) { int digit = Character.digit(hex.charAt(indexSrc), 16); if (digit < 0) { throw new IllegalArgumentException("'" + hex + "' digit " + indexSrc + " is not hexadecimal!"); } result[indexDest] = (char) (digit << 4); ++indexSrc; digit = Character.digit(hex.charAt(indexSrc), 16); if (digit < 0) { throw new IllegalArgumentException("'" + hex + "' digit " + indexSrc + " is not hexadecimal!"); } result[indexDest] |= (char) digit; ++indexSrc; } return result; }  static String lineSeparator(); static char[] hex2CharArray(String hex); static String charArray2hex(char[] charArray); static byte[] hex2ByteArray(String hex); static String byteArray2Hex(byte[] byteArray); static String byteArray2HexString(byte[] byteArray); static String byteArray2HexString(byte[] byteArray, char sep, int max); static byte[] base64ToByteArray(String base64); static String byteArrayToBase64(byte[] bytes); static String trunc(String text, int maxLength); static String toString(InetAddress address); static String toString(InetSocketAddress address); static String toDisplayString(InetSocketAddress address); static boolean isValidHostName(final String name); static String getUriHostname(InetAddress address); static String normalizeLoggingTag(String tag); static String getConfiguration(String name); static Long getConfigurationLong(String name); static boolean getConfigurationBoolean(String name); static final char NO_SEPARATOR; static final String lineSeparator; static final boolean SUPPORT_HOST_STRING; static final String CALIFORNIUM_VERSION; }