Format to 120 line length.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1606081 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2014-06-27 13:03:13 +00:00
parent cf832560dd
commit 7b33ab10de
1 changed files with 109 additions and 130 deletions

View File

@ -156,9 +156,7 @@ public class Conversion {
case 'F': case 'F':
return 0xF; return 0xF;
default: default:
throw new IllegalArgumentException("Cannot interpret '" throw new IllegalArgumentException("Cannot interpret '" + hexDigit + "' as a hexadecimal digit");
+ hexDigit
+ "' as a hexadecimal digit");
} }
} }
@ -216,9 +214,7 @@ public class Conversion {
case 'F': case 'F':
return TTTT; return TTTT;
default: default:
throw new IllegalArgumentException("Cannot interpret '" throw new IllegalArgumentException("Cannot interpret '" + hexDigit + "' as a hexadecimal digit");
+ hexDigit
+ "' as a hexadecimal digit");
} }
} }
@ -276,9 +272,7 @@ public class Conversion {
case 'F': case 'F':
return TTTT; return TTTT;
default: default:
throw new IllegalArgumentException("Cannot interpret '" throw new IllegalArgumentException("Cannot interpret '" + hexDigit + "' as a hexadecimal digit");
+ hexDigit
+ "' as a hexadecimal digit");
} }
} }
@ -579,13 +573,13 @@ public class Conversion {
* @throws NullPointerException if {@code src} is {@code null} * @throws NullPointerException if {@code src} is {@code null}
* @throws ArrayIndexOutOfBoundsException if {@code srcPos + nInts > src.length} * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nInts > src.length}
*/ */
public static long intArrayToLong(final int[] src, final int srcPos, final long dstInit, final int dstPos, final int nInts) { public static long intArrayToLong(final int[] src, final int srcPos, final long dstInit, final int dstPos,
final int nInts) {
if ((src.length == 0 && srcPos == 0) || 0 == nInts) { if ((src.length == 0 && srcPos == 0) || 0 == nInts) {
return dstInit; return dstInit;
} }
if ((nInts - 1) * 32 + dstPos >= 64) { if ((nInts - 1) * 32 + dstPos >= 64) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nInts-1)*32+dstPos is greather or equal to than 64");
"(nInts-1)*32+dstPos is greather or equal to than 64");
} }
long out = dstInit; long out = dstInit;
int shift = 0; int shift = 0;
@ -621,8 +615,7 @@ public class Conversion {
return dstInit; return dstInit;
} }
if ((nShorts - 1) * 16 + dstPos >= 64) { if ((nShorts - 1) * 16 + dstPos >= 64) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nShorts-1)*16+dstPos is greather or equal to than 64");
"(nShorts-1)*16+dstPos is greather or equal to than 64");
} }
long out = dstInit; long out = dstInit;
int shift = 0; int shift = 0;
@ -658,8 +651,7 @@ public class Conversion {
return dstInit; return dstInit;
} }
if ((nShorts - 1) * 16 + dstPos >= 32) { if ((nShorts - 1) * 16 + dstPos >= 32) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nShorts-1)*16+dstPos is greather or equal to than 32");
"(nShorts-1)*16+dstPos is greather or equal to than 32");
} }
int out = dstInit; int out = dstInit;
int shift = 0; int shift = 0;
@ -695,8 +687,7 @@ public class Conversion {
return dstInit; return dstInit;
} }
if ((nBytes - 1) * 8 + dstPos >= 64) { if ((nBytes - 1) * 8 + dstPos >= 64) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nBytes-1)*8+dstPos is greather or equal to than 64");
"(nBytes-1)*8+dstPos is greather or equal to than 64");
} }
long out = dstInit; long out = dstInit;
int shift = 0; int shift = 0;
@ -726,13 +717,13 @@ public class Conversion {
* @throws IllegalArgumentException if {@code (nBytes-1)*8+dstPos >= 32} * @throws IllegalArgumentException if {@code (nBytes-1)*8+dstPos >= 32}
* @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBytes > src.length} * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBytes > src.length}
*/ */
public static int byteArrayToInt(final byte[] src, final int srcPos, final int dstInit, final int dstPos, final int nBytes) { public static int byteArrayToInt(final byte[] src, final int srcPos, final int dstInit, final int dstPos,
final int nBytes) {
if ((src.length == 0 && srcPos == 0) || 0 == nBytes) { if ((src.length == 0 && srcPos == 0) || 0 == nBytes) {
return dstInit; return dstInit;
} }
if ((nBytes - 1) * 8 + dstPos >= 32) { if ((nBytes - 1) * 8 + dstPos >= 32) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nBytes-1)*8+dstPos is greather or equal to than 32");
"(nBytes-1)*8+dstPos is greather or equal to than 32");
} }
int out = dstInit; int out = dstInit;
int shift = 0; int shift = 0;
@ -768,8 +759,7 @@ public class Conversion {
return dstInit; return dstInit;
} }
if ((nBytes - 1) * 8 + dstPos >= 16) { if ((nBytes - 1) * 8 + dstPos >= 16) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nBytes-1)*8+dstPos is greather or equal to than 16");
"(nBytes-1)*8+dstPos is greather or equal to than 16");
} }
short out = dstInit; short out = dstInit;
int shift = 0; int shift = 0;
@ -797,13 +787,13 @@ public class Conversion {
* @return a long containing the selected bits * @return a long containing the selected bits
* @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 64} * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 64}
*/ */
public static long hexToLong(final String src, final int srcPos, final long dstInit, final int dstPos, final int nHex) { public static long hexToLong(final String src, final int srcPos, final long dstInit, final int dstPos,
final int nHex) {
if (0 == nHex) { if (0 == nHex) {
return dstInit; return dstInit;
} }
if ((nHex - 1) * 4 + dstPos >= 64) { if ((nHex - 1) * 4 + dstPos >= 64) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greather or equal to than 64");
"(nHexs-1)*4+dstPos is greather or equal to than 64");
} }
long out = dstInit; long out = dstInit;
int shift = 0; int shift = 0;
@ -836,8 +826,7 @@ public class Conversion {
return dstInit; return dstInit;
} }
if ((nHex - 1) * 4 + dstPos >= 32) { if ((nHex - 1) * 4 + dstPos >= 32) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greather or equal to than 32");
"(nHexs-1)*4+dstPos is greather or equal to than 32");
} }
int out = dstInit; int out = dstInit;
int shift = 0; int shift = 0;
@ -865,13 +854,13 @@ public class Conversion {
* @return a short containing the selected bits * @return a short containing the selected bits
* @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 16} * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 16}
*/ */
public static short hexToShort(final String src, final int srcPos, final short dstInit, final int dstPos, final int nHex) { public static short hexToShort(final String src, final int srcPos, final short dstInit, final int dstPos,
final int nHex) {
if (0 == nHex) { if (0 == nHex) {
return dstInit; return dstInit;
} }
if ((nHex - 1) * 4 + dstPos >= 16) { if ((nHex - 1) * 4 + dstPos >= 16) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greather or equal to than 16");
"(nHexs-1)*4+dstPos is greather or equal to than 16");
} }
short out = dstInit; short out = dstInit;
int shift = 0; int shift = 0;
@ -899,13 +888,13 @@ public class Conversion {
* @return a byte containing the selected bits * @return a byte containing the selected bits
* @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 8} * @throws IllegalArgumentException if {@code (nHexs-1)*4+dstPos >= 8}
*/ */
public static byte hexToByte(final String src, final int srcPos, final byte dstInit, final int dstPos, final int nHex) { public static byte hexToByte(final String src, final int srcPos, final byte dstInit, final int dstPos,
final int nHex) {
if (0 == nHex) { if (0 == nHex) {
return dstInit; return dstInit;
} }
if ((nHex - 1) * 4 + dstPos >= 8) { if ((nHex - 1) * 4 + dstPos >= 8) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greather or equal to than 8");
"(nHexs-1)*4+dstPos is greather or equal to than 8");
} }
byte out = dstInit; byte out = dstInit;
int shift = 0; int shift = 0;
@ -941,8 +930,7 @@ public class Conversion {
return dstInit; return dstInit;
} }
if (nBools - 1 + dstPos >= 64) { if (nBools - 1 + dstPos >= 64) {
throw new IllegalArgumentException( throw new IllegalArgumentException("nBools-1+dstPos is greather or equal to than 64");
"nBools-1+dstPos is greather or equal to than 64");
} }
long out = dstInit; long out = dstInit;
int shift = 0; int shift = 0;
@ -972,13 +960,13 @@ public class Conversion {
* @throws IllegalArgumentException if {@code nBools-1+dstPos >= 32} * @throws IllegalArgumentException if {@code nBools-1+dstPos >= 32}
* @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length} * @throws ArrayIndexOutOfBoundsException if {@code srcPos + nBools > src.length}
*/ */
public static int binaryToInt(final boolean[] src, final int srcPos, final int dstInit, final int dstPos, final int nBools) { public static int binaryToInt(final boolean[] src, final int srcPos, final int dstInit, final int dstPos,
final int nBools) {
if ((src.length == 0 && srcPos == 0) || 0 == nBools) { if ((src.length == 0 && srcPos == 0) || 0 == nBools) {
return dstInit; return dstInit;
} }
if (nBools - 1 + dstPos >= 32) { if (nBools - 1 + dstPos >= 32) {
throw new IllegalArgumentException( throw new IllegalArgumentException("nBools-1+dstPos is greather or equal to than 32");
"nBools-1+dstPos is greather or equal to than 32");
} }
int out = dstInit; int out = dstInit;
int shift = 0; int shift = 0;
@ -1014,8 +1002,7 @@ public class Conversion {
return dstInit; return dstInit;
} }
if (nBools - 1 + dstPos >= 16) { if (nBools - 1 + dstPos >= 16) {
throw new IllegalArgumentException( throw new IllegalArgumentException("nBools-1+dstPos is greather or equal to than 16");
"nBools-1+dstPos is greather or equal to than 16");
} }
short out = dstInit; short out = dstInit;
int shift = 0; int shift = 0;
@ -1081,13 +1068,13 @@ public class Conversion {
* @throws IllegalArgumentException if {@code (nInts-1)*32+srcPos >= 64} * @throws IllegalArgumentException if {@code (nInts-1)*32+srcPos >= 64}
* @throws ArrayIndexOutOfBoundsException if {@code dstPos + nInts > dst.length} * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nInts > dst.length}
*/ */
public static int[] longToIntArray(final long src, final int srcPos, final int[] dst, final int dstPos, final int nInts) { public static int[] longToIntArray(final long src, final int srcPos, final int[] dst, final int dstPos,
final int nInts) {
if (0 == nInts) { if (0 == nInts) {
return dst; return dst;
} }
if ((nInts - 1) * 32 + srcPos >= 64) { if ((nInts - 1) * 32 + srcPos >= 64) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nInts-1)*32+srcPos is greather or equal to than 64");
"(nInts-1)*32+srcPos is greather or equal to than 64");
} }
int shift = 0; int shift = 0;
for (int i = 0; i < nInts; i++) { for (int i = 0; i < nInts; i++) {
@ -1120,8 +1107,7 @@ public class Conversion {
return dst; return dst;
} }
if ((nShorts - 1) * 16 + srcPos >= 64) { if ((nShorts - 1) * 16 + srcPos >= 64) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nShorts-1)*16+srcPos is greather or equal to than 64");
"(nShorts-1)*16+srcPos is greather or equal to than 64");
} }
int shift = 0; int shift = 0;
for (int i = 0; i < nShorts; i++) { for (int i = 0; i < nShorts; i++) {
@ -1154,8 +1140,7 @@ public class Conversion {
return dst; return dst;
} }
if ((nShorts - 1) * 16 + srcPos >= 32) { if ((nShorts - 1) * 16 + srcPos >= 32) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nShorts-1)*16+srcPos is greather or equal to than 32");
"(nShorts-1)*16+srcPos is greather or equal to than 32");
} }
int shift = 0; int shift = 0;
for (int i = 0; i < nShorts; i++) { for (int i = 0; i < nShorts; i++) {
@ -1188,8 +1173,7 @@ public class Conversion {
return dst; return dst;
} }
if ((nBytes - 1) * 8 + srcPos >= 64) { if ((nBytes - 1) * 8 + srcPos >= 64) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nBytes-1)*8+srcPos is greather or equal to than 64");
"(nBytes-1)*8+srcPos is greather or equal to than 64");
} }
int shift = 0; int shift = 0;
for (int i = 0; i < nBytes; i++) { for (int i = 0; i < nBytes; i++) {
@ -1216,13 +1200,13 @@ public class Conversion {
* @throws IllegalArgumentException if {@code (nBytes-1)*8+srcPos >= 32} * @throws IllegalArgumentException if {@code (nBytes-1)*8+srcPos >= 32}
* @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length} * @throws ArrayIndexOutOfBoundsException if {@code dstPos + nBytes > dst.length}
*/ */
public static byte[] intToByteArray(final int src, final int srcPos, final byte[] dst, final int dstPos, final int nBytes) { public static byte[] intToByteArray(final int src, final int srcPos, final byte[] dst, final int dstPos,
final int nBytes) {
if (0 == nBytes) { if (0 == nBytes) {
return dst; return dst;
} }
if ((nBytes - 1) * 8 + srcPos >= 32) { if ((nBytes - 1) * 8 + srcPos >= 32) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nBytes-1)*8+srcPos is greather or equal to than 32");
"(nBytes-1)*8+srcPos is greather or equal to than 32");
} }
int shift = 0; int shift = 0;
for (int i = 0; i < nBytes; i++) { for (int i = 0; i < nBytes; i++) {
@ -1255,8 +1239,7 @@ public class Conversion {
return dst; return dst;
} }
if ((nBytes - 1) * 8 + srcPos >= 16) { if ((nBytes - 1) * 8 + srcPos >= 16) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nBytes-1)*8+srcPos is greather or equal to than 16");
"(nBytes-1)*8+srcPos is greather or equal to than 16");
} }
int shift = 0; int shift = 0;
for (int i = 0; i < nBytes; i++) { for (int i = 0; i < nBytes; i++) {
@ -1282,13 +1265,13 @@ public class Conversion {
* @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 64} * @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 64}
* @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos} * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}
*/ */
public static String longToHex(final long src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) { public static String longToHex(final long src, final int srcPos, final String dstInit, final int dstPos,
final int nHexs) {
if (0 == nHexs) { if (0 == nHexs) {
return dstInit; return dstInit;
} }
if ((nHexs - 1) * 4 + srcPos >= 64) { if ((nHexs - 1) * 4 + srcPos >= 64) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greather or equal to than 64");
"(nHexs-1)*4+srcPos is greather or equal to than 64");
} }
final StringBuilder sb = new StringBuilder(dstInit); final StringBuilder sb = new StringBuilder(dstInit);
int shift = 0; int shift = 0;
@ -1322,13 +1305,13 @@ public class Conversion {
* @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 32} * @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 32}
* @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos} * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}
*/ */
public static String intToHex(final int src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) { public static String intToHex(final int src, final int srcPos, final String dstInit, final int dstPos,
final int nHexs) {
if (0 == nHexs) { if (0 == nHexs) {
return dstInit; return dstInit;
} }
if ((nHexs - 1) * 4 + srcPos >= 32) { if ((nHexs - 1) * 4 + srcPos >= 32) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greather or equal to than 32");
"(nHexs-1)*4+srcPos is greather or equal to than 32");
} }
final StringBuilder sb = new StringBuilder(dstInit); final StringBuilder sb = new StringBuilder(dstInit);
int shift = 0; int shift = 0;
@ -1362,13 +1345,13 @@ public class Conversion {
* @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 16} * @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 16}
* @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos} * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}
*/ */
public static String shortToHex(final short src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) { public static String shortToHex(final short src, final int srcPos, final String dstInit, final int dstPos,
final int nHexs) {
if (0 == nHexs) { if (0 == nHexs) {
return dstInit; return dstInit;
} }
if ((nHexs - 1) * 4 + srcPos >= 16) { if ((nHexs - 1) * 4 + srcPos >= 16) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greather or equal to than 16");
"(nHexs-1)*4+srcPos is greather or equal to than 16");
} }
final StringBuilder sb = new StringBuilder(dstInit); final StringBuilder sb = new StringBuilder(dstInit);
int shift = 0; int shift = 0;
@ -1402,13 +1385,13 @@ public class Conversion {
* @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 8} * @throws IllegalArgumentException if {@code (nHexs-1)*4+srcPos >= 8}
* @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos} * @throws StringIndexOutOfBoundsException if {@code dst.init.length() < dstPos}
*/ */
public static String byteToHex(final byte src, final int srcPos, final String dstInit, final int dstPos, final int nHexs) { public static String byteToHex(final byte src, final int srcPos, final String dstInit, final int dstPos,
final int nHexs) {
if (0 == nHexs) { if (0 == nHexs) {
return dstInit; return dstInit;
} }
if ((nHexs - 1) * 4 + srcPos >= 8) { if ((nHexs - 1) * 4 + srcPos >= 8) {
throw new IllegalArgumentException( throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greather or equal to than 8");
"(nHexs-1)*4+srcPos is greather or equal to than 8");
} }
final StringBuilder sb = new StringBuilder(dstInit); final StringBuilder sb = new StringBuilder(dstInit);
int shift = 0; int shift = 0;
@ -1449,8 +1432,7 @@ public class Conversion {
return dst; return dst;
} }
if (nBools - 1 + srcPos >= 64) { if (nBools - 1 + srcPos >= 64) {
throw new IllegalArgumentException( throw new IllegalArgumentException("nBools-1+srcPos is greather or equal to than 64");
"nBools-1+srcPos is greather or equal to than 64");
} }
int shift = 0; int shift = 0;
for (int i = 0; i < nBools; i++) { for (int i = 0; i < nBools; i++) {
@ -1483,8 +1465,7 @@ public class Conversion {
return dst; return dst;
} }
if (nBools - 1 + srcPos >= 32) { if (nBools - 1 + srcPos >= 32) {
throw new IllegalArgumentException( throw new IllegalArgumentException("nBools-1+srcPos is greather or equal to than 32");
"nBools-1+srcPos is greather or equal to than 32");
} }
int shift = 0; int shift = 0;
for (int i = 0; i < nBools; i++) { for (int i = 0; i < nBools; i++) {
@ -1517,8 +1498,7 @@ public class Conversion {
return dst; return dst;
} }
if (nBools - 1 + srcPos >= 16) { if (nBools - 1 + srcPos >= 16) {
throw new IllegalArgumentException( throw new IllegalArgumentException("nBools-1+srcPos is greather or equal to than 16");
"nBools-1+srcPos is greather or equal to than 16");
} }
int shift = 0; int shift = 0;
assert ((nBools - 1) < 16 - srcPos); assert ((nBools - 1) < 16 - srcPos);
@ -1609,7 +1589,6 @@ public class Conversion {
if (src.length - srcPos < 16) { if (src.length - srcPos < 16) {
throw new IllegalArgumentException("Need at least 16 bytes for UUID"); throw new IllegalArgumentException("Need at least 16 bytes for UUID");
} }
return new UUID(byteArrayToLong(src, srcPos, 0, 0, 8), byteArrayToLong( return new UUID(byteArrayToLong(src, srcPos, 0, 0, 8), byteArrayToLong(src, srcPos + 8, 0, 0, 8));
src, srcPos + 8, 0, 0, 8));
} }
} }