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

BooleanBinding.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: BooleanBinding.java,v 12.2 2005/08/01 20:25:10 mark Exp $
00008  */
00009 
00010 package com.sleepycat.bind.tuple;
00011 
00012 import com.sleepycat.db.DatabaseEntry;
00013 
00029 public class BooleanBinding extends TupleBinding {
00030 
00031     private static final int BOOLEAN_SIZE = 1;
00032 
00033     // javadoc is inherited
00034     public Object entryToObject(TupleInput input) {
00035 
00036         return input.readBoolean() ? Boolean.TRUE : Boolean.FALSE;
00037     }
00038 
00039     // javadoc is inherited
00040     public void objectToEntry(Object object, TupleOutput output) {
00041 
00042         output.writeBoolean(((Boolean) object).booleanValue());
00043     }
00044 
00045     // javadoc is inherited
00046     protected TupleOutput getTupleOutput(Object object) {
00047 
00048         return sizedOutput();
00049     }
00050 
00058     public static boolean entryToBoolean(DatabaseEntry entry) {
00059 
00060         return entryToInput(entry).readBoolean();
00061     }
00062 
00070     public static void booleanToEntry(boolean val, DatabaseEntry entry) {
00071 
00072         outputToEntry(sizedOutput().writeBoolean(val), entry);
00073     }
00074 
00079     private static TupleOutput sizedOutput() {
00080 
00081         return new TupleOutput(new byte[BOOLEAN_SIZE]);
00082     }
00083 }

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