Package com.persistit.exception

Examples of com.persistit.exception.ConversionException


     */
    public BigDecimal decodeBigDecimal() {
        int index = _index;
        final int type = getTypeCode();
        if (type != TYPE_BIG_DECIMAL) {
            throw new ConversionException("Invalid String lead-in byte (" + type + ") at position " + _index
                    + " in key");
        }
        _index++;
        try {
            final BigIntegerStruct bis = new BigIntegerStruct();
View Full Code Here


    public byte[] decodeByteArray() {
        int index = _index;
        final int type = getTypeCode();
        try {
            if (type != TYPE_BYTE_ARRAY) {
                throw new ConversionException("Invalid String lead-in byte (" + type + ") at position " + _index
                        + " in key");
            }
            final int size = unquoteNulls(index + 1, false);
            final byte[] result = new byte[size];
            System.arraycopy(_bytes, index + 1, result, 0, size);
View Full Code Here

        if (type >= TYPE_CODER_MIN && type <= TYPE_CODER_MAX) {
            return decodeByKeyCoder(target, context);
        }

        throw new ConversionException("Invalid type " + type + " at index " + (index - 1));
    }
View Full Code Here

    private Key appendString(final CharSequence s, final CoderContext context) {
        notLeftOrRightGuard();
        testValidForAppend();
        final int strlen = s.length();
        if (strlen > _maxSize) {
            throw new ConversionException("Requested size=" + strlen + " exceeds maximum size=" + _maxSize);
        }
        int size = _size;
        _bytes[size++] = (byte) TYPE_STRING;

        for (int i = 0; i < strlen; i++) {
View Full Code Here

        boolean zeroByteFree = false;
        try {
            final int handle = decodeHandle();
            clazz = _persistit.classForHandle(handle);
            if (clazz == null) {
                throw new ConversionException("No class information for handle " + handle);
            }
            final KeyCoder coder = _persistit.lookupKeyCoder(clazz);
            if (coder == null) {
                throw new ConversionException("No KeyCoder for class " + clazz.getName());
            }
            zeroByteFree = coder.isZeroByteFree();
            segmentSize = unquoteNulls(index, zeroByteFree);
            size = _size;
            _size = index + segmentSize;
            unquoted = true;
            if (target == null) {
                return coder.decodeKeySegment(this, clazz, context);
            } else {
                if (coder instanceof KeyRenderer) {
                    ((KeyRenderer) coder).renderKeySegment(this, target, clazz, context);
                    return target;
                } else {
                    throw new ConversionException("No KeyRenderer for class " + clazz.getName());
                }
            }
        } finally {
            _size = size;
            if (unquoted) {
View Full Code Here

     */
    private Appendable decodeString(final boolean quoted, final Appendable sb) {
        int index = _index;
        int c1 = _bytes[index++] & 0xFF;
        if (c1 != TYPE_STRING) {
            throw new ConversionException("Invalid String lead-in byte (" + c1 + ") at position " + (index - 1)
                    + " in key");
        }

        while ((c1 = _bytes[index++] & 0xFF) != 0 && index <= _size) {
            char c = 0;
            // Handle encoded NUL and SOH bytes
            if (c1 == 0x01) {
                final int c2 = _bytes[index++] & 0xFF;
                if (c2 >= 0x0020 && c2 <= 0x0021) {
                    c = (char) (c2 - 0x0020);
                } else {
                    throw new ConversionException("String decoding exception at position " + (index - 1));
                }
            }

            // 7-bit ASCII
            else if (c1 <= 0x7F) {
                c = (char) c1;
            }

            else if (c1 > 0xC0 && c1 <= 0xDF) {
                final int c2 = _bytes[index++] & 0xFF;
                if (c2 >= 0x80 && c2 <= 0xBF) {
                    c = (char) (((c1 & 0x1F) << 6) | ((c2 & 0x3F) << 0));
                } else {
                    throw new ConversionException("String decoding exception at position " + (index - 1));
                }
            } else if (c1 >= 0xE0 && c1 <= 0xEF) {
                final int c2 = _bytes[index++] & 0xFF;
                final int c3 = _bytes[index++] & 0xFF;
                if (c2 >= 0x80 && c2 <= 0xBF && c3 >= 0x80 && c3 <= 0xBF) {
                    c = (char) (((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | ((c3 & 0x3F) << 0));
                }
            } else {
                throw new ConversionException("String decoding exception at position " + (index - 1));
            }
            if (quoted) {
                Util.appendQuotedChar(sb, c);
            } else {
                Util.append(sb, c);
View Full Code Here

            _index = index;
            return result + ClassIndex.HANDLE_BASE;

        default:
        }
        throw new ConversionException("Invalid KeyCoder handle at " + _index);
    }
View Full Code Here

        throw new ConversionException("Invalid KeyCoder handle at " + _index);
    }

    private int decodeEnd(final int index) {
        if (_bytes[index] != 0) {
            throw new ConversionException("Invalid end byte at " + (index + 1));
        }
        return index + 1;
    }
View Full Code Here

    }

    private Object decodeNull() {
        final int type = _bytes[_index] & 0xFF;
        if (type != TYPE_NULL)
            throw new ConversionException("Expected null type");
        _index = decodeEnd(_index + 1);
        return null;
    }
View Full Code Here

        if (type == TYPE_BEFORE) {
            v = BEFORE;
        } else if (type == TYPE_AFTER) {
            v = AFTER;
        } else {
            throw new ConversionException("Invalid BEFORE type " + type);
        }
        _index = decodeEnd(_index + 1);
        return v;
    }
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.