Java Code Examples for org.apache.jena.sparql.core.Var#equals()
The following examples show how to use
org.apache.jena.sparql.core.Var#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CSVParser.java From tarql with BSD 2-Clause "Simplified" License | 5 votes |
private void init() throws IOException { String[] row; csv = new CSVReaderBuilder(reader).withCSVParser( new CSVParserBuilder() .withSeparator(delimiter) .withQuoteChar(quote) .withEscapeChar(escape) .build()) .build(); if (varsFromHeader) { while ((row = csv.readNext()) != null) { boolean foundValidColumnName = false; for (int i = 0; i < row.length; i++) { if (toVar(row[i]) == null) continue; foundValidColumnName = true; } // If row was empty or didn't contain anything usable // as column name, then try next row if (!foundValidColumnName) continue; for (int i = 0; i < row.length; i++) { Var var = toVar(row[i]); if (var == null || vars.contains(var) || var.equals(TarqlQuery.ROWNUM)) { getVar(i); } else { vars.add(var); } } break; } } rownum = 1; next(); }
Example 2
Source File: Helpers.java From tarql with BSD 2-Clause "Simplified" License | 5 votes |
public static Binding removePseudoVars(Binding binding) { BindingHashMap result = new BindingHashMap(); Iterator<Var> it = binding.vars(); while (it.hasNext()) { Var var = it.next(); if (var.equals(TarqlQuery.ROWNUM)) continue; result.add(var, binding.get(var)); } return result; }
Example 3
Source File: TarqlQueryExecution.java From tarql with BSD 2-Clause "Simplified" License | 4 votes |
/** * Modifies a query so that it operates onto a table. This is achieved * by appending the table as a VALUES block to the end of the main * query pattern. * * @param query Original query; will be modified in place * @param table Data table to be added into the query */ private void modifyQuery(Query query, final Table table) { ElementData tableElement = new ElementData() { @Override public Table getTable() { return table; } }; for (Var var: table.getVars()) { // Skip ?ROWNUM for "SELECT *" queries -- see further below if (query.isSelectType() && query.isQueryResultStar() && var.equals(TarqlQuery.ROWNUM)) continue; tableElement.add(var); } ElementGroup groupElement = new ElementGroup(); groupElement.addElement(tableElement); if (query.getQueryPattern() instanceof ElementGroup) { for (Element element: ((ElementGroup) query.getQueryPattern()).getElements()) { groupElement.addElement(element); } } else { groupElement.addElement(query.getQueryPattern()); } query.setQueryPattern(groupElement); // For SELECT * queries, we don't want to include pseudo // columns such as ?ROWNUM that may exist in the table. // That's why we skipped ?ROWNUM further up. if (query.isSelectType() && query.isQueryResultStar()) { // Force expansion of "SELECT *" to actual projection list query.setResultVars(); // Tell ARQ that it actually needs to pay attention to // the projection list query.setQueryResultStar(false); // And now we can add ?ROWNUM to the table, as the "*" // has already been expanded. tableElement.add(TarqlQuery.ROWNUM); } // Data can only be added to table after we've finished the // ?ROWNUM shenangians /*for (Binding binding: table.getRows()) { tableElement.add(binding); }*/ }