KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > collections > ship > factory > ShipmentKey


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: ShipmentKey.java,v 1.14 2006/10/30 21:13:59 bostic Exp $
7  */

8
9 package collections.ship.factory;
10
11 import com.sleepycat.bind.tuple.MarshalledTupleEntry;
12 import com.sleepycat.bind.tuple.TupleInput;
13 import com.sleepycat.bind.tuple.TupleOutput;
14
15 /**
16  * A ShipmentKey serves as the key in the key/data pair for a shipment entity.
17  *
18  * <p> In this sample, ShipmentKey is bound to the stored key tuple entry by
19  * implementing the MarshalledTupleEntry interface, which is called by {@link
20  * SampleViews.MarshalledKeyBinding}. </p>
21  *
22  * @author Mark Hayes
23  */

24 public class ShipmentKey implements MarshalledTupleEntry {
25
26     private String JavaDoc partNumber;
27     private String JavaDoc supplierNumber;
28
29     public ShipmentKey(String JavaDoc partNumber, String JavaDoc supplierNumber) {
30
31         this.partNumber = partNumber;
32         this.supplierNumber = supplierNumber;
33     }
34
35     public final String JavaDoc getPartNumber() {
36
37         return partNumber;
38     }
39
40     public final String JavaDoc getSupplierNumber() {
41
42         return supplierNumber;
43     }
44
45     public String JavaDoc toString() {
46
47         return "[ShipmentKey: supplier=" + supplierNumber +
48                 " part=" + partNumber + ']';
49     }
50
51     // --- MarshalledTupleEntry implementation ---
52

53     public ShipmentKey() {
54
55         // A no-argument constructor is necessary only to allow the binding to
56
// instantiate objects of this class.
57
}
58
59     public void marshalEntry(TupleOutput keyOutput) {
60
61         keyOutput.writeString(this.partNumber);
62         keyOutput.writeString(this.supplierNumber);
63     }
64
65     public void unmarshalEntry(TupleInput keyInput) {
66
67         this.partNumber = keyInput.readString();
68         this.supplierNumber = keyInput.readString();
69     }
70 }
71
Popular Tags