本文整理汇总了Java中org.apache.commons.codec.net.URLCodec.decodeUrl方法的典型用法代码示例。如果您正苦于以下问题:Java URLCodec.decodeUrl方法的具体用法?Java URLCodec.decodeUrl怎么用?Java URLCodec.decodeUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.codec.net.URLCodec
的用法示例。
在下文中一共展示了URLCodec.decodeUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Decodes a URL safe string into its original form using the UTF-8 charset. Escaped characters are converted back
* to their original representation.
* @param string URL safe string to convert into its original form
* @return original string
* @throws AciURLCodecException Thrown if URL decoding is unsuccessful
*/
public String decode(final String string) throws AciURLCodecException {
// This is what we'll return...
String returnValue = null;
try {
if (string != null) {
returnValue = new String(URLCodec.decodeUrl(string.getBytes(US_ASCII)), UTF8);
}
} catch (final UnsupportedEncodingException | DecoderException uee) {
// This should never ever happen as both charsets are required by the Java Spec.
throw new AciURLCodecException(uee);
}
// Return the result...
return returnValue;
}
示例2: decode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Unescape and decode a given string regarded as an escaped string with the
* default protocol charset.
*
* @param escaped a string
* @return the unescaped string
* @throws HttpException if the string cannot be decoded (invalid)
*/
public static String decode(String escaped) throws HttpException {
try {
byte[] rawdata = URLCodec.decodeUrl(EncodingUtils.getAsciiBytes(escaped));
return EncodingUtils.getString(rawdata, UTF8_CHARSET_NAME);
} catch (DecoderException e) {
throw new HttpException(e.getMessage());
}
}
示例3: decodeInternal
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* This method firstly www-form-urlencoded unescapes the input string, as the response from a GSS-API secured ACI
* server www-form-urlencoded escapes the Base64 encoded content. Once that's done it passes the resulting string
* onto the super class for the Base64 decoding and length prefix stripping.
* @param bytes The Base64 encoded byte array to decode.
* @return The decoded byte array.
* @throws EncryptionCodecException If an error occurred during processing
*/
@Override
protected byte[] decodeInternal(final byte[] bytes) throws EncryptionCodecException {
try {
// We're not using AciURLCodec as it works on Strings, it uses URLCodec internally anyway, so it's always
// going to be shipped, thus we may as well use it's byte[] methods...
return super.decodeInternal(URLCodec.decodeUrl(bytes));
} catch (final DecoderException de) {
throw new EncryptionCodecException("Unable to www-form-urlencoded unescape.", de);
}
}
示例4: decode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Unescape and decode a given string regarded as an escaped string with the
* default protocol charset.
*
* @param escaped a string
* @return the unescaped string
* @throws HttpException if the string cannot be decoded (invalid)
*/
public static String decode(String escaped) throws HttpException {
try {
byte[] rawdata = URLCodec.decodeUrl(EncodingUtils.getAsciiBytes(escaped));
return EncodingUtils.getString(rawdata, Charsets.UTF_8.name());
} catch (DecoderException e) {
throw new HttpException(e.getMessage());
}
}
示例5: decode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Unescape and decode a given string regarded as an escaped string with the
* UTF-8 protocol charset.
* @param escaped a string
* @return the unescaped string
* @throws IllegalStateException if the escaped string is not a correct URL
*/
public static String decode(String escaped) {
byte[] asciiData = getAsciiBytes(escaped);
byte[] rawdata;
try {
rawdata = URLCodec.decodeUrl(asciiData);
} catch (DecoderException e) {
throw new IllegalStateException(e.getMessage());
}
return getString(rawdata,
"UTF-8");
}
示例6: decodeURL
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
public static String decodeURL(String text) {
try {
return new String(URLCodec.decodeUrl(Strings.bytes(text)), Charsets.UTF_8);
} catch (DecoderException e) {
throw new Error(e);
}
}
示例7: URLDecode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
public static byte[] URLDecode(byte[] bytes) {
try {
byte[] decodeURLBytes = URLCodec.decodeUrl(bytes);
return decodeURLBytes;
} catch (DecoderException de) {
System.err.println("URLDecode: Failed to decode text, returning un-decoded bytes.\n"
+ "Exception: " + de.toString());
return bytes;
}
}
示例8: oauthDecode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Decode the specified value.
*
* @param value The value to decode.
* @return The decoded value.
*/
public static String oauthDecode(String value) throws DecoderException {
if (value == null) {
return "";
}
try {
return new String(URLCodec.decodeUrl(value.getBytes("US-ASCII")), "UTF-8");
}
catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
示例9: decode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Decodes URI encoded string.
* <p/>
* This is a two mapping, one from URI characters to octets, and
* subsequently a second from octets to original characters:
* <p><blockquote><pre>
* URI character sequence->octet sequence->original character sequence
* </pre></blockquote><p>
* <p/>
* A URI must be separated into its components before the escaped
* characters within those components can be allowedly decoded.
* <p/>
* Notice that there is a chance that URI characters that are non UTF-8
* may be parsed as valid UTF-8. A recent non-scientific analysis found
* that EUC encoded Japanese words had a 2.7% false reading; SJIS had a
* 0.0005% false reading; other encoding such as ASCII or KOI-8 have a 0%
* false reading.
* <p/>
* The percent "%" character always has the reserved purpose of being
* the escape indicator, it must be escaped as "%25" in order to be used
* as data within a URI.
* <p/>
* The unescape method is internally performed within this method.
*
* @param component the URI character sequence
* @param charset the protocol charset
* @return original character sequence
* @throws HttpException incomplete trailing escape pattern or unsupported
* character encoding
* @since 3.0
*/
protected static String decode(String component, String charset)
throws HttpException {
if (component == null) {
throw new IllegalArgumentException("Component array of chars may not be null");
}
byte[] rawData;
try {
rawData = URLCodec.decodeUrl(EncodingUtils.getAsciiBytes(component));
} catch (DecoderException e) {
throw new HttpException(e.getMessage());
}
return EncodingUtils.getString(rawData, charset);
}
示例10: decode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Unescape and decode a given string regarded as an escaped string with the
* default protocol charset.
*
* @param escaped a string
* @return the unescaped string
*
* @throws URIException if the string cannot be decoded (invalid)
*
* @see URI#getDefaultProtocolCharset
*/
public static String decode(String escaped) throws URIException {
try {
byte[] rawdata = URLCodec.decodeUrl(EncodingUtil.getAsciiBytes(escaped));
return EncodingUtil.getString(rawdata, URI.getDefaultProtocolCharset());
} catch (DecoderException e) {
throw new URIException(e.getMessage());
}
}
示例11: decode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Decodes URI encoded string.
*
* This is a two mapping, one from URI characters to octets, and
* subsequently a second from octets to original characters:
* <p><blockquote><pre>
* URI character sequence->octet sequence->original character sequence
* </pre></blockquote><p>
*
* A URI must be separated into its components before the escaped
* characters within those components can be allowedly decoded.
* <p>
* Notice that there is a chance that URI characters that are non UTF-8
* may be parsed as valid UTF-8. A recent non-scientific analysis found
* that EUC encoded Japanese words had a 2.7% false reading; SJIS had a
* 0.0005% false reading; other encoding such as ASCII or KOI-8 have a 0%
* false reading.
* <p>
* The percent "%" character always has the reserved purpose of being
* the escape indicator, it must be escaped as "%25" in order to be used
* as data within a URI.
* <p>
* The unescape method is internally performed within this method.
*
* @param component the URI character sequence
* @param charset the protocol charset
* @return original character sequence
* @throws URIException incomplete trailing escape pattern or unsupported
* character encoding
*
* @since 3.0
*/
protected static String decode(String component, String charset)
throws URIException {
if (component == null) {
throw new IllegalArgumentException("Component array of chars may not be null");
}
byte[] rawdata = null;
try {
rawdata = URLCodec.decodeUrl(EncodingUtil.getAsciiBytes(component));
} catch (DecoderException e) {
throw new URIException(e.getMessage());
}
return EncodingUtil.getString(rawdata, charset);
}
示例12: decode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Unescape and decode a given string regarded as an escaped string with the
* default protocol charset.
*
* @param escaped
* a string
* @return the unescaped string
*
* @throws URIException
* if the string cannot be decoded (invalid)
*
* @see URI#getDefaultProtocolCharset
*/
public static String decode(final String escaped) throws URIException {
try {
final byte[] rawdata = URLCodec.decodeUrl(EncodingUtil.getAsciiBytes(escaped));
return EncodingUtil.getString(rawdata, URI.getDefaultProtocolCharset());
} catch (final DecoderException e) {
throw new URIException(e.getMessage());
}
}
示例13: decode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Decodes URI encoded string.
*
* This is a two mapping, one from URI characters to octets, and
* subsequently a second from octets to original characters:
* <p>
* <blockquote>
*
* <pre>
* URI character sequence->octet sequence->original character sequence
* </pre>
*
* </blockquote>
* <p>
*
* A URI must be separated into its components before the escaped characters
* within those components can be allowedly decoded.
* <p>
* Notice that there is a chance that URI characters that are non UTF-8 may
* be parsed as valid UTF-8. A recent non-scientific analysis found that EUC
* encoded Japanese words had a 2.7% false reading; SJIS had a 0.0005% false
* reading; other encoding such as ASCII or KOI-8 have a 0% false reading.
* <p>
* The percent "%" character always has the reserved purpose of being the
* escape indicator, it must be escaped as "%25" in order to be used as data
* within a URI.
* <p>
* The unescape method is internally performed within this method.
*
* @param component
* the URI character sequence
* @param charset
* the protocol charset
* @return original character sequence
* @throws URIException
* incomplete trailing escape pattern or unsupported character
* encoding
*
* @since 3.0
*/
protected static String decode(final String component, final String charset) throws URIException {
if (component == null) {
throw new IllegalArgumentException("Component array of chars may not be null");
}
byte[] rawdata = null;
try {
rawdata = URLCodec.decodeUrl(EncodingUtil.getAsciiBytes(component));
} catch (final DecoderException e) {
throw new URIException(e.getMessage());
}
return EncodingUtil.getString(rawdata, charset);
}
示例14: decode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Unescape and decode a given string regarded as an escaped string with the
* default protocol charset.
*
* @param escaped a string
* @return the unescaped string
*
* @throws URIException if the string cannot be decoded (invalid)
*
* @see URI#getDefaultProtocolCharset
*/
public static String decode(String escaped) throws URIException {
try {
byte[] rawdata = URLCodec.decodeUrl(EncodingUtils.getAsciiBytes(escaped));
return EncodingUtils.getString(rawdata, "UTF-8");
} catch (DecoderException e) {
throw new URIException(e.getMessage());
}
}
示例15: decode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Decodes URI encoded string.
* <p/>
* This is a two mapping, one from URI characters to octets, and
* subsequently a second from octets to original characters:
* <p><blockquote><pre>
* URI character sequence->octet sequence->original character sequence
* </pre></blockquote><p>
* <p/>
* A URI must be separated into its components before the escaped
* characters within those components can be allowedly decoded.
* <p/>
* Notice that there is a chance that URI characters that are non UTF-8
* may be parsed as valid UTF-8. A recent non-scientific analysis found
* that EUC encoded Japanese words had a 2.7% false reading; SJIS had a
* 0.0005% false reading; other encoding such as ASCII or KOI-8 have a 0%
* false reading.
* <p/>
* The percent "%" character always has the reserved purpose of being
* the escape indicator, it must be escaped as "%25" in order to be used
* as data within a URI.
* <p/>
* The unescape method is internally performed within this method.
*
* @param component the URI character sequence
* @param charset the protocol charset
* @return original character sequence
* @throws HttpException incomplete trailing escape pattern or unsupported
* character encoding
* @since 3.0
*/
protected static String decode(String component, String charset)
throws HttpException {
if (component == null) {
throw new IllegalArgumentException("Component array of chars may not be null");
}
byte[] rawdata = null;
try {
rawdata = URLCodec.decodeUrl(EncodingUtils.getAsciiBytes(component));
} catch (DecoderException e) {
throw new HttpException(e.getMessage());
}
return EncodingUtils.getString(rawdata, charset);
}