Package com.persistit.exception

Examples of com.persistit.exception.ConversionException


    private int quoteNulls(final int index, int size, final boolean zeroByteFree) {
        for (int i = index; i < index + size; i++) {
            final int c = _bytes[i] & 0xFF;
            if (zeroByteFree) {
                if (c == 0) {
                    throw new ConversionException("NUL found in encoded Key");
                }
            } else {
                if (c == 0 || c == 1) {
                    System.arraycopy(_bytes, i + 1, _bytes, i + 2, _size - i - 1);
                    _bytes[i] = 1;
View Full Code Here


    private void decodeBigInteger(final BigIntegerStruct bis) {
        final int start = _index;
        final int signum = (_bytes[_index++] & 0xFF) - 0x40;
        if (signum < -1 || signum > 1) {
            throw new ConversionException("Invalid BigInteger signum at offset " + (start));
        }
        if (signum == 0) {
            bis._bigInteger = BigInteger.ZERO;
            bis._scale = 0;
            return;
        }
        final boolean neg = signum < 0;
        //
        // Decode the exponent
        //
        int exp = decodeIntInternal();
        if (neg)
            exp = -exp;
        //
        // Reset the fields of the BigIntegerStruct
        //
        bis._bigInteger = null;
        bis._scale = 0;
        bis._zeroCount = 0;

        boolean done = false;
        int lastDigit = 0;
        boolean leftOverDigit = false;
        boolean lastDigitZero = false;
        int zeroCount = 0;
        while (!done) {
            long lowBits = leftOverDigit ? lastDigit : 0;
            //
            // Number of digits that will be accumulated in lowBits before
            // adding to the accumulator.
            //
            int chunk = 0;
            if (exp > 0) {
                chunk = exp % 16;
                if (chunk == 0)
                    chunk = 16;
            } else {
                chunk = 16;
            }
            exp -= chunk;
            if (leftOverDigit)
                chunk--;
            boolean dontAccumulate = false;
            while (chunk > 0 && !done) {
                int b = _bytes[_index++] & 0xFF;
                if (b == 0) {
                    done = true;
                    _index--;
                    if (chunk >= 15 && exp == -16 && lowBits == 0) {
                        exp += 16;
                        dontAccumulate = true;
                    } else {
                        if (leftOverDigit)
                            lastDigitZero = (lastDigit == 0);
                        if (lastDigitZero)
                            zeroCount++;
                        for (; --chunk >= 0;) {
                            zeroCount++;
                            lowBits *= 10;
                        }
                    }
                } else if (b != 0xFF) {
                    if (neg)
                        b = 0xAA - b;
                    else
                        b = b - 0x11;
                    if (((b >>> 4) & 0x0F) > 9 || (b & 0x0F) > 9) {
                        throw new ConversionException("Invalid BigInteger encoding at index " + (_index - 1));
                    }
                    if (chunk == 1) {
                        final int digit = (b >>> 4) & 0x0F;
                        lowBits = lowBits * 10 + digit;
                        lastDigit = b & 0x0F;
View Full Code Here

                            final String name = osFields[index].getName();
                            try {
                                field = clientClass.getDeclaredField(name);
                                list.add(field);
                            } catch (final NoSuchFieldException nsfe) {
                                throw new ConversionException(clientClass + " unmatched serializable field '" + name
                                        + "' declared");
                            }
                        }
                    } else {
                        final Field[] fields = clientClass.getDeclaredFields();
View Full Code Here

        _serializable = Serializable.class.isAssignableFrom(clientClass);
        if (_serializable) {
            _externalizable = Externalizable.class.isAssignableFrom(clientClass);
            _classDescriptor = ObjectStreamClass.lookup(_clazz);
        } else if (mustBeSerializable) {
            throw new ConversionException("Not Serializable: " + clientClass.getName());
        }

        final Class superClass = clientClass.getSuperclass();
        if (superClass != null && Serializable.class.isAssignableFrom(superClass)) {
            ValueCoder coder = null;
View Full Code Here

                    try {
                        constructor = _clazz.getDeclaredConstructor(EMPTY_CLASS_ARRAY);
                    } catch (final NoSuchMethodException nsme) {
                    }
                    if (_externalizable && (constructor == null || !Modifier.isPublic(constructor.getModifiers()))) {
                        throw new ConversionException("Externalizable class " + _clazz.getName()
                                + " requires a public no-argument constructor");
                    } else if (constructor == null) {
                        throw new ConversionException("Class " + _clazz.getName()
                                + " requires a no-argument constructor");
                    }
                    constructor.setAccessible(true);
                    _newInstanceConstructor = constructor;
                } else {
View Full Code Here

        }
        if (object instanceof Externalizable) {
            try {
                ((Externalizable) object).writeExternal(value.getObjectOutputStream());
            } catch (final Exception e) {
                throw new ConversionException("Invoking writeExternal for " + _clazz, e);
            }
        } else if (_writeObjectMethod != null) {
            invokeMethod(value, _writeObjectMethod, object, new Object[] { value.getObjectOutputStream() }, true);
        } else {
            putDefaultFields(value, object);
View Full Code Here

        value.setCurrentObject(setStackFields ? object : null);
        try {
            final Object result = method.invoke(object, args);
            return result;
        } catch (final Exception e) {
            throw new ConversionException("Invoking " + method + " for " + _clazz, e);
        } finally {
            value.setCurrentCoder(saveCoder);
            value.setCurrentObject(saveObject);
        }
    }
View Full Code Here

            final boolean setStackFields) throws ConversionException {
        try {
            final Object result = method.invoke(object, args);
            return result;
        } catch (final Exception e) {
            throw new ConversionException("Invoking " + method + " for " + _clazz, e);
        }
    }
View Full Code Here

                return _newInstanceMethod.invoke(_classDescriptor, _newInstanceArguments);
            } else {
                return _clazz.newInstance();
            }
        } catch (final Exception e) {
            throw new ConversionException("Instantiating " + _clazz.getName(), e);

        }
    }
View Full Code Here

            for (int index = 0; index < accessors.length; index++) {
                accessor = accessors[index];
                accessors[index].toValue(object, value);
            }
        } catch (final Exception e) {
            throw new ConversionException("Encoding " + accessor.toString() + " for " + _clazz, e);
        }
    }
View Full Code Here

TOP

Related Classes of com.persistit.exception.ConversionException

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.