if (attributes.size() > 0) {
writeAttributeReader(b);
}
JVar depthVar = b.decl(model._ref(int.class), "depth", xsrVar.invoke("getDepth"));
JVar targetDepthVar;
JVar event;
if (depth == 1) {
targetDepthVar = b.decl(model._ref(int.class), "targetDepth", JExpr.lit(depth));
event = b.decl(model._ref(int.class), "event", xsrVar.invoke("getEventType"));
} else {
targetDepthVar = b.decl(model._ref(int.class), "targetDepth", depthVar.plus(JExpr.lit(1)));
event = b.decl(model._ref(int.class), "event", xsrVar.invoke("nextTagIgnoreAll"));
}
b.assign(depthVar, xsrVar.invoke("getDepth"));
// JClass sysType = (JClass) model._ref(System.class);
// if (depth != 1)
// b.add(sysType.staticRef("out").invoke("println").arg(JExpr.lit("TD ").plus(targetDepthVar)
// .plus(JExpr.lit(" Depth: ")).plus(depthVar)
// .plus(JExpr.lit(" Name: " + name).plus(JExpr.lit(" Current: "))
// .plus(xsrVar.invoke("getName")))));
JBlock loop = b._while(depthVar.gte(targetDepthVar.minus(JExpr.lit(1)))).body();
b = loop._if(event.eq(JExpr.lit(XMLStreamConstants.START_ELEMENT)))._then();
JConditional ifDepth = b._if(depthVar.eq(targetDepthVar));
writeElementReader(elements, ifDepth._then(), false);