KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > betwixt > recursion > Element


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 JavaDoc;
19 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
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,v 1.6 2004/02/28 13:38:36 yoavs Exp $
26  */

27 public class Element
28 {
29     ArrayList JavaDoc elements;
30     String JavaDoc name;
31    
32
33     /**
34      * Constructor for ElementBean.
35      */

36     public Element()
37     {
38         elements = new ArrayList JavaDoc();
39     }
40     
41     public Element(String JavaDoc 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 JavaDoc getElements()
53     {
54         return elements;
55     }
56     
57     public void setName(String JavaDoc name)
58     {
59         this.name = name;
60     }
61     
62     public String JavaDoc getName()
63     {
64         return this.name;
65     }
66     
67     public String JavaDoc toString()
68     {
69         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(getName() + "==>list: ");
70         Iterator JavaDoc 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 }
86
Popular Tags