29import java.nio.ByteBuffer;
30import java.util.Locale;
36 "00000000000000000000000000000001",
37 "00000000000000000000000000000010",
38 "00000000000000000000000000000100",
39 "00000000000000000000000000001000",
40 "00000000000000000000000000010000",
41 "00000000000000000000000000100000",
42 "00000000000000000000000001000000",
43 "00000000000000000000000010000000",
44 "00000000000000000000000100000000",
45 "00000000000000000000001000000000",
46 "00000000000000000000010000000000",
47 "00000000000000000000100000000000",
48 "00000000000000000001000000000000",
49 "00000000000000000010000000000000",
50 "00000000000000000100000000000000",
51 "00000000000000001000000000000000",
52 "00000000000000010000000000000000",
53 "00000000000000100000000000000000",
54 "00000000000001000000000000000000",
55 "00000000000010000000000000000000",
56 "00000000000100000000000000000000",
57 "00000000001000000000000000000000",
58 "00000000010000000000000000000000",
59 "00000000100000000000000000000000",
60 "00000001000000000000000000000000",
61 "00000010000000000000000000000000",
62 "00000100000000000000000000000000",
63 "00001000000000000000000000000000",
64 "00010000000000000000000000000000",
65 "00100000000000000000000000000000",
66 "01000000000000000000000000000000",
67 "10000000000000000000000000000000"
73 public static final byte[]
testBytesMSB =
new byte[] { (byte)0xde, (
byte)0xaf, (byte)0xca, (
byte)0xfe };
75 public static final String[]
testStringsMSB =
new String[] {
"11011110",
"10101111",
"11001010",
"11111110" };
81 public static final byte[]
testBytesMSB_rev =
new byte[] { (byte)0xfe, (
byte)0xca, (byte)0xaf, (
byte)0xde };
83 public static final String[]
testStringsMSB_rev =
new String[] {
"11111110",
"11001010",
"10101111",
"11011110" };
89 public static final byte[]
testBytesLSB =
new byte[] { (byte)0x7f, (
byte)0x53, (byte)0xf5, (
byte)0x7b };
91 public static final String[]
testStringsLSB =
new String[] {
"01111111",
"01010011",
"11110101",
"01111011" };
97 public static final byte[]
testBytesLSB_revByte =
new byte[] { (byte)0x7b, (
byte)0xf5, (byte)0x53, (
byte)0x7f };
99 public static final String[]
testStringsLSB_revByte =
new String[] {
"01111011",
"11110101",
"01010011",
"01111111" };
102 public static final void dumpData(
final String prefix,
final byte[] data,
final int offset,
final int len) {
103 for(
int i=0; i<len; ) {
104 System.err.printf(
"%s: %03d: ", prefix, i);
105 for(
int j=0; j<8 && i<len; j++, i++) {
106 final int v = 0xFF & data[offset+i];
109 System.err.println(
"");
112 public static final void dumpData(
final String prefix,
final ByteBuffer data,
final int offset,
final int len) {
113 for(
int i=0; i<len; ) {
114 System.err.printf(
"%s: %03d: ", prefix, i);
115 for(
int j=0; j<8 && i<len; j++, i++) {
116 final int v = 0xFF & data.get(offset+i);
119 System.err.println(
"");
125 for(
int i=0; i<pattern.length(); i++) {
126 if(
'1' == pattern.charAt(i) ) {
132 public static long toLong(
final String bitPattern) {
133 return Long.valueOf(bitPattern, 2).longValue();
136 final long res = Long.valueOf(bitPattern, 2).longValue();
144 return "0x"+Integer.toHexString(v);
147 return "0x"+Long.toHexString(v);
149 public static final String
strZeroPadding=
"0000000000000000000000000000000000000000000000000000000000000000";
151 if( 0 == bitCount ) {
154 final int mask = (int) ( ( 1L << bitCount ) - 1L );
155 final String s0 = Integer.toBinaryString( mask & v );
159 if( 0 == bitCount ) {
162 final long mask = ( 1L << bitCount ) - 1L;
163 final String s0 = Long.toBinaryString( mask & v );
167 final int nibbles = 0 == bitCount ? 2 : ( bitCount + 3 ) / 4;
168 return String.format((Locale)
null,
"[%0"+nibbles+
"X, %s]", v,
toBinaryString(v, bitCount));
171 final int nibbles = 0 == bitCount ? 2 : ( bitCount + 3 ) / 4;
172 return String.format((Locale)
null,
"[%0"+nibbles+
"X, %s]", v,
toBinaryString(v, bitCount));
175 final int nibbles = 0 == bitCount ? 2 : ( bitCount + 3 ) / 4;
176 return String.format((Locale)
null,
"[%0"+nibbles+
"X, %s]", v,
toBinaryString(v, bitCount));
static final String strZeroPadding
static int getOneBitCount(final String pattern)
static String toHexBinaryString(final short v, final int bitCount)
static final String testStringMSB_rev
static String toHexString(final long v)
static final void dumpData(final String prefix, final byte[] data, final int offset, final int len)
static final int testIntMSB_rev
static final long UNSIGNED_INT_MAX_VALUE
static final String[] testStringsLSB_revByte
static String toBinaryString(final long v, final int bitCount)
static final String[] pyramid32bit_one
static final String[] testStringsMSB
static String toBinaryString(final int v, final int bitCount)
static String toHexString(final int v)
static String toHexBinaryString(final int v, final int bitCount)
static long toLong(final String bitPattern)
static final String[] testStringsMSB_rev
static final int testIntMSB
static final byte[] testBytesLSB
static final byte[] testBytesLSB_revByte
static final String testStringLSB
static final byte[] testBytesMSB_rev
static String toHexBinaryString(final long v, final int bitCount)
static final int testIntLSB_revByte
static final void dumpData(final String prefix, final ByteBuffer data, final int offset, final int len)
static final String[] testStringsLSB
static final byte[] testBytesMSB
static final String testStringLSB_revByte
static int toInteger(final String bitPattern)
static final String testStringMSB
static final int testIntLSB