All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.persistit.encoding.ValueRenderer Maven / Gradle / Ivy

There is a newer version: 3.3.0
Show newest version
/**
 * Copyright © 2005-2012 Akiban Technologies, Inc.  All rights reserved.
 * 
 * This program and the accompanying materials are made available
 * under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * This program may also be available under different license terms.
 * For more information, see www.akiban.com or contact [email protected].
 * 
 * Contributors:
 * Akiban Technologies, Inc.
 */

package com.persistit.encoding;

import com.persistit.Value;
import com.persistit.exception.ConversionException;

/**
 * 

* An extended {@link ValueCoder} that can populate a supplied * Object with data that was formerly written to a {@link Value} by * the ValueCoder. *

*

* A ValueRenderer implements an additional method called * {@link #render} that populates a supplied target object rather than creating * a new object instance. The application provides the mutable target object to * {@link Value#get(Object)}. *

*

* A ValueRenderer can implement an application-level contract to * recover a limited set of fields from an encoded Value or to * populate a generic target object that might be suitable for utility display * purposes. For example, suppose there is a complex Person class * with many fields that refer to other objects. Deserializing and populating * all the fields of such a Person object might not be appropriate * in an area of the application that merely needs to display a list of names. * To avoid completely deserializing numerous Person objects, the * application could register a ValueRenderer implementation that * knows how to decode a serialized Person into a * PersonListData object. To do so it would {@link Value#get} the * desired interior fields of the encoded Person and * {@link Value#skip} the other fields. *

* * * @version 1.0 */ public interface ValueRenderer extends ValueCoder { /** *

* Populates the state of the supplied (mutable) target Object * by decoding the supplied Value. This method will be called * only if this ValueRenderer has been registered with the * current {@link CoderManager} to encode objects having the supplied * Class value. Persistit will never call this method to decode * a value that was null when written because null values are * handled by built-in encoding logic. *

* * @param value * The Value from which interior fields of the * object are to be retrieved * * @param target * The object into which the decoded value is to be written * * @param clazz * The class of the object that was originally encoded into * Value. * * @param context * An arbitrary object that can optionally be supplied by the * application to convey an application-specific context for the * operation. (See {@link CoderContext}.) The default value is * null. * * @throws ConversionException */ public void render(Value value, Object target, Class clazz, CoderContext context) throws ConversionException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy