本文整理汇总了Java中org.openrdf.query.algebra.ProjectionElem.getSourceName方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectionElem.getSourceName方法的具体用法?Java ProjectionElem.getSourceName怎么用?Java ProjectionElem.getSourceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.query.algebra.ProjectionElem
的用法示例。
在下文中一共展示了ProjectionElem.getSourceName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: meet
import org.openrdf.query.algebra.ProjectionElem; //导入方法依赖的package包/类
@Override
public void meet(final ProjectionElem n) {
final String source = n.getSourceName();
final String target = n.getTargetName();
final ValueExpr expr = n.getSourceExpression() == null ? null : n
.getSourceExpression().getExpr();
if (target.startsWith("-")) {
if (expr != null) {
emit("(").emit(expr).emit(" AS ?").emit(sanitize(target)).emit(")");
}
} else if (expr != null) {
emit("(").emit(expr).emit(" AS ?").emit(target).emit(")");
} else if (!equalOrNull(source, target)) {
emit("(?").emit(source).emit(" AS ?").emit(target).emit(")");
} else {
emit("?").emit(target);
}
}
示例2: extractConstructVar
import org.openrdf.query.algebra.ProjectionElem; //导入方法依赖的package包/类
private static Var extractConstructVar(final Map<String, ExtensionElem> extensions,
final ProjectionElem projection) {
final ExtensionElem extension = extensions.get(projection.getSourceName());
String name = projection.getSourceName();
if (name.startsWith("-anon-")) {
name += "-construct";
}
if (extension == null || extension.getExpr() instanceof BNodeGenerator) {
final Var var = new Var(name);
var.setAnonymous(name.startsWith("-anon-"));
return var;
} else if (extension.getExpr() instanceof ValueConstant) {
final ValueConstant constant = (ValueConstant) extension.getExpr();
return new Var(name, constant.getValue());
} else {
throw new UnsupportedOperationException(
"Unsupported extension in construct query: " + extension);
}
}
示例3: project
import org.openrdf.query.algebra.ProjectionElem; //导入方法依赖的package包/类
/**
* Applies the projection to a value. If the result has a blank node whose ID is not mapped to a value in
* {@code blankNodes}, then a random UUID will be used.
*
* @param bs - The value the projection will be applied to. (not null)
* @param blankNodes - A map from node source names to the blank nodes that will be used for those names. (not null)
* @return A new value that is the result of the projection.
*/
public VisibilityBindingSet project(final VisibilityBindingSet bs, final Map<String, BNode> blankNodes) {
requireNonNull(bs);
requireNonNull(blankNodes);
// Apply the projection elements against the original binding set.
final MapBindingSet result = new MapBindingSet();
for (final ProjectionElem elem : projectionElems.getElements()) {
final String sourceName = elem.getSourceName();
Value value = null;
// If the binding set already has the source name, then use the target name.
if (bs.hasBinding(sourceName)) {
value = bs.getValue(elem.getSourceName());
}
// If the source name represents a constant value, then use the constant.
else if(constantSources.containsKey(sourceName)) {
value = constantSources.get(sourceName);
}
// If the source name represents an anonymous value, then create a Blank Node.
else if(anonymousSources.contains(sourceName)) {
if(blankNodes.containsKey(sourceName)) {
value = blankNodes.get(sourceName);
} else {
value = vf.createBNode( UUID.randomUUID().toString() );
}
}
// Only add the value if there is one. There may not be one if a binding is optional.
if(value != null) {
result.addBinding(elem.getTargetName(), value);
}
}
return new VisibilityBindingSet(result, bs.getVisibility());
}
示例4: getConstructGraphVarOrder
import org.openrdf.query.algebra.ProjectionElem; //导入方法依赖的package包/类
private static VariableOrder getConstructGraphVarOrder(final List<ProjectionElemList> projections) {
final Set<String> varOrders = new HashSet<>();
for(final ProjectionElemList elems: projections) {
for(final ProjectionElem elem: elems.getElements()) {
final String name = elem.getSourceName();
if(!name.startsWith("-const-") && !name.startsWith("-anon-")) {
varOrders.add(name);
}
}
}
return new VariableOrder(varOrders);
}
示例5: meet
import org.openrdf.query.algebra.ProjectionElem; //导入方法依赖的package包/类
@Override
public void meet(ProjectionElemList node) {
List<ProjectionElem> proj = node.getElements();
for (ProjectionElem s : proj) {
if (varChanges.containsKey(s.getSourceName())) {
String name = s.getSourceName();
s.setSourceName(varChanges.get(name));
s.setTargetName(varChanges.get(name));
}
}
}
示例6: recordConsequent
import org.openrdf.query.algebra.ProjectionElem; //导入方法依赖的package包/类
private void recordConsequent(ProjectionElemList variables, List<ExtensionElem> extensionElements) {
Map<String, Value> bindings = new ConcurrentHashMap<>();
Map<String, Value> values = new ConcurrentHashMap<>();
Set<String> queryBnodes = new HashSet<>();
Set<String> projectedBnodes = new HashSet<>();
for (ExtensionElem ee : extensionElements) {
if (ee.getExpr() instanceof ValueConstant) {
bindings.put(ee.getName(), ((ValueConstant) ee.getExpr()).getValue());
}
else if (ee.getExpr() instanceof BNodeGenerator) {
queryBnodes.add(ee.getName());
}
}
for (ProjectionElem var : variables.getElements()) {
String sourceName = var.getSourceName();
String targetName = var.getTargetName();
Value constValue = bindings.get(sourceName);
if (constValue != null) {
values.put(targetName, constValue);
}
else if (queryBnodes.contains(sourceName)) {
projectedBnodes.add(targetName);
}
}
Var subjVar = new Var(SUBJECT_VAR_NAME, values.get(SUBJECT_VAR_NAME));
Var predVar = new Var(PREDICATE_VAR_NAME, values.get(PREDICATE_VAR_NAME));
Var objVar = new Var(OBJECT_VAR_NAME, values.get(OBJECT_VAR_NAME));
subjVar.setAnonymous(projectedBnodes.contains(SUBJECT_VAR_NAME));
predVar.setAnonymous(projectedBnodes.contains(PREDICATE_VAR_NAME));
objVar.setAnonymous(projectedBnodes.contains(OBJECT_VAR_NAME));
StatementPattern sp = new StatementPattern(subjVar, predVar, objVar);
consequentStatementPatterns.add(sp);
}