}
}
private void writeElementReader(Map<QName, ElementParserBuilderImpl> els, JBlock b, boolean global) {
JConditional cond = null;
if (depth == 1 && !global && checkXsiTypes) {
writeXsiChecks(b);
}
for (Map.Entry<QName, ElementParserBuilderImpl> e : els.entrySet()) {
QName name = e.getKey();
ElementParserBuilderImpl builder = e.getValue();
JExpression localInv = xsrVar.invoke("getLocalName").eq(JExpr.lit(name.getLocalPart()));
String ns = name.getNamespaceURI();
JExpression nsInv = JExpr.lit(name.getNamespaceURI()).eq(xsrVar.invoke("getNamespaceURI"));
if (ns.equals("")) {
nsInv = nsInv.cor(xsrVar.invoke("getNamespaceURI").eq(JExpr._null()));
}
JExpression qnameCompare = localInv.cand(nsInv);
if (cond == null) {
cond = b._if(qnameCompare);
} else {
cond = cond._else()._if(qnameCompare);
}
JBlock block = cond._then();
writeElementReader(builder, block, global);
}
for (Map.Entry<QName, ElementCall> e : elementCalls.entrySet()) {
QName name = e.getKey();
ElementCall call = e.getValue();
ElementParserBuilderImpl builder = call.getElement();
JExpression localInv = xsrVar.invoke("getLocalName").eq(JExpr.lit(name.getLocalPart()));
String ns = name.getNamespaceURI();
JExpression nsInv = JExpr.lit(name.getNamespaceURI()).eq(xsrVar.invoke("getNamespaceURI"));
if (ns.equals("")) {
nsInv = nsInv.cor(xsrVar.invoke("getNamespaceURI").eq(JExpr._null()));
}
JExpression qnameCompare = localInv.cand(nsInv);
if (cond == null) {
cond = b._if(qnameCompare);
} else {
cond = cond._else()._if(qnameCompare);
}
JBlock block = cond._then();
JMethod nextMethod = builder.getMethod();
JInvocation invocation = JExpr.invoke(nextMethod).arg(xsrVar).arg(rtContextVar);
for (JExpression var : call.getVars()) {
invocation.arg(var);
}
block.add(invocation);
if (builder != this)
builder.write();
}
if (anyElement != null) {
JBlock anyBlock = b;
if (cond != null) {
anyBlock = cond._else().block();
}
writeElementReader(anyElement, anyBlock, false);
}
}