本文整理汇总了Java中com.hp.hpl.jena.sparql.core.Var类的典型用法代码示例。如果您正苦于以下问题:Java Var类的具体用法?Java Var怎么用?Java Var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Var类属于com.hp.hpl.jena.sparql.core包,在下文中一共展示了Var类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transform
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
@Override
public Op transform(OpFilter opFilter, Op subOp) {
if ( ! (subOp instanceof OpBGP) )
return super.transform(opFilter, subOp);
ExprList exprs = opFilter.getExprs();
Op op = subOp;
// Variables set
Set<Var> patternVars = OpVars.visibleVars(op);
// Any assignments must go inside filters so the filters see the assignments.
ExprList exprs2 = new ExprList();
for ( Expr e : exprs.getList() ) {
Op op2 = processFilterWorker(e, op, patternVars);
if ( op2 == null )
exprs2.add(e);
else
op = op2;
}
// Place any filter expressions around the processed sub op.
if ( exprs2.size() > 0 )
op = OpFilter.filter(exprs2, op);
return op;
}
示例2: translate
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
@Override
public SqlStatement translate(String _resultName, SqlStatement child) {
// update schema
resultSchema = Schema.shiftToParent(subOp.getSchema(), subOp.getResultName());
resultName = _resultName;
// translates to select object
Select projection = new Select(this.getResultName());
// Add selectors (subset of result schema)
boolean first = true;
for (Var var : this.opProject.getVars()) {
projection.addSelector(var.getName(), resultSchema.get(var.getName()));
first = false;
}
// set from
projection.setFrom(child.toNamedString());
return projection;
}
示例3: generateForeach
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
private String generateForeach() {
String foreach = resultName + " = FOREACH ";
foreach += subOp.getResultName() + " GENERATE ";
List<Var> selectedVars = opProject.getVars();
Iterator<Var> varIterator = selectedVars.iterator();
String varName;
varName = varIterator.next().getVarName();
foreach += varName;
resultSchema.add(varName);
while (varIterator.hasNext()) {
varName = varIterator.next().getVarName();
foreach += ", " + varName;
resultSchema.add(varName);
}
foreach += " ;\n";
return foreach;
}
示例4: transform
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
@Override
public Op transform(OpFilter opFilter, Op subOp) {
if ( ! (subOp instanceof OpBGP) )
return super.transform(opFilter, subOp);
ExprList exprs = opFilter.getExprs();
Op op = subOp;
// Variables set
Set<Var> patternVars = OpVars.visibleVars(op);
// Any assignments must go inside filters so the filters see the assignments.
ExprList exprs2 = new ExprList();
for ( Expr e : exprs.getList() ) {
Op op2 = processFilterWorker(e, op, patternVars);
if ( op2 == null )
exprs2.add(e);
else
op = op2;
}
// Place any filter expressions around the processed sub op.
if ( exprs2.size() > 0 )
op = OpFilter.filter(exprs2, op);
return op;
}
示例5: translate
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
@Override
public SQLStatement translate(String _resultName, SQLStatement child) {
// update schema
resultSchema = Schema.shiftToParent(subOp.getSchema(), subOp.getResultName());
resultName = _resultName;
// translates to select object
Select projection = new Select(this.getResultName());
// Add selectors (subset of result schema)
for (Var var : this.opProject.getVars()) {
projection.addSelector(var.getName(), resultSchema.get(var.getName()));
}
// set from
projection.setFrom(child.toNamedString());
return projection;
}
示例6: extendWith
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
/**
* Joins this NodeRelation with a Binding. Any row in this
* NodeRelation that is incompatible with the binding will be
* dropped, and any compatible row will be extended with
* FixedNodeMakers whose node is taken from the binding.
*
* FIXME: This doesn't behave correctly when a node maker is available for a given variable but produces unbound results. Everything is compatible with unbound.
* FIXME: This ignores the condition of the binding maker, if any is present.
*
* @param binding A binding to join with this NodeRelation
* @return The joined NodeRelation
*/
public static NodeRelation extendWith(NodeRelation table, Binding binding) {
if (binding.isEmpty()) return table;
Map<Var,NodeMaker> extraVars = new HashMap<Var,NodeMaker>();
NodeRelation result = table;
for (Iterator<Var> it = binding.vars(); it.hasNext();) {
Var var = it.next();
Node value = binding.get(var);
if (table.getBindingMaker().has(var)) {
result = NodeRelationUtil.select(result, var, value);
} else {
extraVars.put(var, new FixedNodeMaker(value));
}
}
if (!extraVars.isEmpty()) {
extraVars.putAll(result.getBindingMaker().getNodeMakers());
result = new NodeRelation(result.getSQLConnection(), result.getBaseTabular(),
new BindingMaker(extraVars, result.getBindingMaker().getConditionColumn()));
}
return result;
}
示例7: project
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
public static NodeRelation project(NodeRelation original, Set<Var> vars) {
Set<ColumnName> projections = new HashSet<ColumnName>();
for (Var var: vars) {
if (!original.getBindingMaker().has(var)) continue;
projections.addAll(original.nodeMaker(var).getRequiredColumns());
}
Set<ColumnName> originalColumns = new HashSet<ColumnName>(
original.getBaseTabular().getColumns().asList());
if (originalColumns.equals(projections)) {
// The original already has exactly the columns we need, no need to project
return original;
}
OpProjecter projecter = new OpProjecter(original.getBaseTabular(), projections);
return new NodeRelation(original.getSQLConnection(),
projecter.getResult(),
original.getBindingMaker().rename(projecter.getRenamer()));
}
示例8: makeBinding
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
public Binding makeBinding(ResultRow row) {
if (conditionColumn != null) {
String value = row.get(conditionColumn);
if (value == null || "false".equals(value) || "0".equals(value) || "".equals(value)) {
return null;
}
}
BindingMap result = new BindingHashMap();
for (Var variableName: nodeMakers.keySet()) {
Node node = nodeMakers.get(variableName).makeNode(row);
if (node == null) {
return null;
}
result.add(Var.alloc(variableName), node);
}
return result;
}
示例9: toString
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
@Override
public String toString() {
StringBuffer result = new StringBuffer("BindingMaker(\n");
for (Var variable: nodeMakers.keySet()) {
result.append(" ");
result.append(variable);
result.append(" => ");
result.append(nodeMakers.get(variable));
result.append("\n");
}
result.append(")");
if (conditionColumn != null) {
result.append(" WHERE ");
result.append(conditionColumn);
}
return result.toString();
}
示例10: makeBinding
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
public Binding makeBinding(ResultRow row) {
if (condition != null) {
String value = row.get(condition);
if (value == null || "false".equals(value) || "0".equals(value) || "".equals(value)) {
return null;
}
}
BindingMap result = new BindingHashMap();
for (Var variableName: nodeMakers.keySet()) {
Node node = nodeMakers.get(variableName).makeNode(row);
if (node == null) {
return null;
}
result.add(Var.alloc(variableName), node);
}
return result;
}
示例11: toString
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
public String toString() {
StringBuffer result = new StringBuffer("BindingMaker(\n");
for (Var variable: nodeMakers.keySet()) {
result.append(" ");
result.append(variable);
result.append(" => ");
result.append(nodeMakers.get(variable));
result.append("\n");
}
result.append(")");
if (condition != null) {
result.append(" WHERE ");
result.append(condition);
}
return result.toString();
}
示例12: extendWith
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
/**
* Joins this NodeRelation with a Binding. Any row in this
* NodeRelation that is incompatible with the binding will be
* dropped, and any compatible row will be extended with
* FixedNodeMakers whose node is taken from the binding.
*
* @param binding A binding to join with this NodeRelation
* @return The joined NodeRelation
*/
public NodeRelation extendWith(Binding binding) {
if (binding.isEmpty()) return this;
MutableRelation mutator = new MutableRelation(baseRelation());
Map<Var,NodeMaker> columns = new HashMap<Var,NodeMaker>();
for (Var variable: variables()) {
columns.put(variable, nodeMaker(variable));
}
for (Iterator<Var> it = binding.vars(); it.hasNext();) {
Var var = it.next();
Node value = binding.get(var);
if (columns.containsKey(var)) {
columns.put(var, columns.get(var).selectNode(value, mutator));
} else {
columns.put(var, new FixedNodeMaker(value, false));
}
}
return new NodeRelation(mutator.immutableSnapshot(), columns);
}
示例13: visit
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
public void visit(ExprVar var)
{
logger.debug("visit ExprVar " + var);
if (!convertable) {
expression.push(Expression.FALSE); // prevent stack empty exceptions when conversion
return; // fails in the middle of a multi-arg operator conversion
}
String varName = var.getVarName();
// if expression contains a blank node, no conversion to sql can be done
if (Var.isBlankNodeVarName(varName)) {
conversionFailed("blank nodes not supported", var);
return;
}
List<Expression> expressions = toExpression(var);
if (expressions.size() == 1) {
expression.push(expressions.get(0));
} else {
// no single sql-column for sparql-var does exist break up conversion
// (the case for Pattern ValueMakers)
conversionFailed("multi column pattern valuemakers not supported", var);
}
}
示例14: testDisjunction
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
public void testDisjunction()
{
List<Triple> pattern = new ArrayList<Triple>();
pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
NodeRelation intvalue = search("table2", "intvalue", rels);
Expr disjunction = new E_LogicalOr(new E_Equals(new ExprVar("o"), NodeValue.makeNode("1", XSDDatatype.XSDint)), new E_Equals(new ExprVar("o"), NodeValue.makeNode("2", XSDDatatype.XSDint)));
Expression result = TransformExprToSQLApplyer.convert(disjunction, intvalue);
TypedNodeMaker nm = (TypedNodeMaker) intvalue.nodeMaker(Var.alloc("o"));
Expression e1 = nm.valueMaker().valueExpression("1");
Expression e2 = nm.valueMaker().valueExpression("2");
Expression expected = e1.or(e2);
assertEquals("?o = \"1\"^^xsd:int || ?o = \"2\"^^xsd:int", expected, result);
}
示例15: execEvaluated
import com.hp.hpl.jena.sparql.core.Var; //导入依赖的package包/类
public QueryIterator execEvaluated(Binding binding, Node product,
Node predicate, Node object,
ExecutionContext execCxt) {
Graph graph = execCxt.getActiveGraph();
Geometry geometry=getGeometry(product,graph);
if(geometry==null){
return IterLib.noResults(execCxt);
}
if (Var.isVar(product))
throw new ARQInternalErrorException(
this.getClass().getName()+": Subject are variables without binding");
if (Var.isVar(object))
return getValue(binding, graph, product,geometry,
Var.alloc(object), execCxt);
else
return verifyValue(binding, graph, product,geometry,object,
execCxt);
}