1   /*
2    * Copyright 2001-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.betwixt.recursion;
17  
18  import java.util.ArrayList;
19  import java.util.Iterator;
20  import java.util.List;
21  
22  /***
23   * This is just a simple element bean..
24   * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a>
25   * @version $Id: Element.java 155402 2005-02-26 12:52:00Z dirkv $
26   */
27  public class Element
28  {
29      ArrayList elements;
30      String name;
31     
32  
33      /***
34       * Constructor for ElementBean.
35       */
36      public Element()
37      {
38          elements = new ArrayList();
39      }
40      
41      public Element(String name) 
42      {
43          this();
44          setName(name);
45      }
46      
47      public void addElement(Element element)
48      {
49          elements.add(element);
50      }
51      
52      public List getElements()
53      {
54          return elements;
55      }
56      
57      public void setName(String name)
58      {
59          this.name = name;
60      }
61      
62      public String getName()
63      {
64          return this.name;
65      }
66      
67      public String toString()
68      {
69          StringBuffer buffer = new StringBuffer(getName() + "==>list: ");
70          Iterator it = getElements().iterator();
71          boolean first=true;
72          while (it.hasNext()) {
73              Element element = (Element) it.next();
74              if (first) {
75                  first = false;
76              } else {
77                  buffer.append(",");
78              }
79              buffer.append(element.getName());
80          }	
81          return buffer.toString();
82      }
83          
84  
85  }