01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: SupplierKey.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 SupplierKey serves as the key in the key/data pair for a supplier entity.
16: *
17: * <p> In this sample, SupplierKey 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 SupplierKey implements MarshalledKey {
24:
25: private String number;
26:
27: public SupplierKey(String number) {
28:
29: this .number = number;
30: }
31:
32: public final String getNumber() {
33:
34: return number;
35: }
36:
37: public String toString() {
38:
39: return "[SupplierKey: number=" + number + ']';
40: }
41:
42: // --- MarshalledKey implementation ---
43:
44: SupplierKey() {
45:
46: // A no-argument constructor is necessary only to allow the binding to
47: // instantiate objects of this class.
48: }
49:
50: public void unmarshalKey(TupleInput keyInput) {
51:
52: this .number = keyInput.readString();
53: }
54:
55: public void marshalKey(TupleOutput keyOutput) {
56:
57: keyOutput.writeString(this.number);
58: }
59: }
|