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


Java EncoderException类代码示例

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


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

示例1: request

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
@Override
public void request(String[] fillArray) {
    for (int i = 0; i < fillArray.length; i++) {
        byte[] rnd = drbg.nextBytes(length);

        if (crc32) {
            rnd = Bytes.wrap(rnd).transform(new ByteUtils.Crc32AppenderTransformer()).array();
        }

        String randomEncodedString = padding ? encoder.encodePadded(rnd) : encoder.encode(rnd);

        if (urlencode) {
            try {
                randomEncodedString = new URLCodec().encode(randomEncodedString);
            } catch (EncoderException e) {
                throw new IllegalStateException("could not url encode", e);
            }
        }
        fillArray[i] = randomEncodedString;
    }
}
 
开发者ID:patrickfav,项目名称:dice,代码行数:22,代码来源:ColumnRenderer.java

示例2: encode

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
/**
 * Converts a String or an array of bytes into an array of characters representing the hexadecimal values of each
 * byte in order. The returned array will be double the length of the passed String or array, as it takes two
 * characters to represent any given byte.
 * <p>
 * The conversion from hexadecimal characters to bytes to be encoded to performed with the charset named by
 * {@link #getCharset()}.
 * </p>
 *
 * @param object
 *            a String, ByteBuffer, or byte[] to convert to Hex characters
 * @return A char[] containing lower-case hexadecimal characters
 * @throws EncoderException
 *             Thrown if the given object is not a String or byte[]
 * @see #encodeHex(byte[])
 */
