KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > tutorial > forms > VisitorState


1 // Copyright 2004 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package tutorial.forms;
16
17 import java.io.Serializable JavaDoc;
18 import java.text.DateFormat JavaDoc;
19 import java.text.ParseException JavaDoc;
20 import java.util.Date JavaDoc;
21
22 /**
23  * Used to capture the state of each user within the web application
24  * @author Neil Clayton
25  */

26 public class VisitorState implements Serializable JavaDoc
27 {
28     /**
29      * Returns the dateOfBirth.
30      * @return String
31      */

32     public Date JavaDoc getDateOfBirth()
33     {
34         return dateOfBirth;
35     }
36
37     public String JavaDoc getDateOfBirthAsString()
38     {
39         return DateFormat.getDateInstance().format(dateOfBirth);
40     }
41
42     /**
43      * Returns the favoriteColour.
44      * @return String
45      */

46     public String JavaDoc getFavoriteColour()
47     {
48         return favoriteColour;
49     }
50
51     /**
52      * Returns the name.
53      * @return String
54      */

55     public String JavaDoc getUserName()
56     {
57         return userName;
58     }
59
60     /**
61      * Sets the dateOfBirth.
62      * @param dateOfBirth The dateOfBirth to set
63      */

64     public void setDateOfBirth(Date JavaDoc dateOfBirth)
65     {
66         this.dateOfBirth = dateOfBirth;
67     }
68
69     /**
70      * Sets the favoriteColour.
71      * @param favoriteColour The favoriteColour to set
72      */

73     public void setFavoriteColour(String JavaDoc favoriteColour)
74     {
75         this.favoriteColour = favoriteColour;
76     }
77
78     public void setDateOfBirthAsString(String JavaDoc newDOB) throws ParseException JavaDoc
79     {
80         dateOfBirth = DateFormat.getDateInstance().parse(newDOB);
81     }
82
83     /**
84      * Sets the name.
85      * @param name The name to set
86      */

87     public void setUserName(String JavaDoc name)
88     {
89         this.userName = name;
90     }
91
92     private String JavaDoc userName;
93     private Date JavaDoc dateOfBirth = new Date JavaDoc(0);
94     private String JavaDoc favoriteColour;
95 }
96
Popular Tags