本文整理汇总了Java中org.openrdf.query.algebra.Var.setConstant方法的典型用法代码示例。如果您正苦于以下问题:Java Var.setConstant方法的具体用法?Java Var.setConstant怎么用?Java Var.setConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.query.algebra.Var
的用法示例。
在下文中一共展示了Var.setConstant方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTypePattern
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Test
public void testTypePattern() throws Exception {
final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
final Set<URI> narcissistProps = new HashSet<>();
narcissistProps.add(love);
when(inferenceEngine.getHasSelfImplyingType(narcissist)).thenReturn(narcissistProps);
final Var subj = new Var("s");
final Var obj = new Var("o", narcissist);
obj.setConstant(true);
final Var pred = new Var("p", RDF.TYPE);
pred.setConstant(true);
final Projection query = new Projection(new StatementPattern(subj, pred, obj),
new ProjectionElemList(new ProjectionElem("s", "subject")));
query.visit(new HasSelfVisitor(conf, inferenceEngine));
Assert.assertTrue(query.getArg() instanceof Union);
final Union union = (Union) query.getArg();
Assert.assertTrue(union.getRightArg() instanceof StatementPattern);
Assert.assertTrue(union.getLeftArg() instanceof StatementPattern);
final StatementPattern expectedLeft = new StatementPattern(subj, pred, obj);
final StatementPattern expectedRight = new StatementPattern(subj, new Var("urn:love", love), subj);
Assert.assertEquals(expectedLeft, union.getLeftArg());
Assert.assertEquals(expectedRight, union.getRightArg());
}
示例2: statementPatternToString
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@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("-const-http://worksAt", new URIImpl("http://worksAt"));
predicate.setConstant(true);
final Var object = new Var("-const-http://Chipotle", new URIImpl("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:::" +
"-const-http://worksAt<<~>>http://www.w3.org/2001/XMLSchema#anyURI:::" +
"-const-http://Chipotle<<~>>http://www.w3.org/2001/XMLSchema#anyURI";
assertEquals(spString, expected);
}
示例3: stringToStatementPattern
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Test
public void stringToStatementPattern() {
// Setup the String representation of a statement pattern.
final String patternString = "x:::" +
"-const-http://worksAt<<~>>http://www.w3.org/2001/XMLSchema#anyURI:::" +
"-const-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("-const-http://worksAt", new URIImpl("http://worksAt"));
predicate.setConstant(true);
final Var object = new Var("-const-http://Chipotle", new URIImpl("http://Chipotle"));
object.setConstant(true);
final StatementPattern expected = new StatementPattern(subject, predicate, object);
assertEquals(expected, statementPattern);
}
示例4: testPropertyPattern_constantSubj
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Test
public void testPropertyPattern_constantSubj() throws Exception {
final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
final Set<Resource> loveTypes = new HashSet<>();
loveTypes.add(narcissist);
when(inferenceEngine.getHasSelfImplyingProperty(love)).thenReturn(loveTypes);
final Var subj = new Var("s", self);
subj.setConstant(true);
final Var obj = new Var("o");
final Var pred = new Var("p", love);
pred.setConstant(true);
final Projection query = new Projection(new StatementPattern(subj, pred, obj),
new ProjectionElemList(new ProjectionElem("s", "subject")));
query.visit(new HasSelfVisitor(conf, inferenceEngine));
Assert.assertTrue(query.getArg() instanceof Union);
final Union union = (Union) query.getArg();
Assert.assertTrue(union.getRightArg() instanceof StatementPattern);
Assert.assertTrue(union.getLeftArg() instanceof Extension);
final StatementPattern expectedRight = new StatementPattern(subj, pred, obj);
final Extension expectedLeft = new Extension(
new StatementPattern(subj, new Var(RDF.TYPE.stringValue(), RDF.TYPE), new Var("urn:Narcissist", narcissist)),
new ExtensionElem(subj, "o"));
Assert.assertEquals(expectedLeft, union.getLeftArg());
Assert.assertEquals(expectedRight, union.getRightArg());
}
示例5: testPropertyPattern_constantObj
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Test
public void testPropertyPattern_constantObj() throws Exception {
final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
final Set<Resource> loveTypes = new HashSet<>();
loveTypes.add(narcissist);
when(inferenceEngine.getHasSelfImplyingProperty(love)).thenReturn(loveTypes);
final Var subj = new Var("s");
final Var obj = new Var("o", self);
obj.setConstant(true);
final Var pred = new Var("p", love);
pred.setConstant(true);
final Projection query = new Projection(new StatementPattern(subj, pred, obj),
new ProjectionElemList(new ProjectionElem("s", "subject")));
query.visit(new HasSelfVisitor(conf, inferenceEngine));
Assert.assertTrue(query.getArg() instanceof Union);
final Union union = (Union) query.getArg();
Assert.assertTrue(union.getRightArg() instanceof StatementPattern);
Assert.assertTrue(union.getLeftArg() instanceof Extension);
final StatementPattern expectedRight = new StatementPattern(subj, pred, obj);
final Extension expectedLeft = new Extension(
new StatementPattern(obj, new Var(RDF.TYPE.stringValue(), RDF.TYPE), new Var("urn:Narcissist", narcissist)),
new ExtensionElem(obj, "s"));
Assert.assertEquals(expectedLeft, union.getLeftArg());
Assert.assertEquals(expectedRight, union.getRightArg());
}
示例6: toVar_uri
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Test
public void toVar_uri() {
// Setup the string representation of the variable.
final String varString = "-const-http://Chipotle<<~>>http://www.w3.org/2001/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("-const-http://Chipotle", new URIImpl("http://Chipotle"));
expected.setConstant(true);
assertEquals(expected, var);
}
示例7: toVar_int
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Test
public void toVar_int() throws MalformedQueryException {
// Setup the string representation of the variable.
final String varString = "-const-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("-const-5", new LiteralImpl("5", XMLSchema.INTEGER));
expected.setConstant(true);
assertEquals(expected, result);
}
示例8: toVar_string
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Test
public void toVar_string() {
// Setup the string representation of the variable.
final String varString = "-const-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("-const-Chipotle", new LiteralImpl("Chipotle", XMLSchema.STRING));
expected.setConstant(true);
assertEquals(expected, result);
}
示例9: TypeRequirementVisitor
import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
public TypeRequirementVisitor(String varName, Resource requiredType) {
final Var typeVar = new Var("-const-" + requiredType.stringValue(), 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);
}
}