/** * 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); }
public IVariable getAs() { IResource node = this.getObject(SP.PropertyAs); if (node != null) { return(SPINFactory.asVariable(node)); } else { return(null); } }
public IVariable getServiceVariable() { IResource s = getResource(SP.PropertyServiceURI); if (s != null) { IVariable variable = SPINFactory.asVariable(s); if (variable != null) { return(variable); } } return(null); }
public Uri getServiceURI() { IResource s = getResource(SP.PropertyServiceURI); if (s != null && s.isUri()) { IVariable variable = SPINFactory.asVariable(s); if (variable == null) { return(s.Uri); } } return(null); }
public List <IResource> getResultNodes() { List <IResource> results = new List <IResource>(); foreach (IResource node in getList(SP.PropertyResultNodes)) { IVariable variable = SPINFactory.asVariable(node); if (variable != null) { results.Add(variable); } else if (node.isUri()) { results.Add(node); } } return(results); }
public IResource getNameNode() { IResource r = getObject(SP.PropertyGraphNameNode); if (r != null) { IVariable variable = SPINFactory.asVariable(r); if (variable != null) { return(variable); } else { return(r); } } else { return(null); } }
protected IResource getRDFNodeOrVariable(INode predicate) { IResource node = getResource(predicate); if (node != null) { IVariable var = SPINFactory.asVariable(node); if (var != null) { return(var); } else { return(node); } } else { return(null); } }
public static void printVarOrResource(ISparqlPrinter p, IResource resource) { IVariable variable = SPINFactory.asVariable(resource); if (variable != null) { variable.Print(p); } else if (resource.isUri()) { p.printURIResource(resource); } else if (p.isNamedBNodeMode()) { // TODO is this correct ? p.print(resource.ToString()); } else { p.print("[]"); } }