01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.cocoon.samples.tour.beans;
19:
20: import java.util.LinkedList;
21: import java.util.List;
22: import java.util.Iterator;
23: import java.util.Collections;
24:
25: /** Stores data of a Task
26: *
27: */
28:
29: public class TaskBean {
30: private String m_taskName;
31: private String m_assignedTo;
32: private final int m_id;
33: private final LinkedList m_comments = new LinkedList();
34: public static int m_idCounter;
35:
36: public TaskBean() {
37: synchronized (TaskBean.class) {
38: m_id = ++m_idCounter;
39: }
40: }
41:
42: public String toString() {
43: final StringBuffer sb = new StringBuffer();
44: sb.append("TaskBean #" + m_id + " (" + m_taskName + ","
45: + m_assignedTo + ")");
46: for (Iterator it = m_comments.iterator(); it.hasNext();) {
47: sb.append("\n\t");
48: sb.append(it.next());
49: }
50: return sb.toString();
51: }
52:
53: public int getId() {
54: return m_id;
55: }
56:
57: public String getTaskName() {
58: return m_taskName;
59: }
60:
61: public void setTaskName(String m_taskName) {
62: this .m_taskName = m_taskName;
63: }
64:
65: public String getAssignedTo() {
66: return m_assignedTo;
67: }
68:
69: public void setAssignedTo(String m_assignedTo) {
70: this .m_assignedTo = m_assignedTo;
71: }
72:
73: public List getComments() {
74: return m_comments;
75: }
76:
77: /** replace comments with c (trivial example implementation) */
78: public void setComments(List c) {
79: m_comments.clear();
80: Collections.copy(m_comments, c);
81: }
82:
83: public void addComment(TaskCommentBean tcb) {
84: m_comments.add(tcb);
85: }
86: }
|