@@ -68,12 +68,7 @@ public class Base16 extends BaseNCodec {
6868 * This array is a lookup table that translates 4-bit positive integer index values into their "Base16 Alphabet" equivalents as specified in Table 5 of RFC
6969 * 4648.
7070 */
71- // @formatter:off
72- private static final byte [] UPPER_CASE_ENCODE_TABLE = {
73- '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' ,
74- 'A' , 'B' , 'C' , 'D' , 'E' , 'F'
75- };
76- // @formatter:on
71+ private static final byte [] UPPER_CASE_ENCODE_TABLE = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' };
7772
7873 /**
7974 * This array is a lookup table that translates Unicode characters drawn from the a lower-case "Base16 Alphabet" into their 4-bit positive integer
@@ -95,12 +90,7 @@ public class Base16 extends BaseNCodec {
9590 /**
9691 * This array is a lookup table that translates 4-bit positive integer index values into their "Base16 Alphabet" lower-case equivalents.
9792 */
98- // @formatter:off
99- private static final byte [] LOWER_CASE_ENCODE_TABLE = {
100- '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' ,
101- 'a' , 'b' , 'c' , 'd' , 'e' , 'f'
102- };
103- // @formatter:on
93+ private static final byte [] LOWER_CASE_ENCODE_TABLE = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' };
10494
10595 /** Mask used to extract 4 bits, used when decoding character. */
10696 private static final int MASK_4BITS = 0x0f ;
@@ -164,42 +154,33 @@ void decode(final byte[] data, int offset, final int length, final Context conte
164154 }
165155 return ;
166156 }
167-
168157 final int dataLen = Math .min (data .length - offset , length );
169158 final int availableChars = (context .ibitWorkArea != 0 ? 1 : 0 ) + dataLen ;
170-
171159 // small optimization to short-cut the rest of this method when it is fed byte-by-byte
172160 if (availableChars == 1 && availableChars == dataLen ) {
173161 // store 1/2 byte for next invocation of decode, we offset by +1 as empty-value is 0
174162 context .ibitWorkArea = decodeOctet (data [offset ]) + 1 ;
175163 return ;
176164 }
177-
178165 // we must have an even number of chars to decode
179166 final int charsToProcess = availableChars % BYTES_PER_ENCODED_BLOCK == 0 ? availableChars : availableChars - 1 ;
180167 final int end = offset + dataLen ;
181-
182168 final byte [] buffer = ensureBufferSize (charsToProcess / BYTES_PER_ENCODED_BLOCK , context );
183-
184169 int result ;
185170 if (dataLen < availableChars ) {
186171 // we have 1/2 byte from previous invocation to decode
187172 result = context .ibitWorkArea - 1 << BITS_PER_ENCODED_BYTE ;
188173 result |= decodeOctet (data [offset ++]);
189-
190174 buffer [context .pos ++] = (byte ) result ;
191-
192175 // reset to empty-value for next invocation!
193176 context .ibitWorkArea = 0 ;
194177 }
195-
196178 final int loopEnd = end - 1 ;
197179 while (offset < loopEnd ) {
198180 result = decodeOctet (data [offset ++]) << BITS_PER_ENCODED_BYTE ;
199181 result |= decodeOctet (data [offset ++]);
200182 buffer [context .pos ++] = (byte ) result ;
201183 }
202-
203184 // we have one char of a hex-pair left over
204185 if (offset < end ) {
205186 // store 1/2 byte for next invocation of decode, we offset by +1 as empty-value is 0
@@ -212,11 +193,9 @@ private int decodeOctet(final byte octet) {
212193 if ((octet & 0xff ) < decodeTable .length ) {
213194 decoded = decodeTable [octet ];
214195 }
215-
216196 if (decoded == -1 ) {
217197 throw new IllegalArgumentException ("Invalid octet in encoded value: " + (int ) octet );
218198 }
219-
220199 return decoded ;
221200 }
222201
@@ -225,19 +204,15 @@ void encode(final byte[] data, final int offset, final int length, final Context
225204 if (context .eof ) {
226205 return ;
227206 }
228-
229207 if (length < 0 ) {
230208 context .eof = true ;
231209 return ;
232210 }
233-
234211 final int size = length * BYTES_PER_ENCODED_BLOCK ;
235212 if (size < 0 ) {
236213 throw new IllegalArgumentException ("Input length exceeds maximum size for encoded data: " + length );
237214 }
238-
239215 final byte [] buffer = ensureBufferSize (size , context );
240-
241216 final int end = offset + length ;
242217 for (int i = offset ; i < end ; i ++) {
243218 final int value = data [i ];
0 commit comments