final int indexOfOn = secondPart.toUpperCase().indexOf(" ON ");
// secondTableToken = "BAR b"
final String secondTableToken = secondPart.substring(0, indexOfOn).trim();
final FromItem leftSide = parseTableItem(firstTableToken);
final FromItem rightSide = parseTableItem(secondTableToken);
// onClausess = ["f.id = b.id"]
final String[] onClauses = secondPart.substring(indexOfOn + " ON ".length()).split(" AND ");
final SelectItem[] leftOn = new SelectItem[onClauses.length];
final SelectItem[] rightOn = new SelectItem[onClauses.length];
for (int i = 0; i < onClauses.length; i++) {
final String onClause = onClauses[i];
final int indexOfEquals = onClause.indexOf("=");
// leftPart = "f.id"
final String leftPart = onClause.substring(0, indexOfEquals).trim();
// rightPart = "b.id"
final String rightPart = onClause.substring(indexOfEquals + 1).trim();
leftOn[i] = findSelectItem(leftPart, leftSide, rightSide);
rightOn[i] = findSelectItem(rightPart, leftSide, rightSide);
}
final FromItem result = new FromItem(joinType, leftSide, rightSide, leftOn, rightOn);
result.setQuery(_query);
return result;
}