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

Shipment.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2002-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: Shipment.java,v 12.2 2005/06/16 20:22:32 bostic Exp $
00008  */
00009 
00010 package collections.ship.factory;
00011 
00012 import java.io.Serializable;
00013 
00014 import com.sleepycat.bind.tuple.MarshalledTupleKeyEntity;
00015 import com.sleepycat.bind.tuple.TupleInput;
00016 import com.sleepycat.bind.tuple.TupleOutput;
00017 
00034 public class Shipment implements Serializable, MarshalledTupleKeyEntity {
00035 
00036     static final String PART_KEY = "part";
00037     static final String SUPPLIER_KEY = "supplier";
00038 
00039     private transient String partNumber;
00040     private transient String supplierNumber;
00041     private int quantity;
00042 
00043     public Shipment(String partNumber, String supplierNumber, int quantity) {
00044 
00045         this.partNumber = partNumber;
00046         this.supplierNumber = supplierNumber;
00047         this.quantity = quantity;
00048     }
00049 
00050     public final String getPartNumber() {
00051 
00052         return partNumber;
00053     }
00054 
00055     public final String getSupplierNumber() {
00056 
00057         return supplierNumber;
00058     }
00059 
00060     public final int getQuantity() {
00061 
00062         return quantity;
00063     }
00064 
00065     public String toString() {
00066 
00067         return "[Shipment: part=" + partNumber +
00068             " supplier=" + supplierNumber +
00069             " quantity=" + quantity + ']';
00070     }
00071 
00072     // --- MarshalledTupleKeyEntity implementation ---
00073 
00074     public void marshalPrimaryKey(TupleOutput keyOutput) {
00075 
00076         keyOutput.writeString(this.partNumber);
00077         keyOutput.writeString(this.supplierNumber);
00078     }
00079 
00080     public void unmarshalPrimaryKey(TupleInput keyInput) {
00081 
00082         this.partNumber = keyInput.readString();
00083         this.supplierNumber = keyInput.readString();
00084     }
00085 
00086     public boolean marshalSecondaryKey(String keyName, TupleOutput keyOutput) {
00087 
00088         if (keyName.equals(PART_KEY)) {
00089             keyOutput.writeString(this.partNumber);
00090             return true;
00091         } else if (keyName.equals(SUPPLIER_KEY)) {
00092             keyOutput.writeString(this.supplierNumber);
00093             return true;
00094         } else {
00095             throw new UnsupportedOperationException(keyName);
00096         }
00097     }
00098 
00099     public boolean nullifyForeignKey(String keyName) {
00100 
00101         throw new UnsupportedOperationException(keyName);
00102     }
00103 }

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