org.eclipse.rdf4j.query.algebra.Var.setConstant()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中org.eclipse.rdf4j.query.algebra.Var.setConstant()方法的一些代码示例,展示了Var.setConstant()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Var.setConstant()方法的具体详情如下:
包路径:org.eclipse.rdf4j.query.algebra.Var
类名称:Var
方法名:setConstant

Var.setConstant介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-rya

public TypeRequirementVisitor(String varName, Resource requiredType) {
  final Var typeVar = VarNameUtils.createUniqueConstVar(requiredType);
  typeVar.setConstant(true);
  this.varName = varName;
  if (BASE_TYPES.contains(requiredType)) {
    this.typeRequirement = null;
  }
  else {
    this.typeRequirement = new StatementPattern(new Var(varName), RDF_TYPE_VAR, typeVar);
  }
}
@Override

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

/**
 * Creates an (anonymous) Var representing a constant value. The variable name will be derived from the
 * actual value to guarantee uniqueness.
 * 
 * @param value
 * @return an (anonymous) Var representing a constant value.
 */
public static Var createConstVar(Value value) {
  String varName = getConstVarName(value);
  Var var = new Var(varName);
  var.setConstant(true);
  var.setAnonymous(true);
  var.setValue(value);
  return var;
}

代码示例来源:origin: eclipse/rdf4j

/**
 * Creates an (anonymous) Var representing a constant value. The variable name will be derived from the
 * actual value to guarantee uniqueness.
 * 
 * @param value
 * @return an (anonymous) Var representing a constant value.
 */
public static Var createConstVar(Value value) {
  String varName = getConstVarName(value);
  Var var = new Var(varName);
  var.setConstant(true);
  var.setAnonymous(true);
  var.setValue(value);
  return var;
}

代码示例来源:origin: apache/incubator-rya

final String valueString = VarNameUtils.removeConstant(name);
  final Var var = new Var(name, vf.createIRI(valueString));
  var.setConstant(true);
  return var;
} else if(dataTypeString.equals(RyaSchema.BNODE_NAMESPACE)) {
  final Literal value = vf.createLiteral(valueString, dataType);
  final Var var = new Var(name, value);
  var.setConstant(true);
  return var;

代码示例来源:origin: apache/incubator-rya

@Test
public void toVar_uri() {
  // Setup the string representation of the variable.
  final String varString = String.format(prependConstant("http://Chipotle%s%s"),TYPE_DELIM,XMLSchema.ANYURI );
  // Convert it to a Var object.
  final Var var = FluoStringConverter.toVar(varString);
  // Ensure it converted to the expected result.
  final Var expected = new Var(prependConstant("http://Chipotle"), VF.createIRI("http://Chipotle"));
  expected.setConstant(true);
  assertEquals(expected, var);
}

代码示例来源:origin: apache/incubator-rya

@Test
public void toVar_int() throws MalformedQueryException {
  // Setup the string representation of the variable.
  final String varString = prependConstant("5<<~>>http://www.w3.org/2001/XMLSchema#integer");
  // Convert it to a Var object.
  final Var result = FluoStringConverter.toVar(varString);
  // Ensure it converted to the expected result.
  final Var expected = new Var(prependConstant("5"), VF.createLiteral("5", XMLSchema.INTEGER));
  expected.setConstant(true);
  assertEquals(expected, result);
}

代码示例来源:origin: apache/incubator-rya

@Test
  public void toVar_string() {
    // Setup the string representation of the variable.
    final String varString = prependConstant("Chipotle<<~>>http://www.w3.org/2001/XMLSchema#string");

    // Convert it to a Var object.
    final Var result = FluoStringConverter.toVar(varString);

    // Ensure it converted to the expected result.
    final Var expected = new Var(prependConstant("Chipotle"), VF.createLiteral("Chipotle", XMLSchema.STRING));
    expected.setConstant(true);

    assertEquals(expected, result);
  }
}

代码示例来源:origin: apache/incubator-rya

@Test
public void statementPatternToString() throws MalformedQueryException {
  // Setup a StatementPattern that represents "?x <http://worksAt> <http://Chipotle>."
  final Var subject = new Var("x");
  final Var predicate = new Var(prependConstant("http://worksAt"), VF.createIRI("http://worksAt"));
  predicate.setConstant(true);
  final Var object = new Var(prependConstant("http://Chipotle"), VF.createIRI("http://Chipotle"));
  object.setConstant(true);
  final StatementPattern pattern = new StatementPattern(subject, predicate, object);
  // Convert the pattern to a String.
  final String spString = FluoStringConverter.toStatementPatternString(pattern);
  // Ensure it converted to the expected result.
  final String expected = "x:::" +
      prependConstant("http://worksAt<<~>>http://www.w3.org/2001/XMLSchema#anyURI:::") +
      prependConstant("http://Chipotle<<~>>http://www.w3.org/2001/XMLSchema#anyURI");
  assertEquals(spString, expected);
}

代码示例来源:origin: apache/incubator-rya

@Test
public void stringToStatementPattern() {
  // Setup the String representation of a statement pattern.
  final String patternString = "x:::" +
      prependConstant("http://worksAt<<~>>http://www.w3.org/2001/XMLSchema#anyURI:::") +
      prependConstant("http://Chipotle<<~>>http://www.w3.org/2001/XMLSchema#anyURI");
  // Convert it to a StatementPattern.
  final StatementPattern statementPattern = FluoStringConverter.toStatementPattern(patternString);
  // Enusre it converted to the expected result.
  final Var subject = new Var("x");
  final Var predicate = new Var(prependConstant("http://worksAt"), VF.createIRI("http://worksAt"));
  predicate.setConstant(true);
  final Var object = new Var(prependConstant("http://Chipotle"), VF.createIRI("http://Chipotle"));
  object.setConstant(true);
  final StatementPattern expected = new StatementPattern(subject, predicate, object);
  assertEquals(expected, statementPattern);
}

相关文章