Package org.apache.commons.codec

Examples of org.apache.commons.codec.DecoderException


                try {
                    final int u = Utils.digit16(bytes[++i]);
                    final int l = Utils.digit16(bytes[++i]);
                    buffer.write((char) ((u << 4) + l));
                } catch (final ArrayIndexOutOfBoundsException e) {
                    throw new DecoderException("Invalid URL encoding: ", e);
                }
            } else {
                buffer.write(b);
            }
        }
View Full Code Here


            return null;
        }
        try {
            return decode(str, getDefaultCharset());
        } catch (final UnsupportedEncodingException e) {
            throw new DecoderException(e.getMessage(), e);
        }
    }
View Full Code Here

        } else if (obj instanceof byte[]) {
            return decode((byte[]) obj);
        } else if (obj instanceof String) {
            return decode((String) obj);
        } else {
            throw new DecoderException("Objects of type " + obj.getClass().getName() + " cannot be URL decoded");

        }
    }
View Full Code Here

            throws DecoderException, UnsupportedEncodingException {
        if (text == null) {
            return null;
        }
        if (!text.startsWith(PREFIX) || !text.endsWith(POSTFIX)) {
            throw new DecoderException("RFC 1522 violation: malformed encoded content");
        }
        final int terminator = text.length() - 2;
        int from = 2;
        int to = text.indexOf(SEP, from);
        if (to == terminator) {
            throw new DecoderException("RFC 1522 violation: charset token not found");
        }
        final String charset = text.substring(from, to);
        if (charset.equals("")) {
            throw new DecoderException("RFC 1522 violation: charset not specified");
        }
        from = to + 1;
        to = text.indexOf(SEP, from);
        if (to == terminator) {
            throw new DecoderException("RFC 1522 violation: encoding token not found");
        }
        final String encoding = text.substring(from, to);
        if (!getEncoding().equalsIgnoreCase(encoding)) {
            throw new DecoderException("This codec cannot decode " + encoding + " encoded content");
        }
        from = to + 1;
        to = text.indexOf(SEP, from);
        byte[] data = StringUtils.getBytesUsAscii(text.substring(from, to));
        data = doDecoding(data);
View Full Code Here

    public Object decode(Object pObject) throws DecoderException {

        Object result;

        if (!(pObject instanceof byte[])) {
            throw new DecoderException("Parameter supplied to Base64 decode is not a byte[]");
        } else {
            result = decode((byte[]) pObject);
        }

        return result;
View Full Code Here

            } else if (b == '%') {
                try {
                    int u = Character.digit((char)pArray[++i], 16);
                    int l = Character.digit((char)pArray[++i], 16);
                    if (u == -1 || l == -1) {
                        throw new DecoderException("Invalid URL encoding");
                    }
                    buffer.write((char)((u << 4) + l));
                } catch(ArrayIndexOutOfBoundsException e) {
                    throw new DecoderException("Invalid URL encoding");
                }
            } else {
                buffer.write(b);
            }
        }
View Full Code Here

            return null;
        }
        try {
            return new String(decode(pString.getBytes(this.getEncoding())));
        } catch(UnsupportedEncodingException e) {
            throw new DecoderException(e.getMessage());
        }
    }
View Full Code Here

        } else if (pObject instanceof byte[]) {
            return decode((byte[])pObject);
        } else if (pObject instanceof String) {
            return decode((String)pObject);
        } else {
            throw new DecoderException("Objects of type " +
                pObject.getClass().getName() + " cannot be URL decoded");
             
        }
    }
View Full Code Here

    public Object decode(Object pObject) throws DecoderException {

        Object result;

        if (!(pObject instanceof byte[])) {
            throw new DecoderException(
                "Parameter supplied to "
                    + "Base64 "
                    + "decode is not a byte[]");
        }
        else {
View Full Code Here

    public byte[] decode(byte[] pArray) throws DecoderException {

        byte[] result;

        if (!isArrayByteBase64(pArray)) {
            throw new DecoderException(
                "Parameter supplied to "
                    + "Base64 "
                    + "decode is not a valid base64 data.");
        }
        else {
View Full Code Here

TOP

Related Classes of org.apache.commons.codec.DecoderException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.