KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > samples > tour > beans > TaskBean


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

16
17 package org.apache.cocoon.samples.tour.beans;
18
19 import java.util.LinkedList JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.Collections JavaDoc;
23
24 /** Stores data of a Task
25  *
26  */

27
28 public class TaskBean {
29     private String JavaDoc m_taskName;
30     private String JavaDoc m_assignedTo;
31     private final int m_id;
32     private final LinkedList JavaDoc m_comments = new LinkedList JavaDoc();
33     public static int m_idCounter;
34
35     public TaskBean() {
36         synchronized(TaskBean.class) {
37             m_id = ++m_idCounter;
38         }
39     }
40
41     public String JavaDoc toString() {
42         final StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
43         sb.append("TaskBean #" + m_id + " (" + m_taskName + "," + m_assignedTo + ")");
44         for(Iterator JavaDoc it = m_comments.iterator(); it.hasNext(); ) {
45             sb.append("\n\t");
46             sb.append(it.next());
47         }
48         return sb.toString();
49     }
50
51     public int getId() {
52         return m_id;
53     }
54
55     public String JavaDoc getTaskName() {
56         return m_taskName;
57     }
58
59     public void setTaskName(String JavaDoc m_taskName) {
60         this.m_taskName = m_taskName;
61     }
62
63     public String JavaDoc getAssignedTo() {
64         return m_assignedTo;
65     }
66
67     public void setAssignedTo(String JavaDoc m_assignedTo) {
68         this.m_assignedTo = m_assignedTo;
69     }
70
71     public List JavaDoc getComments() {
72         return m_comments;
73     }
74
75     /** replace comments with c (trivial example implementation) */
76     public void setComments(List JavaDoc c) {
77         m_comments.clear();
78         Collections.copy(m_comments,c);
79     }
80
81     public void addComment(TaskCommentBean tcb) {
82         m_comments.add(tcb);
83     }
84 }
85
Popular Tags