本文整理汇总了Java中org.openrdf.query.algebra.Var.hasValue方法的典型用法代码示例。如果您正苦于以下问题:Java Var.hasValue方法的具体用法?Java Var.hasValue怎么用?Java Var.hasValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.query.algebra.Var
的用法示例。
在下文中一共展示了Var.hasValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: meet
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Override
public void meet(Var node) throws RuntimeException {
if (node.hasValue()) {
// bound variable (constant)
Value value = node.getValue();
if (value instanceof URI)
buffer.append("<").append(value).append(">");
else
buffer.append(value);
} else {
// unbound variable
if (node.isAnonymous())
buffer.append("[]");
else
buffer.append("?").append(node.getName());
}
}
示例2: getConstantVars
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
protected List<Var> getConstantVars(Iterable<Var> vars) {
List<Var> constantVars = new ArrayList<Var>();
for (Var var : vars) {
if (var.hasValue()) {
constantVars.add(var);
}
}
return constantVars;
}
示例3: getUnboundVars
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
protected List<Var> getUnboundVars(Iterable<Var> vars) {
List<Var> unboundVars = new ArrayList<Var>();
for (Var var : vars) {
if (!var.hasValue() && !this.boundVars.contains(var.getName())) {
unboundVars.add(var);
}
}
return unboundVars;
}
示例4: meet
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@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());
}
}
示例5: CopyRule
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
/**
* Instantiate a rule containing a StatementPattern, renaming any variables to canonical
* subject/predicate/object forms and saving the mappings from the original variable names.
* @param sp StatementPattern defining a set of triples to match
*/
public CopyRule(final StatementPattern sp) throws QueryRulesetException {
statement = sp;
final Var subjVar = statement.getSubjectVar();
final Var predVar = statement.getPredicateVar();
final Var objVar = statement.getObjectVar();
final Var conVar = statement.getContextVar();
int variables = 0;
if (subjVar == null || !subjVar.hasValue()) {
sp.setSubjectVar(SUBJ_VAR);
if (subjVar != null) {
varMap.put(subjVar.getName(), SUBJ_VAR);
}
variables++;
}
if (predVar == null || !predVar.hasValue()) {
sp.setPredicateVar(PRED_VAR);
if (predVar != null) {
varMap.put(predVar.getName(), PRED_VAR);
}
variables++;
}
if (objVar == null || !objVar.hasValue()) {
sp.setObjectVar(OBJ_VAR);
if (objVar != null) {
varMap.put(objVar.getName(), OBJ_VAR);
}
variables++;
}
if (variables == 3) {
throw new QueryRulesetException("Statement pattern with no constants would match every statement:\n" + sp);
}
if (conVar != null && !conVar.hasValue()) {
sp.setContextVar(CON_VAR);
varMap.put(conVar.getName(), CON_VAR);
}
}
示例6: varIsGeneralization
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
/**
* Determine whether the first variable is at least as general as the second.
*/
private static boolean varIsGeneralization(final Var first, final Var second) {
if (first == null || !first.hasValue()) {
// if first is a variable, it is at least as general
return true;
}
// Otherwise, it is only at least as general if they are the same value
return second != null && first.getValue().equals(second.getValue());
}
示例7: meet
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Override
public void meet(Var var) {
if (!var.hasValue()) {
varNames.add(var.getName());
}
vars.add(var);
}
示例8: processPropertySearches
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
private void processPropertySearches(final TupleExpr tupleExpr, final Collection<Var> searchProperties) {
final MatchStatementVisitor matchStatements = new MatchStatementVisitor(searchProperties);
tupleExpr.visit(matchStatements);
for (final StatementPattern matchStatement: matchStatements.matchStatements) {
final Var subject = matchStatement.getSubjectVar();
if (subject.hasValue() && !(subject.getValue() instanceof Resource)) {
throw new IllegalArgumentException("Query error: Found " + subject.getValue() + ", expected an URI or BNode");
}
Validate.isTrue(subject.hasValue() || subject.getName() != null);
Validate.isTrue(!matchStatement.getObjectVar().hasValue() && matchStatement.getObjectVar().getName() != null);
buildQuery(tupleExpr, matchStatement);
}
}
示例9: meet
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Override
public void meet(Var node) throws RuntimeException {
if (node.hasValue()) {
Value value = node.getValue();
if (value instanceof URI)
buffer.append("<").append(value).append(">");
else
buffer.append(node.getValue());
} else
buffer.append("?").append(node.getName());
}
示例10: containsVar
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
private boolean containsVar(StatementPattern pattern, Var var) {
String varName = var.getName();
Var sVar = pattern.getSubjectVar();
Var oVar = pattern.getObjectVar();
return (!sVar.hasValue() && sVar.getName().equals(varName))
|| (!oVar.hasValue() && oVar.getName().equals(varName));
}
示例11: getValue
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
private Value getValue(Var subjectVar) {
return subjectVar.hasValue() ? subjectVar.getValue() : null;
}
示例12: getPredicateRestrictions
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
public static Collection<URI> getPredicateRestrictions(Var predicate) {
if (predicate.hasValue())
return Collections.singleton((URI) predicate.getValue());
return Collections.emptyList();
}
示例13: meet
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Override
public void meet(Var var) {
if (var.hasValue()) {
var.setValue(vf.asRdbmsValue(var.getValue()));
}
}
示例14: getVarValue
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
/**
* Assigns BindingSet values for any {@link Var} whose {@link Value} is
* null. Returns the {@link Value} associated with Var (if it has one),
* otherwise returns the BindingSet Value corresponding to
* {@link Var#getName()}. If no such Binding exits, this method returns
* null.
*
* @param var
* @param bindings
* @return Value
*/
private Value getVarValue(Var var, BindingSet bindings) {
if (var == null) {
return null;
} else if (var.hasValue()) {
return var.getValue();
} else {
return bindings.getValue(var.getName());
}
}