/*- * See the file LICENSE for redistribution information. * * Copyright (c) 2002-2003 * Sleepycat Software. All rights reserved. * * $Id: ShipmentKey.java,v 1.2 2004/03/30 01:23:21 jtownsen Exp $ */ package com.sleepycat.examples.bdb.shipment.factory; import com.sleepycat.bdb.bind.tuple.MarshalledTupleData; import com.sleepycat.bdb.bind.tuple.TupleInput; import com.sleepycat.bdb.bind.tuple.TupleOutput; import java.io.IOException; /** * A ShipmentKey serves as the key in the key/value pair for a shipment entity. * *

In this sample, ShipmentKey is bound to the stored key tuple data by * implementing the MarshalledTupleData interface, which is called by {@link * SampleViews.MarshalledKeyBinding}.

* * @author Mark Hayes */ public class ShipmentKey implements MarshalledTupleData { private String partNumber; private String supplierNumber; public ShipmentKey(String partNumber, String supplierNumber) { this.partNumber = partNumber; this.supplierNumber = supplierNumber; } public final String getPartNumber() { return partNumber; } public final String getSupplierNumber() { return supplierNumber; } public String toString() { return "[ShipmentKey: supplier=" + supplierNumber + " part=" + partNumber + ']'; } // --- MarshalledTupleData implementation --- public ShipmentKey() { // A no-argument constructor is necessary only to allow the binding to // instantiate objects of this class. } public void marshalData(TupleOutput keyOutput) throws IOException { keyOutput.writeString(this.partNumber); keyOutput.writeString(this.supplierNumber); } public void unmarshalData(TupleInput keyInput) throws IOException { this.partNumber = keyInput.readString(); this.supplierNumber = keyInput.readString(); } }