1 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 27 public class Element 28 { 29 ArrayList elements; 30 String name; 31 32 33 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 } 86 | Popular Tags |