Package api.exceptions

Examples of api.exceptions.DecodingException


    }

    private <T> T tryDecode(InputStream data, Class<T> objClass) throws InstantiationException, IllegalAccessException, InvocationTargetException, DecodingException {
        int constructorCode = objClass.getAnnotation(Constructor.class).value();
        if(constructorCode != integerDecoder.decode(data)) {
            throw new DecodingException("Another object was received");
        }
        T obj = objClass.newInstance();
        Field[] fields = objClass.getDeclaredFields();
        for(Field field: fields) {
            Decoder decoder = lookupDecoder(field);
View Full Code Here


            if(firstByte == longStringMarker) {
                return read(stream);
            }
            return read(stream, firstByte);
        } catch (IOException e) {
            throw new DecodingException("Do not like InputStream interface for ugly checked exception");
        }
    }
View Full Code Here

        long messageId = longDecoedr.decode(data);
        int messageLength = intDecoder.decode(data);
        if(authKey == 0) {
            return nonEncryptedDecoder.decode(data, objClass);
        }
        throw new DecodingException("encryption is not supported");
    }
View Full Code Here

        try {
            stream.read(bytes);
            ArrayUtils.reverse(bytes); // little-endian to big one
            return new BigInteger(bytes);
        } catch (IOException e) {
            throw new DecodingException("Do not like InputStream interface for ugly checked exception");
        }
    }
View Full Code Here

    @Override
    public String decode(InputStream stream) throws DecodingException {
        try {
            return hexToString(DECODER.decode(stream));
        } catch (UnsupportedEncodingException e) {
            throw new DecodingException(e);
        }
    }
View Full Code Here

    @Override
    public <T> T decode(InputStream data, Class<T> objClass) throws DecodingException {
        try {
            return tryDecode(data, objClass);
        } catch (InstantiationException e) {
            throw new DecodingException("Construct failed", e);
        } catch (IllegalAccessException e) {
            throw new DecodingException("Construct failed", e);
        } catch (InvocationTargetException e) {
            throw new DecodingException("Decoding went wrong", e);
        }
    }
View Full Code Here

TOP

Related Classes of api.exceptions.DecodingException

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.