import java.util.*; class XNodeList { private XNodeList() { } public static String toString( List xnodes ) { return XNodeList.toString( xnodes, "", true ); } public static String toString( List xnodes, String indent, boolean lotsaNewlines ) { String result = ""; // map toString(.,.) over the list: for ( XNode x : xnodes ) { result += x.toString(indent,lotsaNewlines) + (lotsaNewlines ? "\n" : " "); } return result; } public static List parse(Scanner s) { List nodes = new ArrayList(); while (XNode.hasNext(s)) { nodes.add(XNode.parse(s)); } return nodes; } static List parse( String s ) { return XNodeList.parse(new Scanner(s)); } }