3838public class Hex implements BinaryEncoder , BinaryDecoder {
3939
4040 /**
41- * Default charset is {@link StandardCharsets#UTF_8}
41+ * Default charset is {@link StandardCharsets#UTF_8}.
4242 *
4343 * @since 1.7
4444 */
4545 public static final Charset DEFAULT_CHARSET = StandardCharsets .UTF_8 ;
4646
4747 /**
48- * Default charset name is {@link CharEncoding#UTF_8}
48+ * Default charset name is {@link CharEncoding#UTF_8}.
4949 *
5050 * @since 1.4
5151 */
5252 public static final String DEFAULT_CHARSET_NAME = CharEncoding .UTF_8 ;
5353
5454 /**
55- * Used to build output as Hex
55+ * Used to build output as hex.
5656 */
5757 private static final char [] DIGITS_LOWER = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' , 'b' , 'c' , 'd' ,
5858 'e' , 'f' };
5959
6060 /**
61- * Used to build output as Hex
61+ * Used to build output as hex.
6262 */
6363 private static final char [] DIGITS_UPPER = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'A' , 'B' , 'C' , 'D' ,
6464 'E' , 'F' };
@@ -70,7 +70,7 @@ public class Hex implements BinaryEncoder, BinaryDecoder {
7070 *
7171 * @param data An array of characters containing hexadecimal digits
7272 * @return A byte array containing binary data decoded from the supplied char array.
73- * @throws DecoderException Thrown if an odd number or illegal of characters is supplied
73+ * @throws DecoderException Thrown if an odd number of characters or illegal characters are supplied
7474 */
7575 public static byte [] decodeHex (final char [] data ) throws DecoderException {
7676 final byte [] out = new byte [data .length >> 1 ];
@@ -87,7 +87,7 @@ public static byte[] decodeHex(final char[] data) throws DecoderException {
8787 * @param out A byte array to contain the binary data decoded from the supplied char array.
8888 * @param outOffset The position within {@code out} to start writing the decoded bytes.
8989 * @return the number of bytes written to {@code out}.
90- * @throws DecoderException Thrown if an odd number or illegal of characters is supplied
90+ * @throws DecoderException Thrown if an odd number of characters or illegal characters are supplied
9191 *
9292 * @since 1.15
9393 */
@@ -100,7 +100,7 @@ public static int decodeHex(final char[] data, final byte[] out, final int outOf
100100
101101 final int outLen = len >> 1 ;
102102 if (out .length - outOffset < outLen ) {
103- throw new DecoderException ("out is not large enough to accommodate decoded data." );
103+ throw new DecoderException ("Output array is not large enough to accommodate decoded data." );
104104 }
105105
106106 // two characters form the hex value.
@@ -122,9 +122,9 @@ public static int decodeHex(final char[] data, final byte[] out, final int outOf
122122 *
123123 * @param data A String containing hexadecimal digits
124124 * @return A byte array containing binary data decoded from the supplied char array.
125- * @throws DecoderException Thrown if an odd number or illegal of characters is supplied
125+ * @throws DecoderException Thrown if an odd number of characters or illegal characters are supplied
126126 * @since 1.11
127- */
127+ */
128128 public static byte [] decodeHex (final String data ) throws DecoderException {
129129 return decodeHex (data .toCharArray ());
130130 }
@@ -134,7 +134,7 @@ public static byte[] decodeHex(final String data) throws DecoderException {
134134 * The returned array will be double the length of the passed array, as it takes two characters to represent any
135135 * given byte.
136136 *
137- * @param data a byte[] to convert to Hex characters
137+ * @param data a byte[] to convert to hex characters
138138 * @return A char[] containing lower-case hexadecimal characters
139139 */
140140 public static char [] encodeHex (final byte [] data ) {
@@ -160,7 +160,7 @@ public static char[] encodeHex(final byte[] data, final boolean toLowerCase) {
160160 * The returned array will be double the length of the passed array, as it takes two characters to represent any
161161 * given byte.
162162 *
163- * @param data a byte[] to convert to Hex characters
163+ * @param data a byte[] to convert to hex characters
164164 * @param toDigits the output alphabet (must contain at least 16 chars)
165165 * @return A char[] containing the appropriate characters from the alphabet For best results, this should be either
166166 * upper- or lower-case hex.
@@ -176,7 +176,7 @@ protected static char[] encodeHex(final byte[] data, final char[] toDigits) {
176176 /**
177177 * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
178178 *
179- * @param data a byte[] to convert to Hex characters
179+ * @param data a byte[] to convert to hex characters
180180 * @param dataOffset the position in {@code data} to start encoding from
181181 * @param dataLen the number of bytes from {@code dataOffset} to encode
182182 * @param toLowerCase {@code true} converts to lowercase, {@code false} to uppercase
@@ -194,7 +194,7 @@ public static char[] encodeHex(final byte[] data, final int dataOffset, final in
194194 /**
195195 * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
196196 *
197- * @param data a byte[] to convert to Hex characters
197+ * @param data a byte[] to convert to hex characters
198198 * @param dataOffset the position in {@code data} to start encoding from
199199 * @param dataLen the number of bytes from {@code dataOffset} to encode
200200 * @param toLowerCase {@code true} converts to lowercase, {@code false} to uppercase
@@ -210,7 +210,7 @@ public static void encodeHex(final byte[] data, final int dataOffset, final int
210210 /**
211211 * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
212212 *
213- * @param data a byte[] to convert to Hex characters
213+ * @param data a byte[] to convert to hex characters
214214 * @param dataOffset the position in {@code data} to start encoding from
215215 * @param dataLen the number of bytes from {@code dataOffset} to encode
216216 * @param toDigits the output alphabet (must contain at least 16 chars)
@@ -235,7 +235,7 @@ protected static void encodeHex(final byte[] data, final int dataOffset, final i
235235 * <p>All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method
236236 * the value {@link ByteBuffer#remaining() remaining()} will be zero.</p>
237237 *
238- * @param data a byte buffer to convert to Hex characters
238+ * @param data a byte buffer to convert to hex characters
239239 * @return A char[] containing lower-case hexadecimal characters
240240 * @since 1.11
241241 */
@@ -251,7 +251,7 @@ public static char[] encodeHex(final ByteBuffer data) {
251251 * <p>All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method
252252 * the value {@link ByteBuffer#remaining() remaining()} will be zero.</p>
253253 *
254- * @param data a byte buffer to convert to Hex characters
254+ * @param data a byte buffer to convert to hex characters
255255 * @param toLowerCase {@code true} converts to lowercase, {@code false} to uppercase
256256 * @return A char[] containing hexadecimal characters in the selected case
257257 * @since 1.11
@@ -268,7 +268,7 @@ public static char[] encodeHex(final ByteBuffer data, final boolean toLowerCase)
268268 * <p>All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method
269269 * the value {@link ByteBuffer#remaining() remaining()} will be zero.</p>
270270 *
271- * @param byteBuffer a byte buffer to convert to Hex characters
271+ * @param byteBuffer a byte buffer to convert to hex characters
272272 * @param toDigits the output alphabet (must be at least 16 characters)
273273 * @return A char[] containing the appropriate characters from the alphabet For best results, this should be either
274274 * upper- or lower-case hex.
@@ -282,7 +282,7 @@ protected static char[] encodeHex(final ByteBuffer byteBuffer, final char[] toDi
282282 * Converts an array of bytes into a String representing the hexadecimal values of each byte in order. The returned
283283 * String will be double the length of the passed array, as it takes two characters to represent any given byte.
284284 *
285- * @param data a byte[] to convert to Hex characters
285+ * @param data a byte[] to convert to hex characters
286286 * @return A String containing lower-case hexadecimal characters
287287 * @since 1.4
288288 */
@@ -294,7 +294,7 @@ public static String encodeHexString(final byte[] data) {
294294 * Converts an array of bytes into a String representing the hexadecimal values of each byte in order. The returned
295295 * String will be double the length of the passed array, as it takes two characters to represent any given byte.
296296 *
297- * @param data a byte[] to convert to Hex characters
297+ * @param data a byte[] to convert to hex characters
298298 * @param toLowerCase {@code true} converts to lowercase, {@code false} to uppercase
299299 * @return A String containing lower-case hexadecimal characters
300300 * @since 1.11
@@ -310,7 +310,7 @@ public static String encodeHexString(final byte[] data, final boolean toLowerCas
310310 * <p>All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method
311311 * the value {@link ByteBuffer#remaining() remaining()} will be zero.</p>
312312 *
313- * @param data a byte buffer to convert to Hex characters
313+ * @param data a byte buffer to convert to hex characters
314314 * @return A String containing lower-case hexadecimal characters
315315 * @since 1.11
316316 */
@@ -325,7 +325,7 @@ public static String encodeHexString(final ByteBuffer data) {
325325 * <p>All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method
326326 * the value {@link ByteBuffer#remaining() remaining()} will be zero.</p>
327327 *
328- * @param data a byte buffer to convert to Hex characters
328+ * @param data a byte buffer to convert to hex characters
329329 * @param toLowerCase {@code true} converts to lowercase, {@code false} to uppercase
330330 * @return A String containing lower-case hexadecimal characters
331331 * @since 1.11
@@ -475,7 +475,7 @@ public Object decode(final Object object) throws DecoderException {
475475 * {@link #getCharset()}.
476476 * </p>
477477 *
478- * @param array a byte[] to convert to Hex characters
478+ * @param array a byte[] to convert to hex characters
479479 * @return A byte[] containing the bytes of the lower-case hexadecimal characters
480480 * @since 1.7 No longer throws IllegalStateException if the charsetName is invalid.
481481 * @see #encodeHex(byte[])
@@ -496,7 +496,7 @@ public byte[] encode(final byte[] array) {
496496 * <p>All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method
497497 * the value {@link ByteBuffer#remaining() remaining()} will be zero.</p>
498498 *
499- * @param array a byte buffer to convert to Hex characters
499+ * @param array a byte buffer to convert to hex characters
500500 * @return A byte[] containing the bytes of the lower-case hexadecimal characters
501501 * @see #encodeHex(byte[])
502502 * @since 1.11
@@ -514,7 +514,7 @@ public byte[] encode(final ByteBuffer array) {
514514 * {@link #getCharset()}.
515515 * </p>
516516 *
517- * @param object a String, ByteBuffer, or byte[] to convert to Hex characters
517+ * @param object a String, ByteBuffer, or byte[] to convert to hex characters
518518 * @return A char[] containing lower-case hexadecimal characters
519519 * @throws EncoderException Thrown if the given object is not a String or byte[]
520520 * @see #encodeHex(byte[])
0 commit comments