KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > collections > ship > sentity > Shipment


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

8
9 package collections.ship.sentity;
10
11 import java.io.Serializable JavaDoc;
12
13 /**
14  * A Shipment represents the combined key/data pair for a shipment entity.
15  *
16  * <p> In this sample, Shipment is created from the stored key/data entry
17  * using TupleSerialEntityBinding. See {@link SampleViews.PartBinding} for
18  * details.
19  * </p>
20  *
21  * <p> The binding is "tricky" in that it uses this class for both the stored
22  * data entry and the combined entity object. To do this, the key field(s)
23  * are transient and are set by the binding after the data object has been
24  * deserialized. This avoids the use of a ShipmentData class completely. </p>
25  *
26  * <p> Since this class is used directly for data storage, it must be
27  * Serializable. </p>
28  *
29  * @author Mark Hayes
30  */

31 public class Shipment implements Serializable JavaDoc {
32
33     private transient String JavaDoc partNumber;
34     private transient String JavaDoc supplierNumber;
35     private int quantity;
36
37     public Shipment(String JavaDoc partNumber, String JavaDoc supplierNumber, int quantity) {
38
39         this.partNumber = partNumber;
40         this.supplierNumber = supplierNumber;
41         this.quantity = quantity;
42     }
43
44     /**
45      * Set the transient key fields after deserializing. This method is only
46      * called by data bindings.
47      */

48     void setKey(String JavaDoc partNumber, String JavaDoc supplierNumber) {
49
50         this.partNumber = partNumber;
51         this.supplierNumber = supplierNumber;
52     }
53
54     public final String JavaDoc getPartNumber() {
55
56         return partNumber;
57     }
58
59     public final String JavaDoc getSupplierNumber() {
60
61         return supplierNumber;
62     }
63
64     public final int getQuantity() {
65
66         return quantity;
67     }
68
69     public String JavaDoc toString() {
70
71         return "[Shipment: part=" + partNumber +
72                 " supplier=" + supplierNumber +
73                 " quantity=" + quantity + ']';
74     }
75 }
76
Popular Tags