當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。