Package com.persistit.exception

Examples of com.persistit.exception.ConversionException


        boolean _innerClassDescriptor;

        OldValueOutputStream(final Value value, final ObjectStreamClass classDescriptor) throws IOException {
            this(value);
            if (classDescriptor == null) {
                throw new ConversionException("Null class descriptor");
            }
            _classDescriptor = classDescriptor;
        }
View Full Code Here


        }
        int newArraySize = ((newSize + SIZE_GRANULARITY - 1) / SIZE_GRANULARITY) * SIZE_GRANULARITY;
        if (newArraySize > _maximumSize)
            newArraySize = _maximumSize;
        if (newArraySize < newSize) {
            throw new ConversionException("Requested size=" + newSize + " exceeds maximum size=" + _maximumSize);
        }
        final byte[] bytes = new byte[newArraySize];
        System.arraycopy(_bytes, 0, bytes, 0, _size);
        _bytes = bytes;

View Full Code Here

            _next = start;
            final Object array = get(null, null);
            if (array == null || array instanceof DisplayMarker || array.getClass().isArray()) {
                appendDisplayable(sb, array, quoted, true);
            } else {
                throw new ConversionException("Referenced object is not an array");
            }
        } else {
            try {
                _depth++;
                final int componentClassHandle = nextType();
View Full Code Here

        }
        _next = start;
        final Object object = get(null, null);
        if (object == null)
            return null;
        throw new ConversionException("Expected null");
    }
View Full Code Here

            _depth++;
            try {
                final ObjectInputStream ois = new OldValueInputStream(this);
                object = ois.readObject();
                if (_next != _end) {
                    throw new ConversionException("Invalid serialized Object at index=" + _next);
                }
                closeVariableLengthItem();
            } catch (final IOException ioe) {
                throw new ConversionException("@" + start, ioe);
            } catch (final ClassNotFoundException cnfe) {
                throw new ConversionException("@" + start, cnfe);
            } finally {
                _depth--;
            }

            break;

        case CLASS_REREF: {
            final int base = _bytes[_next++] & 0xFF;
            final int handle = decodeVariableLengthInt(base);
            object = getValueCache().get(handle);
            break;
        }

        case TYPE_MVV: {
            final int savedSize = _size;
            final ArrayList<Object> outList = new ArrayList<Object>();

            try {
                _depth++;

                MVV.visitAllVersions(new MVV.VersionVisitor() {
                    @Override
                    public void init() {
                    }

                    @Override
                    public void sawVersion(final long version, final int offset, final int valueLength) {
                        Object obj = null;
                        if (valueLength > 0) {
                            _next = offset;
                            _end = _size = _next + valueLength;
                            obj = get(target, context);
                        }
                        outList.add(obj);
                    }

                }, getEncodedBytes(), 0, getEncodedSize());
            } catch (final PersistitException pe) {
                throw new ConversionException("@" + start, pe);
            } finally {
                _depth--;
                _next = _end = _size = savedSize;
            }

            return outList.toArray();
        }

        default: {
            final int saveDepth = _depth;
            try {
                _depth++;
                final Class<?> cl = _persistit.classForHandle(classHandle);
                final ValueCoder coder = getValueCoder(cl);

                if (coder != null) {
                    if (target == null) {
                        object = coder.get(this, cl, context);
                    }

                    else if (coder instanceof ValueRenderer) {
                        ((ValueRenderer) coder).render(this, target, cl, context);
                        object = target;
                    } else {
                        throw new ConversionException("No ValueRenderer for class " + cl.getName());
                    }
                } else {
                    throw new ConversionException("No ValueCoder for class " + cl.getName());
                }
            } finally {
                _depth = saveDepth;
            }
            closeVariableLengthItem();
View Full Code Here

    }

    private int arraySize(final int end, final int next, final int blockSize) {
        final int size = end - next;
        if ((size % blockSize) != 0) {
            throw new ConversionException("Invalid array size");
        }
        return size / blockSize;
    }
View Full Code Here

            case 12:
            case 13:
                /* 110x xxxx 10xx xxxx */
                i++;
                if (i >= _end) {
                    throw new ConversionException();
                }
                b2 = _bytes[i];
                if ((b2 & 0xC0) != 0x80) {
                    throw new ConversionException();
                }
                Util.append(sb, (char) (((b & 0x1F) << 6) | (b2 & 0x3F)));
                break;

            case 14:
                /* 1110 xxxx 10xx xxxx 10xx xxxx */
                i += 2;
                if (i >= _end) {
                    throw new ConversionException();
                }
                b2 = _bytes[i - 1];
                b3 = _bytes[i];
                if (((b2 & 0xC0) != 0x80) || ((b3 & 0xC0) != 0x80)) {
                    throw new ConversionException();
                }
                Util.append(sb, (char) (((b & 0x0F) << 12) | ((b2 & 0x3F) << 6) | ((b3 & 0x3F) << 0)));
                break;

            default:
                /* 10xx xxxx, 1111 xxxx */
                throw new ConversionException();
            }
        }
        return counter;
    }
View Full Code Here

    public Object getArray() {
        final Object object = get(null, null);
        if (object == null || object.getClass().isArray()) {
            return object;
        }
        throw new ConversionException("Expected an array but value is a " + object.getClass().getName());
    }
View Full Code Here

                        oos.close();
                        end = _size;
                    }
                }
            } catch (final IOException ioe) {
                throw new ConversionException(ioe);
            } finally {
                _depth--;
                //
                // Restores _size to original value in the event of an
                // exception.
View Full Code Here

        return _endArray[--_level];
    }

    private int type() {
        if (_next >= _end) {
            throw new ConversionException("No more data at index=" + _next + " end=" + _end);
        }
        return _bytes[_next] & 0xFF;
    }
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.