// if AST exists...
if (debugViewerCreator!=null && debugViewerCreator instanceof SPARQLDebugViewerCreator
&& ((SPARQLDebugViewerCreator) debugViewerCreator).getAST() != null) {
final Node ast = ((SPARQLDebugViewerCreator) debugViewerCreator).getAST(); // get AST
// walk through first level children of AST...
for (int i = 0; i < ast.jjtGetNumChildren(); ++i) {
final Node child = ast.jjtGetChild(i); // get current child
if (child instanceof ASTSelectQuery) {
final ASTSelectQuery selectChild = (ASTSelectQuery) child;
// SELECT is not the wildcard *...
if (!selectChild.isSelectAll()) {
// walk through select children...
for (int j = 0; j < selectChild.jjtGetNumChildren(); ++j) {
final Node selectChildChild = selectChild
.jjtGetChild(j);
// child of select is variable...
if (selectChildChild instanceof ASTVar) {
final ASTVar var = (ASTVar) selectChildChild;
// add name of variable to order...
if (!resultOrder.contains(var.getName())) {
resultOrder.add(var.getName());
}
} else if (selectChildChild instanceof ASTAs) {
for (int j1 = 0; j1 < selectChildChild
.jjtGetNumChildren(); ++j1) {
final Node selectChildChildChild = selectChildChild
.jjtGetChild(j1);
if (selectChildChildChild instanceof ASTVar) {
final ASTVar var = (ASTVar) selectChildChildChild;
// add name of variable to order...