01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: PartKey.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 PartKey serves as the key in the key/data pair for a part entity.
16: *
17: * <p> In this sample, PartKey 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 PartKey implements MarshalledKey {
24:
25: private String number;
26:
27: public PartKey(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 "[PartKey: number=" + number + ']';
40: }
41:
42: // --- MarshalledKey implementation ---
43:
44: PartKey() {
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: }
|