AsciiString implements CharSequence, AsciiStringable, Comparable<CharSequence> { public static AsciiString integerToHexStringWithoutPrefix(final int number) { if (number <= 0) { return HEX_ZERO; } synchronized (cachedStringsLock) { final CacheEntry cacheEntry = cachedStrings[number & 0x7F]; if (cacheEntry != null && cacheEntry.tag == (number & 0x7FFFFF80)) { return cacheEntry.cachedString; } } final int leadingZeros = Integer.numberOfLeadingZeros(number) >>> 2; final byte[] chars = new byte[8 - leadingZeros]; for (int i = leadingZeros; i < 8; i++) { chars[7 - i] = (byte) charactersLower[(number >>> ((i - leadingZeros) << 2)) & 0xF]; } final AsciiString asciiString = of(chars); final CacheEntry cacheEntry = new CacheEntry(number & 0x7FFFFF80, asciiString); synchronized (cachedStringsLock) { cachedStrings[number & 0x7F] = cacheEntry; } return asciiString; } 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 integerToHexStringWithoutPrefix() { assertEquals(Integer.toHexString(0x7FFFFFFF), AsciiString.integerToHexStringWithoutPrefix(Integer.MAX_VALUE).toString()); assertEquals(Integer.toHexString(0x0), AsciiString.integerToHexStringWithoutPrefix(0).toString()); for (int i = 0; i < 4; i++) { assertEquals(Integer.toHexString(7863), AsciiString.integerToHexStringWithoutPrefix(7863).toString()); assertEquals(Integer.toHexString(7863), AsciiString.integerToHexStringWithoutPrefix(7863).toString()); assertEquals(Integer.toHexString(7863), AsciiString.integerToHexStringWithoutPrefix(7863).toString()); assertEquals(Integer.toHexString(7863), AsciiString.integerToHexStringWithoutPrefix(7863).toString()); } assertEquals(Integer.toHexString(0x15), AsciiString.integerToHexStringWithoutPrefix(0x15).toString()); assertEquals(Integer.toHexString(0x16), AsciiString.integerToHexStringWithoutPrefix(0x16).toString()); }