The following document contains the results of PMD's CPD 4.2.2.
| File | Line |
|---|---|
| org\apache\commons\codec\net\QuotedPrintableCodec.java | 231 |
| org\apache\commons\codec\net\URLCodec.java | 227 |
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\binary\Base64.java | 88 |
| org\apache\commons\codec\binary\Base64.java | 101 |
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', '-', '_'
| |