001/* $Id: Employee.java 1102402 2011-05-12 18:03:26Z simonetripodi $
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements.  See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * the License.  You may obtain a copy of the License at
009 *
010 *      http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.apache.commons.digester3;
020
021import java.util.ArrayList;
022
023/**
024 * Bean for Digester testing.
025 */
026
027public class Employee
028{
029
030    public Employee()
031    {
032        this( "My First Name", "My Last Name" );
033    }
034
035    public Employee( String firstName, String lastName )
036    {
037        super();
038        setFirstName( firstName );
039        setLastName( lastName );
040    }
041
042    private ArrayList<Address> addresses = new ArrayList<Address>();
043
044    public void addAddress( Address address )
045    {
046        addresses.add( address );
047    }
048
049    public Address getAddress( String type )
050    {
051        for ( Address address : addresses )
052        {
053            if ( type.equals( address.getType() ) )
054                return ( address );
055        }
056        return ( null );
057    }
058
059    public void removeAddress( Address address )
060    {
061        addresses.remove( address );
062    }
063
064    private String firstName = null;
065
066    public String getFirstName()
067    {
068        return ( this.firstName );
069    }
070
071    public void setFirstName( String firstName )
072    {
073        this.firstName = firstName;
074    }
075
076    private String lastName = null;
077
078    public String getLastName()
079    {
080        return ( this.lastName );
081    }
082
083    public void setLastName( String lastName )
084    {
085        this.lastName = lastName;
086    }
087
088    // this is to allow testing of primitive convertion
089    private int age;
090
091    private boolean active;
092
093    private float salary;
094
095    public int getAge()
096    {
097        return age;
098    }
099
100    public void setAge( int age )
101    {
102        this.age = age;
103    }
104
105    public boolean isActive()
106    {
107        return active;
108    }
109
110    public void setActive( boolean active )
111    {
112        this.active = active;
113    }
114
115    public float getSalary()
116    {
117        return salary;
118    }
119
120    public void setSalary( float salary )
121    {
122        this.salary = salary;
123    }
124
125    @Override
126    public String toString()
127    {
128        StringBuilder sb = new StringBuilder( "Employee[" );
129        sb.append( "firstName=" );
130        sb.append( firstName );
131        sb.append( ", lastName=" );
132        sb.append( lastName );
133        sb.append( "]" );
134        return ( sb.toString() );
135    }
136
137}