01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: Part.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 Part represents the combined key/data pair for a part entity.
15: *
16: * <p> In this sample, Part is created from the stored key/data entry using a
17: * TupleSerialEntityBinding. See {@link SampleViews.PartBinding} for details.
18: * </p>
19: *
20: * <p> The binding is "tricky" in that it uses this class for both the stored
21: * data entry and the combined entity object. To do this, the key field(s) are
22: * transient and are set by the binding after the data object has been
23: * deserialized. This avoids the use of a PartData class completely. </p>
24: *
25: * <p> Since this class is used directly for data storage, it must be
26: * Serializable. </p>
27: *
28: * @author Mark Hayes
29: */
30: public class Part implements Serializable {
31:
32: private transient String number;
33: private String name;
34: private String color;
35: private Weight weight;
36: private String city;
37:
38: public Part(String number, String name, String color,
39: Weight weight, String city) {
40:
41: this .number = number;
42: this .name = name;
43: this .color = color;
44: this .weight = weight;
45: this .city = city;
46: }
47:
48: /**
49: * Set the transient key fields after deserializing. This method is only
50: * called by data bindings.
51: */
52: final void setKey(String number) {
53:
54: this .number = number;
55: }
56:
57: public final String getNumber() {
58:
59: return number;
60: }
61:
62: public final String getName() {
63:
64: return name;
65: }
66:
67: public final String getColor() {
68:
69: return color;
70: }
71:
72: public final Weight getWeight() {
73:
74: return weight;
75: }
76:
77: public final String getCity() {
78:
79: return city;
80: }
81:
82: public String toString() {
83:
84: return "[Part: number=" + number + " name=" + name + " color="
85: + color + " weight=" + weight + " city=" + city + ']';
86: }
87: }
|