/** * Returns the most specific Java instance for a given INode. * If the node is an aggregation, it will be returned as instance of * Aggregation. * If the node is a function call, it will be returned as instance of * FunctionCall. * If it's a Variable, the Variable will be returned. * Otherwise the node itself will be returned. * @param node the node to cast * @return node or node as a Function or Variable */ public static IResource asExpression(IResource resource) { if (resource == null) { return(null); } if (resource is INode) { IVariable var = SPINFactory.asVariable(resource); if (var != null) { return(var); } IAggregation aggr = SPINFactory.asAggregation((IResource)resource); if (aggr != null) { return(aggr); } IFunctionCall functionCall = SPINFactory.asFunctionCall((IResource)resource); if (functionCall != null) { return(functionCall); } } return(resource); }
private void printOrderByExpression(ISparqlPrinter sb, IResource node) { // TODO check for real test if (node is INode) { IResource resource = (IResource)node; IFunctionCall call = SPINFactory.asFunctionCall(resource); if (call != null) { sb.print("("); ISparqlPrinter pc = sb.clone(); pc.setNested(true); call.Print(pc); sb.print(")"); return; } } printNestedExpressionString(sb, node, true); }