KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > collections > ship > marshal > 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.12 2006/10/30 21:14:01 bostic Exp $
7  */

8
9 package collections.ship.marshal;
10
11 import com.sleepycat.bind.tuple.TupleInput;
12 import com.sleepycat.bind.tuple.TupleOutput;
13
14 /**
15  * A SupplierKey serves as the key in the key/data pair for a supplier entity.
16  *
17  * <p> In this sample, SupplierKey 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 SupplierKey implements MarshalledKey {
24
25     private String JavaDoc number;
26
27     public SupplierKey(String JavaDoc number) {
28
29         this.number = number;
30     }
31
32     public final String JavaDoc getNumber() {
33
34         return number;
35     }
36
37     public String JavaDoc toString() {
38
39         return "[SupplierKey: number=" + number + ']';
40     }
41
42     // --- MarshalledKey implementation ---
43

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