AsciiString implements CharSequence, AsciiStringable, Comparable<CharSequence> { public static AsciiString integerToHexString(final int number) { if (number <= 0) { return HEX_ZERO_PREFIXED; } final int leadingZeros = Integer.numberOfLeadingZeros(number) >>> 2; final byte[] chars = new byte[10 - leadingZeros]; chars[0] = '0'; chars[1] = 'x'; for (int i = leadingZeros; i < 8; i++) { chars[9 - i] = (byte) charactersUpper[(number >>> ((i - leadingZeros) << 2)) & 0xF]; } return of(chars); } private  AsciiString(final String value); private  AsciiString(final byte[] bytes); static AsciiString randomUUIDAsciiString(); static AsciiString integerToHexString(final int number); static AsciiString integerToHexStringWithoutPrefix(final int number); static AsciiString of(final String string); static AsciiString of(final Number number); static AsciiString of(final String string, final boolean cache); static AsciiString of(final byte[] string); boolean isEmpty(); byte[] getValue(); @Override int length(); @Override char charAt(final int i); @Override CharSequence subSequence(final int i, final int i1); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object object); boolean contains(final CharSequence other); boolean equals(final AsciiString other); @SuppressWarnings("ALL") boolean equalsIgnoreCase(final CharSequence other); boolean endsWith(final String string); AsciiString toLowerCase(); AsciiString toUpperCase(); @Override AsciiString toAsciiString(); int toInteger(); boolean isInteger(); long toLong(); @Override int compareTo(final CharSequence sequence); List<AsciiString> split(final String delimiter); boolean startsWith(final AsciiString part); boolean startsWith(final String part); static final AsciiString empty; }
@Test void integerToHexString() { assertEquals(AsciiString.of("0x7FFFFFFF"), AsciiString.integerToHexString(Integer.MAX_VALUE)); assertEquals(AsciiString.of("0x0"), AsciiString.integerToHexString(0)); assertEquals(AsciiString.of("0x1EB7"), AsciiString.integerToHexString(7863)); }