01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: ShipmentKey.java,v 1.14.2.2 2008/01/07 15:14:01 cwl Exp $
07: */
08:
09: 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 partNumber;
27: private String supplierNumber;
28:
29: public ShipmentKey(String partNumber, String supplierNumber) {
30:
31: this .partNumber = partNumber;
32: this .supplierNumber = supplierNumber;
33: }
34:
35: public final String getPartNumber() {
36:
37: return partNumber;
38: }
39:
40: public final String getSupplierNumber() {
41:
42: return supplierNumber;
43: }
44:
45: public String toString() {
46:
47: return "[ShipmentKey: supplier=" + supplierNumber + " part="
48: + 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: }
|