• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/db-4.7.25.NC/examples_java/src/collections/ship/factory/
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002,2008 Oracle.  All rights reserved.
5 *
6 * $Id: PartKey.java,v 12.7 2008/01/08 20:58:29 bostic Exp $
7 */
8
9package collections.ship.factory;
10
11import com.sleepycat.bind.tuple.MarshalledTupleEntry;
12import com.sleepycat.bind.tuple.TupleInput;
13import 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 */
24public 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}
61