1 16 17 package org.apache.commons.digester; 18 19 import java.util.List ; 20 import java.util.LinkedList ; 21 import java.util.Iterator ; 22 23 27 public class Box { 28 private String id; 29 30 private List children = new LinkedList (); 31 32 public Box() {} 33 34 public String getId() { 35 return id; 36 } 37 38 public void setId(String id) { 39 this.id = id; 40 } 41 42 public void addChild(Box child) { 43 this.children.add(child); 44 } 45 46 public List getChildren() { 47 return children; 48 } 49 50 public String toString() 51 { 52 StringBuffer buf = new StringBuffer (); 53 buf.append("[Box] id="); 54 buf.append(id); 55 buf.append(" nchildren="); 56 buf.append(children.size()); 57 58 for(Iterator i = children.iterator(); i.hasNext(); ) { 59 Box child = (Box) i.next(); 60 buf.append(" "); 61 buf.append(child.toString()); 62 } 63 return buf.toString(); 64 } 65 66 71 public String getIds() { 72 StringBuffer buf = new StringBuffer (); 73 buf.append(this.id); 74 for(Iterator i = children.iterator(); i.hasNext(); ) { 75 Box child = (Box) i.next(); 76 buf.append(" "); 77 buf.append(child.getIds()); 78 } 79 return buf.toString(); 80 } 81 } 82 | Popular Tags |