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.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 PartKey serves as the key in the key/data pair for a part entity.
17: *
18: * <p> In this sample, PartKey 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 PartKey implements MarshalledTupleEntry {
25:
26: private String number;
27:
28: public PartKey(String number) {
29:
30: this .number = number;
31: }
32:
33: public final String getNumber() {
34:
35: return number;
36: }
37:
38: public String toString() {
39:
40: return "[PartKey: number=" + number + ']';
41: }
42:
43: // --- MarshalledTupleEntry implementation ---
44:
45: public PartKey() {
46:
47: // A no-argument constructor is necessary only to allow the binding to
48: // instantiate objects of this class.
49: }
50:
51: public void marshalEntry(TupleOutput keyOutput) {
52:
53: keyOutput.writeString(this .number);
54: }
55:
56: public void unmarshalEntry(TupleInput keyInput) {
57:
58: this.number = keyInput.readString();
59: }
60: }
|