KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > collections > ship > factory > SupplierKey


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: SupplierKey.java,v 1.14 2006/10/30 21:13:59 bostic Exp $
7  */

8
9 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 SupplierKey serves as the key in the key/data pair for a supplier entity.
17  *
18  * <p> In this sample, SupplierKey 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 SupplierKey implements MarshalledTupleEntry {
25
26     private String JavaDoc number;
27
28     public SupplierKey(String JavaDoc number) {
29
30         this.number = number;
31     }
32
33     public final String JavaDoc getNumber() {
34
35         return number;
36     }
37
38     public String JavaDoc toString() {
39
40         return "[SupplierKey: number=" + number + ']';
41     }
42
43     // --- MarshalledTupleEntry implementation ---
44

45     public SupplierKey() {
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
Popular Tags