1   /*
2    * Copyright 2002,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  package org.apache.commons.jelly.core;
17  
18  import java.util.ArrayList;
19  import java.util.Iterator;
20  import java.util.List;
21  
22  /***
23   * A sample bean that we can construct via Jelly tags
24   *
25   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
26   * @version $Revision: 155420 $
27   */
28  public class Customer {
29  
30      private String name;
31      private String city;
32      private String location;
33      private List orders = new ArrayList();
34  
35  
36      public Customer() {
37      }
38  
39      public Customer(String name) {
40          setName(name);
41      }
42  
43      public Customer(String name, String city) {
44          setName(name);
45          setCity(city);
46      }
47  
48      public Customer(String name, String city, Order anOrder) {
49          setName(name);
50          setCity(city);
51          addOrder(anOrder);
52      }
53  
54      public Customer(Customer cust) {
55          setName(cust.getName());
56          setCity(cust.getCity());
57          setLocation(cust.getLocation());
58          List list = cust.getOrders();
59          if(null != list) {
60              for(Iterator iter = list.iterator();iter.hasNext();) {
61                  addOrder((Order)iter.next());
62              }
63          }
64      }
65  
66      public String toString() {
67          return super.toString() + "[name=" + name + ";city=" + city + "]";
68      }
69  
70      /***
71       * Creates a new Order object
72       */
73      public Order createOrder() {
74          return new Order();
75      }
76  
77      public List getOrders() {
78          return orders;
79      }
80  
81      public void addOrder(Order order) {
82          orders.add(order);
83      }
84  
85      public void removeOrder(Order order) {
86          orders.remove(order);
87      }
88  
89      /***
90       * Returns the city.
91       * @return String
92       */
93      public String getCity() {
94          return city;
95      }
96  
97      /***
98       * Returns the location.
99       * @return String
100      */
101     public String getLocation() {
102         return location;
103     }
104 
105     /***
106      * Returns the name.
107      * @return String
108      */
109     public String getName() {
110         return name;
111     }
112 
113     /***
114      * Sets the city.
115      * @param city The city to set
116      */
117     public void setCity(String city) {
118         this.city = city;
119     }
120 
121     /***
122      * Sets the location.
123      * @param location The location to set
124      */
125     public void setLocation(String location) {
126         this.location = location;
127     }
128 
129     /***
130      * Sets the name.
131      * @param name The name to set
132      */
133     public void setName(String name) {
134         this.name = name;
135     }
136 
137 
138 }