001: /*
002: * Copyright 2002,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.jelly.core;
017:
018: import java.util.ArrayList;
019: import java.util.Iterator;
020: import java.util.List;
021:
022: /**
023: * A sample bean that we can construct via Jelly tags
024: *
025: * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
026: * @version $Revision: 155420 $
027: */
028: public class Customer {
029:
030: private String name;
031: private String city;
032: private String location;
033: private List orders = new ArrayList();
034:
035: public Customer() {
036: }
037:
038: public Customer(String name) {
039: setName(name);
040: }
041:
042: public Customer(String name, String city) {
043: setName(name);
044: setCity(city);
045: }
046:
047: public Customer(String name, String city, Order anOrder) {
048: setName(name);
049: setCity(city);
050: addOrder(anOrder);
051: }
052:
053: public Customer(Customer cust) {
054: setName(cust.getName());
055: setCity(cust.getCity());
056: setLocation(cust.getLocation());
057: List list = cust.getOrders();
058: if (null != list) {
059: for (Iterator iter = list.iterator(); iter.hasNext();) {
060: addOrder((Order) iter.next());
061: }
062: }
063: }
064:
065: public String toString() {
066: return super .toString() + "[name=" + name + ";city=" + city
067: + "]";
068: }
069:
070: /**
071: * Creates a new Order object
072: */
073: public Order createOrder() {
074: return new Order();
075: }
076:
077: public List getOrders() {
078: return orders;
079: }
080:
081: public void addOrder(Order order) {
082: orders.add(order);
083: }
084:
085: public void removeOrder(Order order) {
086: orders.remove(order);
087: }
088:
089: /**
090: * Returns the city.
091: * @return String
092: */
093: public String getCity() {
094: return city;
095: }
096:
097: /**
098: * Returns the location.
099: * @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: }
|