KickJava   Java API By Example, From Geeks To Geeks.

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


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

8
9 package collections.ship.sentity;
10
11 import java.io.Serializable JavaDoc;
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 JavaDoc {
31
32     private transient String JavaDoc number;
33     private String JavaDoc name;
34     private String JavaDoc color;
35     private Weight weight;
36     private String JavaDoc city;
37
38     public Part(String JavaDoc number, String JavaDoc name, String JavaDoc color, Weight weight,
39                 String JavaDoc 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 JavaDoc number) {
53
54         this.number = number;
55     }
56
57     public final String JavaDoc getNumber() {
58
59         return number;
60     }
61
62     public final String JavaDoc getName() {
63
64         return name;
65     }
66
67     public final String JavaDoc getColor() {
68
69         return color;
70     }
71
72     public final Weight getWeight() {
73
74         return weight;
75     }
76
77     public final String JavaDoc getCity() {
78
79         return city;
80     }
81
82     public String JavaDoc toString() {
83
84         return "[Part: number=" + number +
85                " name=" + name +
86                " color=" + color +
87                " weight=" + weight +
88                " city=" + city + ']';
89     }
90 }
91
Popular Tags