The following document contains the results of PMD's CPD 4.2.5.
| File | Line |
|---|---|
| org\apache\commons\codec\net\QuotedPrintableCodec.java | 231 |
| org\apache\commons\codec\net\URLCodec.java | 228 |
return StringUtils.newStringUsAscii(encode(pString.getBytes(charset)));
}
/**
* Encodes a string into its URL safe form using the default string
* charset. Unsafe characters are escaped.
*
* @param pString string to convert to a URL safe form
* @return URL safe string
* @throws EncoderException Thrown if URL encoding is unsuccessful
*
* @see #getDefaultCharset()
*/
public String encode(String pString) throws EncoderException {
if (pString == null) {
return null;
}
try {
return encode(pString, getDefaultCharset());
} catch (UnsupportedEncodingException e) {
throw new EncoderException(e.getMessage(), e);
}
}
/**
* Decodes a URL safe string into its original form using the
* specified encoding. Escaped characters are converted back
* to their original representation.
*
* @param pString URL safe string to convert into its original form
* @param charset the original string charset
* @return original string
* @throws DecoderException Thrown if URL decoding is unsuccessful
* @throws UnsupportedEncodingException Thrown if charset is not
* supported
*/
public String decode(String pString, String charset) throws DecoderException, UnsupportedEncodingException {
if (pString == null) {
return null;
}
return new String(decode(StringUtils.getBytesUsAscii(pString)), charset);
}
/**
* Decodes a URL safe string into its original form using the default
* string charset. Escaped characters are converted back to their
* original representation.
*
* @param pString URL safe string to convert into its original form
* @return original string
* @throws DecoderException Thrown if URL decoding is unsuccessful
*
* @see #getDefaultCharset()
*/
public String decode(String pString) throws DecoderException {
if (pString == null) {
return null;
}
try {
return decode(pString, getDefaultCharset());
} catch (UnsupportedEncodingException e) {
throw new DecoderException(e.getMessage(), e);
}
}
/**
* Encodes an object into its URL safe form. Unsafe characters are
* escaped.
*
* @param pObject string to convert to a URL safe form
* @return URL safe object
* @throws EncoderException Thrown if URL encoding is not
* applicable to objects of this type or
* if encoding is unsuccessful
*/
public Object encode(Object pObject) throws EncoderException {
if (pObject == null) {
return null;
} else if (pObject instanceof byte[]) {
return encode((byte[])pObject);
} else if (pObject instanceof String) {
return encode((String)pObject);
} else {
throw new EncoderException("Objects of type " +
pObject.getClass().getName() + " cannot be URL encoded"); | |
| File | Line |
|---|---|
| org\apache\commons\codec\language\Caverphone1.java | 60 |
| org\apache\commons\codec\language\Caverphone2.java | 63 |
txt = txt.replaceAll("^trough", "trou2f"); // 2.0 only - note the spec says ^enough here again, c+p error I assume
txt = txt.replaceAll("^gn", "2n");
// End
txt = txt.replaceAll("mb$", "m2");
// 4. Handle replacements
txt = txt.replaceAll("cq", "2q");
txt = txt.replaceAll("ci", "si");
txt = txt.replaceAll("ce", "se");
txt = txt.replaceAll("cy", "sy");
txt = txt.replaceAll("tch", "2ch");
txt = txt.replaceAll("c", "k");
txt = txt.replaceAll("q", "k");
txt = txt.replaceAll("x", "k");
txt = txt.replaceAll("v", "f");
txt = txt.replaceAll("dg", "2g");
txt = txt.replaceAll("tio", "sio");
txt = txt.replaceAll("tia", "sia");
txt = txt.replaceAll("d", "t");
txt = txt.replaceAll("ph", "fh");
txt = txt.replaceAll("b", "p");
txt = txt.replaceAll("sh", "s2");
txt = txt.replaceAll("z", "s");
txt = txt.replaceAll("^[aeiou]", "A");
txt = txt.replaceAll("[aeiou]", "3");
txt = txt.replaceAll("j", "y"); // 2.0 only | |
| File | Line |
|---|---|
| org\apache\commons\codec\binary\Base32.java | 68 |
| org\apache\commons\codec\binary\Base32.java | 94 |
private static final byte[] HEX_DECODE_TABLE = {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10-1f
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 63, // 20-2f | |
| File | Line |
|---|---|
| org\apache\commons\codec\binary\Base32.java | 60 |
| org\apache\commons\codec\binary\Base64.java | 99 |
};
/**
* This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified in
* Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64
* alphabet but fall within the bounds of the array are translated to -1.
*
* Note: '+' and '-' both decode to 62. '/' and '_' both decode to 63. This means decoder seamlessly handles both
* URL_SAFE and STANDARD base64. (The encoder, on the other hand, needs to know ahead of time what to emit).
*
* Thanks to "commons" project in ws.apache.org for this code.
* http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/
*/
private static final byte[] DECODE_TABLE = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, 52, 53, 54, | |
| File | Line |
|---|---|
| org\apache\commons\codec\binary\Base32.java | 94 |
| org\apache\commons\codec\binary\Base64.java | 112 |
private static final byte[] DECODE_TABLE = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, 52, 53, 54, | |
| File | Line |
|---|---|
| org\apache\commons\codec\binary\Base64.java | 80 |
| org\apache\commons\codec\binary\Base64.java | 93 |
private static final byte[] URL_SAFE_ENCODE_TABLE = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' | |
| File | Line |
|---|---|
| org\apache\commons\codec\language\Caverphone1.java | 86 |
| org\apache\commons\codec\language\Caverphone2.java | 92 |
txt = txt.replaceAll("y", "3"); // 2.0 only
txt = txt.replaceAll("3gh3", "3kh3");
txt = txt.replaceAll("gh", "22");
txt = txt.replaceAll("g", "k");
txt = txt.replaceAll("s+", "S");
txt = txt.replaceAll("t+", "T");
txt = txt.replaceAll("p+", "P");
txt = txt.replaceAll("k+", "K");
txt = txt.replaceAll("f+", "F");
txt = txt.replaceAll("m+", "M");
txt = txt.replaceAll("n+", "N");
txt = txt.replaceAll("w3", "W3");
txt = txt.replaceAll("wh3", "Wh3"); | |
| File | Line |
|---|---|
| org\apache\commons\codec\binary\Base32.java | 425 |
| org\apache\commons\codec\binary\Base64.java | 359 |
break;
}
currentLinePos += pos - savedPos; // keep track of current line position
// if currentPos == 0 we are at the start of a line, so don't add CRLF
if (lineLength > 0 && currentLinePos > 0) {
System.arraycopy(lineSeparator, 0, buffer, pos, lineSeparator.length);
pos += lineSeparator.length;
}
} else {
for (int i = 0; i < inAvail; i++) {
ensureBufferSize(encodeSize);
modulus = (modulus+1) % BYTES_PER_UNENCODED_BLOCK;
int b = in[inPos++];
if (b < 0) {
b += 256;
}
bitWorkArea = (bitWorkArea << 8) + b; // BITS_PER_BYTE
if (0 == modulus) { // 3 bytes = 24 bits = 4 * 6 bits to extract
buffer[pos++] = encodeTable[(bitWorkArea >> 18) & MASK_6BITS]; | |