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

TupleBase.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: TupleBase.java,v 12.1 2005/08/01 20:25:15 mark Exp $
00008  */
00009 
00010 package com.sleepycat.bind.tuple;
00011 
00012 import com.sleepycat.db.DatabaseEntry;
00013 
00027 public class TupleBase {
00028 
00029     private int outputBufferSize;
00030 
00038     public TupleBase() {
00039         outputBufferSize = 0;
00040     }
00041 
00052     public void setTupleBufferSize(int byteSize) {
00053         outputBufferSize = byteSize;
00054     }
00055 
00063     public int getTupleBufferSize() {
00064         return outputBufferSize;
00065     }
00066 
00088     protected TupleOutput getTupleOutput(Object object) {
00089         int byteSize = getTupleBufferSize();
00090         if (byteSize != 0) {
00091             return new TupleOutput(new byte[byteSize]);
00092         } else {
00093             return new TupleOutput();
00094         }
00095     }
00096 
00105     public static void outputToEntry(TupleOutput output, DatabaseEntry entry) {
00106 
00107         entry.setData(output.getBufferBytes(), output.getBufferOffset(),
00108                       output.getBufferLength());
00109     }
00110 
00119     public static void inputToEntry(TupleInput input, DatabaseEntry entry) {
00120 
00121         entry.setData(input.getBufferBytes(), input.getBufferOffset(),
00122                       input.getBufferLength());
00123     }
00124 
00134     public static TupleInput entryToInput(DatabaseEntry entry) {
00135 
00136         return new TupleInput(entry.getData(), entry.getOffset(),
00137                               entry.getSize());
00138     }
00139 
00147     public static TupleOutput newOutput() {
00148 
00149         return new TupleOutput();
00150     }
00151 
00160     public static TupleOutput newOutput(byte[] buffer) {
00161 
00162         return new TupleOutput(buffer);
00163     }
00164 }

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