• 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/marshal/
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:30 bostic Exp $
7 */
8
9package collections.ship.marshal;
10
11import com.sleepycat.bind.tuple.TupleInput;
12import 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 */
23public 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}
60