Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

TupleSerialMarshalledBinding.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2000-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: TupleSerialMarshalledBinding.java,v 12.1 2005/01/31 19:27:30 mark Exp $
00008  */
00009 
00010 package com.sleepycat.bind.serial;
00011 
00012 import com.sleepycat.bind.tuple.MarshalledTupleKeyEntity;
00013 import com.sleepycat.bind.tuple.TupleInput;
00014 import com.sleepycat.bind.tuple.TupleOutput;
00015 
00032 public class TupleSerialMarshalledBinding extends TupleSerialBinding {
00033 
00044     public TupleSerialMarshalledBinding(ClassCatalog classCatalog,
00045                                         Class baseClass) {
00046 
00047         this(new SerialBinding(classCatalog, baseClass));
00048     }
00049 
00056     public TupleSerialMarshalledBinding(SerialBinding dataBinding) {
00057 
00058         super(dataBinding);
00059     }
00060 
00061     // javadoc is inherited
00062     public Object entryToObject(TupleInput tupleInput, Object javaInput) {
00063 
00064         /* Creates the entity by combining the stored key and data.
00065          * This "tricky" binding returns the stored data as the entity, but
00066          * first it sets the transient key fields from the stored key.
00067          */
00068         MarshalledTupleKeyEntity entity = (MarshalledTupleKeyEntity) javaInput;
00069 
00070         if (tupleInput != null) { // may be null if not used by key extractor
00071             entity.unmarshalPrimaryKey(tupleInput);
00072         }
00073         return entity;
00074     }
00075 
00076     // javadoc is inherited
00077     public void objectToKey(Object object, TupleOutput output) {
00078 
00079         /* Creates the stored key from the entity.
00080          */
00081         MarshalledTupleKeyEntity entity = (MarshalledTupleKeyEntity) object;
00082         entity.marshalPrimaryKey(output);
00083     }
00084 
00085     // javadoc is inherited
00086     public Object objectToData(Object object) {
00087 
00088         /* Returns the entity as the stored data.  There is nothing to do here
00089          * since the entity's key fields are transient.
00090          */
00091         return object;
00092     }
00093 }

Generated on Sun Dec 25 12:14:30 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2