01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: Shipment.java,v 1.11.2.2 2008/01/07 15:14:02 cwl Exp $
07: */
08:
09: package collections.ship.sentity;
10:
11: import java.io.Serializable;
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 {
32:
33: private transient String partNumber;
34: private transient String supplierNumber;
35: private int quantity;
36:
37: public Shipment(String partNumber, String supplierNumber,
38: int quantity) {
39:
40: this .partNumber = partNumber;
41: this .supplierNumber = supplierNumber;
42: this .quantity = quantity;
43: }
44:
45: /**
46: * Set the transient key fields after deserializing. This method is only
47: * called by data bindings.
48: */
49: void setKey(String partNumber, String supplierNumber) {
50:
51: this .partNumber = partNumber;
52: this .supplierNumber = supplierNumber;
53: }
54:
55: public final String getPartNumber() {
56:
57: return partNumber;
58: }
59:
60: public final String getSupplierNumber() {
61:
62: return supplierNumber;
63: }
64:
65: public final int getQuantity() {
66:
67: return quantity;
68: }
69:
70: public String toString() {
71:
72: return "[Shipment: part=" + partNumber + " supplier="
73: + supplierNumber + " quantity=" + quantity + ']';
74: }
75: }
|