Package com.persistit.exception

Examples of com.persistit.exception.ConversionException


    private final ObjectStreamClass _classDescriptor;

    public SerialValueCoder(final Class<?> clazz) {
        _classDescriptor = ObjectStreamClass.lookup(clazz);
        if (_classDescriptor == null) {
            throw new ConversionException("Not Serializable: " + clazz.getName());
        }
    }
View Full Code Here


            final ObjectInputStream stream = value.oldValueInputStream(_classDescriptor);
            final Object object = stream.readObject();
            stream.close();
            return object;
        } catch (final Exception e) {
            throw new ConversionException(e);
        }
    }
View Full Code Here

        try {
            final ObjectOutputStream stream = value.oldValueOutputStream(_classDescriptor);
            stream.writeObject(object);
            stream.close();
        } catch (final Exception e) {
            throw new ConversionException(e);
        }
    }
View Full Code Here

        } else if (object instanceof Collection<?>) {
            for (final Iterator<?> iter = ((Collection<?>) object).iterator(); iter.hasNext();) {
                value.put(iter.next(), context);
            }
        } else {
            throw new ConversionException("CollectionValueCoder cannot encode an object of type "
                    + object.getClass().getName());
        }
    }
View Full Code Here

            final Object target = clazz.newInstance();
            value.registerEncodedObject(target);
            render(value, target, clazz, context);
            return target;
        } catch (final InstantiationException ce) {
            throw new ConversionException(ce + " while decoding a Collection value");
        } catch (final IllegalAccessException iae) {
            throw new ConversionException(iae + " while decoding a Collection value");
        }
    }
View Full Code Here

                    if (!value.hasMoreItems()) {
                        break;
                    }
                    final Object itemKey = value.get(null, context);
                    if (!value.hasMoreItems()) {
                        throw new ConversionException("Encoded Map entry has missing value");
                    }
                    final Object itemValue = value.get(null, context);
                    map.put(itemKey, itemValue);
                }
            } else
                throw new ConversionException("Cannot convert a " + clazz.getName() + " to a Map");
        } else if (target instanceof Collection) {
            if (Collection.class.isAssignableFrom(clazz)) {
                final Collection collection = (Collection) target;
                for (;;) {
                    if (!value.hasMoreItems()) {
                        break;
                    }
                    final Object itemValue = value.get(null, context);
                    collection.add(itemValue);
                }
            } else
                throw new ConversionException("Cannot convert " + clazz.getName() + " to a Collection");

        } else
            throw new ConversionException("CollectionValueCoder cannot render to an object of class "
                    + target.getClass().getName());
    }
View Full Code Here

                value.decodeDisplayable(true, target);
                target.append("->");

                if (!value.hasMoreItems()) {
                    throw new ConversionException("Encoded Map entry has missing value");
                }

                value.decodeDisplayable(true, target);
            }
            target.append(']');
        } else if (Collection.class.isAssignableFrom(clazz)) {
            target.append('[');
            boolean first = true;

            for (;;) {
                if (!value.hasMoreItems()) {
                    break;
                }

                if (first)
                    first = false;
                else
                    target.append(',');

                value.decodeDisplayable(true, target);
            }
            target.append(']');
        } else
            throw new ConversionException("Cannot display value that is neither a Map nor a Collection");
    }
View Full Code Here

            for (int index = 0; index < count; index++) {
                accessor = keyBuilder.getAccessor(index);
                accessor.toKey(object, key);
            }
        } catch (final Exception e) {
            throw new ConversionException("Encoding " + accessor.toString() + " for " + getClientClass(), e);
        }
    }
View Full Code Here

                    + " does not match requested class " + clazz.getName());
        Object instance;
        try {
            instance = getClientClass().newInstance();
        } catch (final Exception e) {
            throw new ConversionException("Unable to instantiate an instance of " + getClientClass(), e);

        }
        renderKeySegment(key, instance, clazz, context);

        return readResolve(instance);
View Full Code Here

            for (int index = 0; index < count; index++) {
                accessor = _keyBuilder.getAccessor(index);
                accessor.fromKey(target, key);
            }
        } catch (final Exception e) {
            throw new ConversionException("Decoding " + accessor.toString() + " for " + getClientClass(), 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.