KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > digester > Employee


1 /* $Id: Employee.java 155412 2005-02-26 12:58:36Z dirkv $
2  *
3  * Copyright 2001-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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.commons.digester;
19
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.Iterator JavaDoc;
23
24
25 /**
26  * Bean for Digester testing.
27  */

28
29 public class Employee {
30
31     public Employee() {
32         this("My First Name", "My Last Name");
33     }
34
35     public Employee(String JavaDoc firstName, String JavaDoc lastName) {
36         super();
37         setFirstName(firstName);
38         setLastName(lastName);
39     }
40
41     private ArrayList JavaDoc addresses = new ArrayList JavaDoc();
42
43     public void addAddress(Address address) {
44         addresses.add(address);
45     }
46
47     public Address getAddress(String JavaDoc type) {
48         Iterator JavaDoc elements = addresses.iterator();
49         while (elements.hasNext()) {
50             Address element = (Address) elements.next();
51             if (type.equals(element.getType()))
52                 return (element);
53         }
54         return (null);
55     }
56
57     public void removeAddress(Address address) {
58         addresses.remove(address);
59     }
60
61     private String JavaDoc firstName = null;
62
63     public String JavaDoc getFirstName() {
64         return (this.firstName);
65     }
66
67     public void setFirstName(String JavaDoc firstName) {
68         this.firstName = firstName;
69     }
70
71     private String JavaDoc lastName = null;
72
73     public String JavaDoc getLastName() {
74         return (this.lastName);
75     }
76
77     public void setLastName(String JavaDoc lastName) {
78         this.lastName = lastName;
79     }
80
81     // this is to allow testing of primitive convertion
82
private int age;
83     private boolean active;
84     private float salary;
85         
86     public int getAge()
87     {
88         return age;
89     }
90     
91     public void setAge(int age)
92     {
93         this.age = age;
94     }
95     
96     public boolean isActive()
97     {
98         return active;
99     }
100     
101     public void setActive(boolean active)
102     {
103         this.active = active;
104     }
105     
106     public float getSalary()
107     {
108         return salary;
109     }
110     
111     public void setSalary(float salary)
112     {
113         this.salary = salary;
114     }
115
116     public String JavaDoc toString() {
117         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("Employee[");
118         sb.append("firstName=");
119         sb.append(firstName);
120         sb.append(", lastName=");
121         sb.append(lastName);
122         sb.append("]");
123         return (sb.toString());
124     }
125
126 }
127
Popular Tags