当前位置: 首页>>代码示例>>Java>>正文


Java URLCodec.decodeUrl方法代码示例

本文整理汇总了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;
}
 
开发者ID:hpe-idol,项目名称:java-aci-api-ng,代码行数:24,代码来源:AciURLCodec.java

示例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());
    }
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:17,代码来源:URIUtil.java

示例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);
    }
}
 
开发者ID:hpe-idol,项目名称:java-aci-api-ng,代码行数:19,代码来源:GssEncryptionCodec.java

示例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());
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:17,代码来源:URIUtil.java

示例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");
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:19,代码来源:EncodingUtil.java

示例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);
    }
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:8,代码来源:Encodings.java

示例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;
        }

    }
 
开发者ID:owenson,项目名称:tor-research-framework,代码行数:14,代码来源:URLUtil.java

示例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);
  }
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:19,代码来源:OAuthCodec.java

示例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);
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:45,代码来源:URI.java

示例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());
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:20,代码来源:URIUtil.java

示例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);
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:46,代码来源:URI.java

示例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());
    }
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:22,代码来源:URIUtil.java

示例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-&gt;octet sequence-&gt;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);
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:53,代码来源:URI.java

示例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());
    }
}
 
开发者ID:parisbutterfield,项目名称:alexa-stocks,代码行数:20,代码来源:URIUtils.java

示例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);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:45,代码来源:URI.java


注:本文中的org.apache.commons.codec.net.URLCodec.decodeUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。