StringEscaper { @Pure public static String formatHex(int amount, int digits) { final StringBuffer hex = new StringBuffer(Integer.toHexString(amount)); while (hex.length() < digits) { hex.insert(0, "0"); } return hex.toString(); } StringEscaper();  StringEscaper(CharSequence toEscapeCharacter, CharSequence... escapeCharacters); void setSpecialChars(String[][] chars); void setValidCharRange(int minValidChar, int maxValidChar); @SuppressWarnings("checkstyle:magicnumber") String escape(CharSequence text); @Pure static String formatHex(int amount, int digits); static final String[][] JAVA_SPECIAL_CHARS; static final String JAVA_ESCAPE_CHAR; static final String JAVA_STRING_CHAR; static final String JSON_SPECIAL_ESCAPED_CHAR; static final int JAVA_MIN_CHAR; static final int JAVA_MAX_CHAR; }
@Test public void formatHex_01() { assertEquals("4f", StringEscaper.formatHex(0x4F, 1)); }
@Test public void formatHex_02() { assertEquals("4f", StringEscaper.formatHex(0x4F, 2)); }
@Test public void formatHex_03() { assertEquals("04f", StringEscaper.formatHex(0x4F, 3)); }
@Test public void formatHex_04() { assertEquals("004f", StringEscaper.formatHex(0x4F, 4)); }