StringUtil { public static int getByteLength(String value, String encoding) throws UnsupportedEncodingException { if (value == null || "".equals(value)) { return 0; } byte[] bytes = null; if (encoding == null || "".equals(encoding)) { bytes = value.getBytes(); } else { try { bytes = value.getBytes(encoding); } catch (UnsupportedEncodingException e) { throw e; } } return bytes == null ? 0 : bytes.length; }  static boolean isWhitespace(char c); static boolean isZenHankakuSpace(char c); static String rtrim(String str); static String ltrim(String str); static String trim(String str); static String rtrimZ(String str); static String ltrimZ(String str); static String trimZ(String str); static String toShortClassName(String longClassName); static String getExtension(String name); static String toHexString(byte[] byteArray, String delim); static String capitalizeInitial(String str); static String[] parseCSV(String csvString); static String[] parseCSV(String csvString, String escapeString); static String dump(Map<?, ?> map); static String getArraysStr(Object[] arrayObj); static String hankakuToZenkaku(String value); static String zenkakuToHankaku(String value); static String filter(String str); static String toLikeCondition(String condition); static int getByteLength(String value, String encoding); static final String LINE_SEP; static final String LIKE_ESC_CHAR; }
@Test public void testGetByteLength01() throws Exception { String value = null; String encoding = null; int i = StringUtil.getByteLength(value, encoding); assertEquals(0, i); }
@Test public void testGetByteLength02() throws Exception { String value = ""; String encoding = null; int i = StringUtil.getByteLength(value, encoding); assertEquals(0, i); }
@Test public void testGetByteLength03() throws Exception { String value = "aaa"; String encoding = null; int i = StringUtil.getByteLength(value, encoding); assertEquals(3, i); }
@Test public void testGetByteLength04() throws Exception { String value = "aaa"; String encoding = ""; int i = StringUtil.getByteLength(value, encoding); assertEquals(3, i); }
@Test public void testGetByteLength05() throws Exception { String value = "あああ"; String encoding = "UTF-8"; int i = StringUtil.getByteLength(value, encoding); assertEquals(9, i); }
@Test public void testGetByteLength06() throws Exception { String value = "aaa"; String encoding = "aaa"; try { StringUtil.getByteLength(value, encoding); fail(); } catch (UnsupportedEncodingException e) { return; } }