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


Java URLCodec.encodeUrl方法代码示例

本文整理汇总了Java中org.apache.commons.codec.net.URLCodec.encodeUrl方法的典型用法代码示例。如果您正苦于以下问题:Java URLCodec.encodeUrl方法的具体用法?Java URLCodec.encodeUrl怎么用?Java URLCodec.encodeUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.codec.net.URLCodec的用法示例。


在下文中一共展示了URLCodec.encodeUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Encodes a string into its URL safe form using the UTF-8 charset. Unsafe characters are escaped and the resulting
 * string is returned in the US-ASCII charset.
 * @param string The string to convert to a URL safe form
 * @return URL safe string
 * @throws AciURLCodecException If there was a problem during the encoding
 */
public String encode(final String string) {
    // This is what we'll return...
    String returnValue = null;

    try {
        if (string != null) {
            returnValue = new String(URLCodec.encodeUrl(safeChars, string.getBytes(UTF8)), US_ASCII);
        }
    } catch (final UnsupportedEncodingException 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: encodePath

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Escape and encode a string regarded as the path component of an URI with
 * the default protocol charset.
 * @param unescaped an unescaped string
 * @return the escaped string
 */
public static String encodePath(String unescaped) {
    byte[] rawdata = URLCodec.encodeUrl(allowed_abs_path,
                                        getBytes(unescaped,
                                                 "UTF-8"));
    return getAsciiString(rawdata);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:13,代码来源:EncodingUtil.java

示例3: oauthEncode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Encode the specified value.
 *
 * @param value The value to encode.
 * @return The encoded value.
 */
public static String oauthEncode(String value) {
  if (value == null) {
    return "";
  }

  try {
    return new String(URLCodec.encodeUrl(SAFE_CHARACTERS, value.getBytes("UTF-8")), "US-ASCII");
  }
  catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:19,代码来源:OAuthCodec.java

示例4: encodeUri

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
private static @NotNull String encodeUri(@NotNull String decodedUriNoLeadSlash) {
  byte[] urlBytes = URLCodec.encodeUrl(SAFE_CHARACTERS, decodedUriNoLeadSlash.getBytes(StandardCharsets.UTF_8));
  return "/" + new String(urlBytes, StandardCharsets.UTF_8);
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:5,代码来源:UriComposer.java

示例5: encode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
public static String encode(String str, java.nio.charset.Charset charset) throws UnsupportedEncodingException {
	return new String(URLCodec.encodeUrl(WWW_FORM_URL, str.getBytes(charset)),"us-ascii");
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:4,代码来源:URLEncoder.java

示例6: urlPath

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
public static String urlPath(String text) {
    return new String(URLCodec.encodeUrl(URL_PATH, Strings.bytes(text)), Charsets.UTF_8);
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:4,代码来源:Encodings.java

示例7: url

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
public static String url(String text) {
    return new String(URLCodec.encodeUrl(null, Strings.bytes(text)), Charsets.UTF_8);
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:4,代码来源:Encodings.java

示例8: encode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Escape and encode a given string with allowed characters not to be
 * escaped and a given charset.
 *
 * @param unescaped a string
 * @param allowed   allowed characters not to be escaped
 * @param charset   the charset
 * @return the escaped string
 */
public static String encode(String unescaped, BitSet allowed,
                            String charset) throws HttpException {
    byte[] rawdata = URLCodec.encodeUrl(allowed,
            EncodingUtils.getBytes(unescaped, charset));
    return EncodingUtils.getAsciiString(rawdata);
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:16,代码来源:URIUtil.java

示例9: encode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Encodes URI string.
 * <p/>
 * This is a two mapping, one from original characters to octets, and
 * subsequently a second from octets to URI characters:
 * <p><blockquote><pre>
 *   original character sequence->octet sequence->URI character sequence
 * </pre></blockquote><p>
 * <p/>
 * An escaped octet is encoded as a character triplet, consisting of the
 * percent character "%" followed by the two hexadecimal digits
 * representing the octet code. For example, "%20" is the escaped
 * encoding for the US-ASCII space character.
 * <p/>
 * Conversion from the local filesystem character set to UTF-8 will
 * normally involve a two step process. First convert the local character
 * set to the UCS; then convert the UCS to UTF-8.
 * The first step in the process can be performed by maintaining a mapping
 * table that includes the local character set code and the corresponding
 * UCS code.
 * The next step is to convert the UCS character code to the UTF-8 encoding.
 * <p/>
 * Mapping between vendor codepages can be done in a very similar manner
 * as described above.
 * <p/>
 * The only time escape encodings can allowedly be made is when a URI is
 * being created from its component parts.  The escape and validate methods
 * are internally performed within this method.
 *
 * @param original the original character sequence
 * @param allowed  those characters that are allowed within a component
 * @param charset  the protocol charset
 * @return URI character sequence
 * @throws HttpException null component or unsupported character encoding
 */

protected static char[] encode(String original, BitSet allowed,
                               String charset) throws HttpException {
    if (original == null) {
        throw new IllegalArgumentException("Original string may not be null");
    }
    if (allowed == null) {
        throw new IllegalArgumentException("Allowed bitset may not be null");
    }
    byte[] rawdata = URLCodec.encodeUrl(allowed, EncodingUtils.getBytes(original, charset));
    return EncodingUtils.getAsciiString(rawdata).toCharArray();
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:48,代码来源:URI.java

示例10: encode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Escape and encode a given string with allowed characters not to be
 * escaped and a given charset.
 *
 * @param unescaped a string
 * @param allowed allowed characters not to be escaped
 * @param charset the charset
 * @return the escaped string
 */
public static String encode(String unescaped, BitSet allowed,
        String charset) throws URIException {
    byte[] rawdata = URLCodec.encodeUrl(allowed, 
        EncodingUtil.getBytes(unescaped, charset));
    return EncodingUtil.getAsciiString(rawdata);
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:16,代码来源:URIUtil.java

示例11: encode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Encodes URI string.
 *
 * This is a two mapping, one from original characters to octets, and
 * subsequently a second from octets to URI characters:
 * <p><blockquote><pre>
 *   original character sequence->octet sequence->URI character sequence
 * </pre></blockquote><p>
 *
 * An escaped octet is encoded as a character triplet, consisting of the
 * percent character "%" followed by the two hexadecimal digits
 * representing the octet code. For example, "%20" is the escaped
 * encoding for the US-ASCII space character.
 * <p>
 * Conversion from the local filesystem character set to UTF-8 will
 * normally involve a two step process. First convert the local character
 * set to the UCS; then convert the UCS to UTF-8.
 * The first step in the process can be performed by maintaining a mapping
 * table that includes the local character set code and the corresponding
 * UCS code.
 * The next step is to convert the UCS character code to the UTF-8 encoding.
 * <p>
 * Mapping between vendor codepages can be done in a very similar manner
 * as described above.
 * <p>
 * The only time escape encodings can allowedly be made is when a URI is
 * being created from its component parts.  The escape and validate methods
 * are internally performed within this method.
 *
 * @param original the original character sequence
 * @param allowed those characters that are allowed within a component
 * @param charset the protocol charset
 * @return URI character sequence
 * @throws URIException null component or unsupported character encoding
 */
    
protected static char[] encode(String original, BitSet allowed,
        String charset) throws URIException {
    if (original == null) {
        throw new IllegalArgumentException("Original string may not be null");
    }
    if (allowed == null) {
        throw new IllegalArgumentException("Allowed bitset may not be null");
    }
    byte[] rawdata = URLCodec.encodeUrl(allowed, EncodingUtil.getBytes(original, charset));
    return EncodingUtil.getAsciiString(rawdata).toCharArray();
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:48,代码来源:URI.java

示例12: encode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Encodes URI string.
 *
 * This is a two mapping, one from original characters to octets, and
 * subsequently a second from octets to URI characters:
 * <p>
 * <blockquote>
 *
 * <pre>
 *   original character sequence-&gt;octet sequence-&gt;URI character sequence
 * </pre>
 *
 * </blockquote>
 * <p>
 *
 * An escaped octet is encoded as a character triplet, consisting of the
 * percent character "%" followed by the two hexadecimal digits representing
 * the octet code. For example, "%20" is the escaped encoding for the
 * US-ASCII space character.
 * <p>
 * Conversion from the local filesystem character set to UTF-8 will normally
 * involve a two step process. First convert the local character set to the
 * UCS; then convert the UCS to UTF-8. The first step in the process can be
 * performed by maintaining a mapping table that includes the local
 * character set code and the corresponding UCS code. The next step is to
 * convert the UCS character code to the UTF-8 encoding.
 * <p>
 * Mapping between vendor codepages can be done in a very similar manner as
 * described above.
 * <p>
 * The only time escape encodings can allowedly be made is when a URI is
 * being created from its component parts. The escape and validate methods
 * are internally performed within this method.
 *
 * @param original
 *        the original character sequence
 * @param allowed
 *        those characters that are allowed within a component
 * @param charset
 *        the protocol charset
 * @return URI character sequence
 * @throws URIException
 *         null component or unsupported character encoding
 */

protected static char[] encode(final String original, final BitSet allowed, final String charset)
    throws URIException {
    if (original == null) {
        throw new IllegalArgumentException("Original string may not be null");
    }
    if (allowed == null) {
        throw new IllegalArgumentException("Allowed bitset may not be null");
    }
    final byte[] rawdata = URLCodec.encodeUrl(allowed, EncodingUtil.getBytes(original, charset));
    return EncodingUtil.getAsciiString(rawdata).toCharArray();
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:57,代码来源:URI.java

示例13: encode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Escape and encode a given string with allowed characters not to be
 * escaped and a given charset.
 *
 * @param unescaped a string
 * @param allowed allowed characters not to be escaped
 * @param charset the charset
 * @return the escaped string
 */
public static String encode(String unescaped, BitSet allowed,
        String charset) throws URIException {
    byte[] rawdata = URLCodec.encodeUrl(allowed, 
        EncodingUtils.getBytes(unescaped, charset));
    return EncodingUtils.getAsciiString(rawdata);
}
 
开发者ID:parisbutterfield,项目名称:alexa-stocks,代码行数:16,代码来源:URIUtils.java

示例14: encode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Escape and encode a given string with allowed characters not to be
 * escaped and a given charset.
 *
 * @param unescaped a string
 * @param allowed   allowed characters not to be escaped
 * @param charset   the charset
 * @return the escaped string
 */
public static String encode(String unescaped, BitSet allowed,
        String charset) throws HttpException {
    byte[] rawdata = URLCodec.encodeUrl(allowed,
            EncodingUtils.getBytes(unescaped, charset));
    return EncodingUtils.getAsciiString(rawdata);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:16,代码来源:URIUtil.java

示例15: encode

import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
 * Encodes URI string.
 * <p/>
 * This is a two mapping, one from original characters to octets, and
 * subsequently a second from octets to URI characters:
 * <p><blockquote><pre>
 *   original character sequence->octet sequence->URI character sequence
 * </pre></blockquote><p>
 * <p/>
 * An escaped octet is encoded as a character triplet, consisting of the
 * percent character "%" followed by the two hexadecimal digits
 * representing the octet code. For example, "%20" is the escaped
 * encoding for the US-ASCII space character.
 * <p/>
 * Conversion from the local filesystem character set to UTF-8 will
 * normally involve a two step process. First convert the local character
 * set to the UCS; then convert the UCS to UTF-8.
 * The first step in the process can be performed by maintaining a mapping
 * table that includes the local character set code and the corresponding
 * UCS code.
 * The next step is to convert the UCS character code to the UTF-8 encoding.
 * <p/>
 * Mapping between vendor codepages can be done in a very similar manner
 * as described above.
 * <p/>
 * The only time escape encodings can allowedly be made is when a URI is
 * being created from its component parts.  The escape and validate methods
 * are internally performed within this method.
 *
 * @param original the original character sequence
 * @param allowed  those characters that are allowed within a component
 * @param charset  the protocol charset
 * @return URI character sequence
 * @throws HttpException null component or unsupported character encoding
 */

protected static char[] encode(String original, BitSet allowed,
        String charset) throws HttpException {
    if (original == null) {
        throw new IllegalArgumentException("Original string may not be null");
    }
    if (allowed == null) {
        throw new IllegalArgumentException("Allowed bitset may not be null");
    }
    byte[] rawdata = URLCodec.encodeUrl(allowed, EncodingUtils.getBytes(original, charset));
    return EncodingUtils.getAsciiString(rawdata).toCharArray();
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:48,代码来源:URI.java


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