@Override
public Object encode(final Object object) throws EncoderException {
    byte[] byteArray;
    if (object instanceof String) {
        byteArray = ((String) object).getBytes(this.getCharset());
    } else if (object instanceof ByteBuffer) {
        byteArray = ((ByteBuffer) object).array();
    } else {
        try {
            byteArray = (byte[]) object;
        } catch (final ClassCastException e) {
            throw new EncoderException(e.getMessage(), e);
        }
    }
    return encodeHex(byteArray);
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:33,代码来源:Hex.java

示例3: encodeText

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
/**
 * Applies an RFC 1522 compliant encoding scheme to the given string of text with the given charset.
 * <p>
 * This method constructs the "encoded-word" header common to all the RFC 1522 codecs and then invokes
 * {@link #doEncoding(byte [])} method of a concrete class to perform the specific encoding.
 *
 * @param text
 *            a string to encode
 * @param charset
 *            a charset to be used
 * @return RFC 1522 compliant "encoded-word"
 * @throws EncoderException
 *             thrown if there is an error condition during the Encoding process.
 * @see <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
 */
protected String encodeText(final String text, final Charset charset) throws EncoderException {
    if (text == null) {
        return null;
    }
    final StringBuilder buffer = new StringBuilder();
    buffer.append(PREFIX);
    buffer.append(charset);
    buffer.append(SEP);
    buffer.append(this.getEncoding());
    buffer.append(SEP);
    final byte [] rawData = this.doEncoding(text.getBytes(charset));
    buffer.append(StringUtils.newStringUsAscii(rawData));
    buffer.append(POSTFIX);
    return buffer.toString();
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:31,代码来源:RFC1522Codec.java

示例4: encode

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
/***
 * Encodes an object into its quoted-printable safe form. Unsafe characters are escaped.
 *
 * @param pObject
 *                  string to convert to a quoted-printable form
 * @return quoted-printable object
 * @throws EncoderException
 *                  Thrown if quoted-printable 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 quoted-printable encoded");
    }
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:24,代码来源:QuotedPrintableCodec.java

示例5: encode

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
@Override
public String encode(String str) throws EncoderException {
    if (str == null) return null;
    String[] s = code(str.toString());
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length; i++) {
        sb.append(s[i]);
        if (i < s.length - 1) {
            sb.append('_');
        }
    }
    return sb.toString();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:KoelnerPhonetik.java

示例6: encode

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
@NonNull
@Override
public String encode(@NonNull String text) {
    setMax(1);
    setConfident(1);
    org.apache.commons.codec.net.URLCodec urlCodec = new org.apache.commons.codec.net.URLCodec();
    try {
        return urlCodec.encode(text);
    } catch (EncoderException e) {
        setConfident(0);
        e.printStackTrace();
        return text;
    }
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:15,代码来源:URLCodec.java

示例7: getTransactions

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
public Transactions getTransactions(Long fromCommitTime, Long minTxnId, Long toCommitTime, Long maxTxnId, int maxResults) throws AuthenticationException, IOException, JSONException
{
    try
    {
        return getTransactions(fromCommitTime, minTxnId, toCommitTime, maxTxnId, maxResults, null);
    }
    catch (EncoderException e)
    {
        // Can not happen ....
        throw new IOException(e);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-solrclient,代码行数:13,代码来源:SOLRAPIClient.java

示例8: getTransactions

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
public Transactions getTransactions(Long fromCommitTime, Long minTxnId, Long toCommitTime, Long maxTxnId, int maxResults) throws AuthenticationException, IOException, JSONException
{
    if(throwException) {
        throw new ConnectException("THROWING EXCEPTION, better be ready!");
    }
    try
    {
        return getTransactions(fromCommitTime, minTxnId, toCommitTime, maxTxnId, maxResults, null);
    }
    catch(EncoderException e)
    {
        throw new IOException(e);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-solrclient,代码行数:15,代码来源:SOLRAPIQueueClient.java

示例9: convert

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
public String convert(String value) {
    if (value == null) {
        return null;
    }
    try {
        String s = codec.encode(value);
        if (s.contains("+")) {
            s = s.replaceAll("\\+", "%20");
        }
        log.debug("** [" + value + "]->[" + s + "]");
        return s;
    } catch (EncoderException e) {
        throw new IllegalArgumentException("illegal value: [" + value + "]", e);
    }
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:16,代码来源:UrlBuilder.java

示例10: encode

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
/**
 * Encodes an object into its quoted-printable form using the default charset. Unsafe characters are escaped.
 *
 * @param obj
 *            object to convert to quoted-printable form
 * @return quoted-printable object
 * @throws EncoderException
 *             thrown if a failure condition is encountered during the encoding process.
 */
@Override
public Object encode(final Object obj) throws EncoderException {
    if (obj == null) {
        return null;
    } else if (obj instanceof String) {
        return encode((String) obj);
    } else {
        throw new EncoderException("Objects of type " +
              obj.getClass().getName() +
              " cannot be encoded using Q codec");
    }
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:22,代码来源:QCodec.java

示例11: encode

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
/**
 * Encodes an object into its quoted-printable safe form. Unsafe characters are escaped.
 *
 * @param obj
 *            string to convert to a quoted-printable form
 * @return quoted-printable object
 * @throws EncoderException
 *             Thrown if quoted-printable encoding is not applicable to objects of this type or if encoding is
 *             unsuccessful
 */
@Override
public Object encode(final Object obj) throws EncoderException {
    if (obj == null) {
        return null;
    } else if (obj instanceof byte[]) {
        return encode((byte[]) obj);
    } else if (obj instanceof String) {
        return encode((String) obj);
    } else {
        throw new EncoderException("Objects of type " +
              obj.getClass().getName() +
              " cannot be quoted-printable encoded");
    }
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:25,代码来源:QuotedPrintableCodec.java

示例12: encode

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
/**
 * Encodes a string into its URL safe form using the default string charset. Unsafe characters are escaped.
 *
 * @param str
 *            string to convert to a URL safe form
 * @return URL safe string
 * @throws EncoderException
 *             Thrown if URL encoding is unsuccessful
 *
 * @see #getDefaultCharset()
 */
@Override
public String encode(final String str) throws EncoderException {
    if (str == null) {
        return null;
    }
    try {
        return encode(str, getDefaultCharset());
    } catch (final UnsupportedEncodingException e) {
        throw new EncoderException(e.getMessage(), e);
    }
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:23,代码来源:URLCodec.java

示例13: encode

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
/**
 * Encodes an object into its Base64 form using the default charset. Unsafe characters are escaped.
 *
 * @param value
 *            object to convert to Base64 form
 * @return Base64 object
 * @throws EncoderException
 *             thrown if a failure condition is encountered during the encoding process.
 */
@Override
public Object encode(final Object value) throws EncoderException {
    if (value == null) {
        return null;
    } else if (value instanceof String) {
        return encode((String) value);
    } else {
        throw new EncoderException("Objects of type " +
              value.getClass().getName() +
              " cannot be encoded using BCodec");
    }
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:22,代码来源:BCodec.java

示例14: encode

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
@Override
public Object encode(final Object object) throws EncoderException {
    if (!(object instanceof String)) {
        throw new EncoderException("This method's parameter was expected to be of the type " +
            String.class.getName() +
            ". But actually it was of the type " +
            object.getClass().getName() +
            ".");
    }
    return encode((String) object);
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:12,代码来源:ColognePhonetic.java

示例15: encode

import org.apache.commons.codec.EncoderException; //导入依赖的package包/类
@Override
public Object encode(final Object source) throws EncoderException {
    if (!(source instanceof String)) {
        throw new EncoderException("BeiderMorseEncoder encode parameter is not of type String");
    }
    return encode((String) source);
}
 
开发者ID:HTBridge,项目名称:pivaa,代码行数:8,代码来源:BeiderMorseEncoder.java


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