Printing Cascade List to ‘n’th Level

Printing Cascade List to ‘n’th Level

private static void printList(IAgileList list, int level) throws APIException {
if (list != null) {
System.out.println(indent(level * 4) /*+ list.getLevelName()*/ + “:” + list.getValue() /*+ “:” + list.getId()*/);
Object[] children = list.getChildren();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
printList((IAgileList) children[i], level + 1);
}
}
}
}

private static String indent(int level) {
if (level <= 0) {
return “”;
}
char c[] = new char[level * 2];
Arrays.fill(c, ‘ ‘);
return new String(c);
}

Leave a Reply

Your email address will not be published. Required fields are marked *