Java Code Examples for org.eclipse.rdf4j.query.algebra.Var#setName()
The following examples show how to use
org.eclipse.rdf4j.query.algebra.Var#setName() .
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: QueryVariableNormalizer.java From rya with Apache License 2.0 | 6 votes |
@Override public void meetNAryValueOperator(NAryValueOperator node) { List<ValueExpr> oldValues = node.getArguments(); List<ValueExpr> newValues = Lists.newArrayList(); for (ValueExpr v : oldValues) { if (v instanceof Var) { Var var = (Var) v; if (!(var.isConstant() && hMap.containsKey(var.getName()))) { String val = hMap.get(var.getName()); if (VarNameUtils.isConstant(val)) { newValues.add(new ValueConstant(valMap.get(val))); } else { var.setName(val); newValues.add(var); } } } else { newValues.add(v); } } node.setArguments(newValues); }
Example 2
Source File: QueryAlgebraUtil.java From CostFed with GNU Affero General Public License v3.0 | 5 votes |
/** * Clone the specified variable and attach bindings, moreover change name of variable * by appending "_varId" to it. * * @param sb * @param var * @param varNames * @param bindings * * @return */ protected static Var appendVarId(Var var, String varID, Set<String> varNames, BindingSet bindings) { Var res = var.clone(); if (!var.hasValue()) { if (bindings.hasBinding(var.getName())) { res.setValue( bindings.getValue(var.getName()) ); } else { String newName = var.getName() + "_" + varID; varNames.add(newName); res.setName(newName); } } return res; }
Example 3
Source File: QueryAlgebraUtil.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Clone the specified variable and attach bindings, moreover change name of variable by appending "_varId" to it. * * @param var * @param varID * @param varNames * @param bindings * * @return the variable */ protected static Var appendVarId(Var var, String varID, Set<String> varNames, BindingSet bindings) { Var res = var.clone(); if (!var.hasValue()) { if (bindings.hasBinding(var.getName())) { res.setValue(bindings.getValue(var.getName())); } else { String newName = var.getName() + "_" + varID; varNames.add(newName); res.setName(newName); } } return res; }
Example 4
Source File: CopyRule.java From rya with Apache License 2.0 | 5 votes |
@Override public void meet(final Var node) { final String oldName = node.getName(); if (rule.varMap.containsKey(oldName)) { node.setName(rule.varMap.get(oldName).getName()); } else { if (node.hasValue() || node.equals(SUBJ_VAR) || node.equals(PRED_VAR) || node.equals(OBJ_VAR) || node.equals(CON_VAR)) { return; } node.setName(UNDEFINED_VAR.getName()); } }
Example 5
Source File: QueryVariableNormalizer.java From rya with Apache License 2.0 | 5 votes |
public void meet(Var var) { if (!var.isConstant() && hMap.containsKey(var.getName())) { String val = hMap.get(var.getName()); if (VarNameUtils.isConstant(val)) { var.setName(val); var.setValue(valMap.get(val)); var.setAnonymous(true); //TODO this might be a hack -- when are Vars not anonymous? } else { var.setName(val); } } }
Example 6
Source File: QueryVariableNormalizer.java From rya with Apache License 2.0 | 5 votes |
@Override public void meet(Var var) { if (!(var.getParentNode() instanceof NAryValueOperator)) { if (!var.isConstant() && hMap.containsKey(var.getName())) { String val = hMap.get(var.getName()); if (VarNameUtils.isConstant(val)) { var.replaceWith(new ValueConstant(valMap.get(val))); } else { var.setName(val); } } } }