CPD Results
The following document contains the results of PMD's CPD 7.14.0.
Duplications
| File | Line |
|---|---|
| org/forgerock/util/encode/Base64.java | 336 |
| org/forgerock/util/encode/Base64.java | 414 |
while (eIx > 0 && IA[sArr[eIx] & 0xff] < 0) {
eIx--;
}
// get the padding count (=) (0, 1 or 2)
final int pad = sArr[eIx] == '=' ? sArr[eIx - 1] == '=' ? 2 : 1 : 0; // Count '=' at end.
final int cCnt = eIx - sIx + 1; // Content count including possible separators
final int sepCnt = sLen > 76 ? (sArr[76] == '\r' ? cCnt / 78 : 0) << 1 : 0;
final int len = ((cCnt - sepCnt) * 6 >> 3) - pad; // The number of decoded bytes
final byte[] dArr = new byte[len]; // Preallocate byte[] of exact length
// Decode all but the last 0 - 2 bytes.
int d = 0;
for (int cc = 0, eLen = len / 3 * 3; d < eLen;) {
// Assemble three bytes into an int from four "valid" characters.
final int i =
IA[sArr[sIx++]] << 18 | IA[sArr[sIx++]] << 12 | IA[sArr[sIx++]] << 6
| IA[sArr[sIx++]];
// Add the bytes
dArr[d++] = (byte) (i >> 16);
dArr[d++] = (byte) (i >> 8);
dArr[d++] = (byte) i;
// If line separator, jump over it.
if (sepCnt > 0 && ++cc == 19) {
sIx += 2;
cc = 0;
}
}
if (d < len) {
// Decode last 1-3 bytes (incl '=') into 1-3 bytes
int i = 0;
for (int j = 0; sIx <= eIx - pad; j++) {
i |= IA[sArr[sIx++]] << 18 - j * 6;
}
for (int r = 16; d < len; r -= 8) {
dArr[d++] = (byte) (i >> r);
}
}
return dArr;
}
/**
* Decodes a BASE64 encoded char array that is known to be resonably well
* formatted. The method is about twice as fast as {@link #decode(char[])}.
* The preconditions are:<br>
* + The array must have a line length of 76 chars OR no line separators at
* all (one line).<br>
* + Line separator must be "\r\n", as specified in RFC 2045 + The array
* must not contain illegal characters within the encoded string<br>
* + The array CAN have illegal characters at the beginning and end, those
* will be dealt with appropriately.<br>
*
* @param sArr
* The source array. Length 0 will return an empty array.
* <code>null</code> will throw an exception.
* @return The decoded array of bytes. May be of length 0.
*/
public static byte[] decodeFast(final char[] sArr) { | |
| File | Line |
|---|---|
| org/forgerock/util/promise/PromiseImpl.java | 364 |
| org/forgerock/util/promise/Promises.java | 164 |
public <EOUT extends Exception> Promise<V, EOUT> thenCatch(final Function<? super E, V, EOUT> onException) {
return then(Promises.<V, EOUT>resultIdempotentFunction(), onException);
}
@Override
public Promise<V, E> thenCatchRuntimeException(
Function<? super RuntimeException, V, E> onRuntimeException) {
return then(Promises.<V, E>resultIdempotentFunction(), Promises.<V, E>exceptionIdempotentFunction(),
onRuntimeException);
}
@Override
public final <VOUT, EOUT extends Exception> Promise<VOUT, EOUT> then(
final Function<? super V, VOUT, EOUT> onResult, final Function<? super E, VOUT, EOUT> onException) {
return then(onResult, onException, Promises.<VOUT, EOUT>runtimeExceptionIdempotentFunction());
}
@Override
@SuppressWarnings("unchecked")
public final <VOUT, EOUT extends Exception> Promise<VOUT, EOUT> then(
final Function<? super V, VOUT, EOUT> onResult, final Function<? super E, VOUT, EOUT> onException,
final Function<? super RuntimeException, VOUT, EOUT> onRuntimeException) { | |
| File | Line |
|---|---|
| org/forgerock/util/promise/PromiseImpl.java | 458 |
| org/forgerock/util/promise/Promises.java | 233 |
public final Promise<V, E> thenCatchRuntimeExceptionAsync(
AsyncFunction<? super RuntimeException, V, E> onRuntimeException) {
return thenAsync(Promises.<V, E>resultIdempotentAsyncFunction(),
Promises.<V, E>exceptionIdempotentAsyncFunction(), onRuntimeException);
}
@Override
public final <VOUT, EOUT extends Exception> Promise<VOUT, EOUT> thenAsync(
final AsyncFunction<? super V, VOUT, EOUT> onResult,
final AsyncFunction<? super E, VOUT, EOUT> onException) {
return thenAsync(onResult, onException, Promises.<VOUT, EOUT>runtimeExceptionIdempotentAsyncFunction());
}
@Override | |

