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.12.2.2 2008/01/07 15:14:02 cwl Exp $
07: */
08:
09: package collections.ship.marshal;
10:
11: import com.sleepycat.bind.tuple.TupleInput;
12: import com.sleepycat.bind.tuple.TupleOutput;
13:
14: /**
15: * A ShipmentKey serves as the key in the key/data pair for a shipment entity.
16: *
17: * <p> In this sample, ShipmentKey is bound to the stored key tuple entry by
18: * implementing the MarshalledKey interface, which is called by {@link
19: * SampleViews.MarshalledKeyBinding}. </p>
20: *
21: * @author Mark Hayes
22: */
23: public class ShipmentKey implements MarshalledKey {
24:
25: private String partNumber;
26: private String supplierNumber;
27:
28: public ShipmentKey(String partNumber, String supplierNumber) {
29:
30: this .partNumber = partNumber;
31: this .supplierNumber = supplierNumber;
32: }
33:
34: public final String getPartNumber() {
35:
36: return partNumber;
37: }
38:
39: public final String getSupplierNumber() {
40:
41: return supplierNumber;
42: }
43:
44: public String toString() {
45:
46: return "[ShipmentKey: supplier=" + supplierNumber + " part="
47: + partNumber + ']';
48: }
49:
50: // --- MarshalledKey implementation ---
51:
52: ShipmentKey() {
53:
54: // A no-argument constructor is necessary only to allow the binding to
55: // instantiate objects of this class.
56: }
57:
58: public void unmarshalKey(TupleInput keyInput) {
59:
60: this .partNumber = keyInput.readString();
61: this .supplierNumber = keyInput.readString();
62: }
63:
64: public void marshalKey(TupleOutput keyOutput) {
65:
66: keyOutput.writeString(this.partNumber);
67: keyOutput.writeString(this.supplierNumber);
68: }
69: }
|