当前位置: 首页>>代码示例>>Java>>正文


Java ValueFactory.createLiteral方法代码示例

本文整理汇总了Java中org.eclipse.rdf4j.model.ValueFactory.createLiteral方法的典型用法代码示例。如果您正苦于以下问题:Java ValueFactory.createLiteral方法的具体用法?Java ValueFactory.createLiteral怎么用?Java ValueFactory.createLiteral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.rdf4j.model.ValueFactory的用法示例。


在下文中一共展示了ValueFactory.createLiteral方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertValue

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
public Value convertValue(Object object) {
  if (object instanceof Value) {
    return (Value) object;
  }

  ValueFactory valueFactory = SimpleValueFactory.getInstance();
  if (object instanceof String) {
    return valueFactory.createLiteral((String) object);
  }
  if (object instanceof Integer) {
    return valueFactory.createLiteral((Integer) object);
  }
  if (object instanceof Double) {
    return valueFactory.createLiteral((Double) object);
  }

  throw new NotSupportedException("Value is not supported: " + object.getClass());
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:19,代码来源:SparqlHttpStub.java

示例2: testEvaluate

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testEvaluate() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value obj = vf.createLiteral("whatever");
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    sail.addStatement(subj, pred, obj);
    sail.commit();
    TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select ?s ?p ?o where {<http://whatever/subj/> <http://whatever/pred/> \"whatever\"}");
    TupleQueryResult res = q.evaluate();
    assertTrue(res.hasNext());
    rep.shutDown();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:18,代码来源:HBaseSailTest.java

示例3: testEvaluateWithContext

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testEvaluateWithContext() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value obj = vf.createLiteral("whatever");
    IRI context = vf.createIRI("http://whatever/context/");
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    sail.addStatement(subj, pred, obj, context);
    sail.commit();
    TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select ?s ?p ?o from named <http://whatever/context/> where {<http://whatever/subj/> <http://whatever/pred/> \"whatever\"}");
    TupleQueryResult res = q.evaluate();
    assertFalse(res.hasNext());
    rep.shutDown();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:19,代码来源:HBaseSailTest.java

示例4: testTruncateTable

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testTruncateTable() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value expl = vf.createLiteral("explicit");
    for (KeyValue kv : HalyardTableUtils.toKeyValues(subj, pred, expl, null, false, System.currentTimeMillis())) {
            table.put(new Put(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(), kv.getTimestamp()).add(kv));
    }
    table.flushCommits();
    try (ResultScanner rs = table.getScanner(HalyardTableUtils.scan(subj, pred, expl, null))) {
        assertNotNull(rs.next());
    }
    table = HalyardTableUtils.truncateTable(table);
    try (ResultScanner rs = table.getScanner(HalyardTableUtils.scan(subj, pred, expl, null))) {
        assertNull(rs.next());
    }
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:19,代码来源:HalyardTableUtilsTest.java

示例5: testAsRDFTermOverloads

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testAsRDFTermOverloads() {
    final RDF4J rdf4J = new RDF4J();

    final ValueFactory valueFactory = SimpleValueFactory.getInstance();

    final Value bNode = valueFactory.createBNode("b1");
    final Value iri = valueFactory.createIRI("http://ex.org");
    final Value literal = valueFactory.createLiteral("b1");

    assertEquals(rdf4J.asRDFTerm(bNode), rdf4J.asRDFTerm((BNode) bNode));
    assertEquals(rdf4J.asRDFTerm(iri), rdf4J.asRDFTerm((IRI) iri));
    assertEquals(rdf4J.asRDFTerm(literal), rdf4J.asRDFTerm((Literal) literal));
    assertEquals(rdf4J.asRDFTerm(bNode), rdf4J.asRDFTerm((Resource) bNode));
    assertEquals(rdf4J.asRDFTerm(iri), rdf4J.asRDFTerm((Resource) iri));
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:17,代码来源:RDF4JMethodOverloadsTest.java

示例6: setUp

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    testDir = tempDir.newFolder("schema-generator-test").toPath();

    ValueFactory vf = SimpleValueFactory.getInstance();

    String ns = "http://example.com/ns/ontology#";
    testOntologyUri = vf.createIRI(ns);
    testProperty1 = vf.createIRI(ns, "property1");
    testProperty2 = vf.createIRI(ns, "property_2");
    testProperty3 = vf.createIRI(ns, "property-3");
    testProperty4 = vf.createIRI(ns, "propertyLocalised4");
    testProperty1Description = vf.createLiteral("property 1 description");
    testProperty2Description = vf.createLiteral("property 2 description");
    testProperty3Description = vf.createLiteral("property 3 description");
    testProperty4DescriptionEn = vf.createLiteral("property 4 description english", "en");
    testProperty4DescriptionFr = vf.createLiteral("Description de la propriété français", "fr");

    Model testOntology = new LinkedHashModel();
    testOntology.add(testOntologyUri, RDF.TYPE, OWL.ONTOLOGY);
    testOntology.add(testProperty1, RDF.TYPE, OWL.DATATYPEPROPERTY);
    testOntology.add(testProperty2, RDF.TYPE, OWL.OBJECTPROPERTY);
    testOntology.add(testProperty3, RDF.TYPE, OWL.ANNOTATIONPROPERTY);
    testOntology.add(testProperty4, RDF.TYPE, OWL.ANNOTATIONPROPERTY);
    testOntology.add(testProperty1, DCTERMS.DESCRIPTION, testProperty1Description);
    testOntology.add(testProperty2, RDFS.COMMENT, testProperty2Description);
    testOntology.add(testProperty3, SKOS.DEFINITION, testProperty3Description);
    testOntology.add(testProperty4, SKOS.PREF_LABEL, testProperty4DescriptionEn);
    testOntology.add(testProperty4, SKOS.PREF_LABEL, testProperty4DescriptionFr);
    String fileName = "test." + format.getDefaultFileExtension();
    inputPath = testDir.resolve(fileName);
    try (final OutputStream outputStream = Files.newOutputStream(inputPath)) {
        Rio.write(testOntology, outputStream, format);
    }
}
 
开发者ID:ansell,项目名称:rdf4j-schema-generator,代码行数:36,代码来源:SchemaGeneratorTest.java

示例7: createLiteralInternal

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
protected Literal createLiteralInternal(@NonNull final ValueFactory valueFactory,
    @NonNull String content, Locale language, java.net.URI type) {
  LOG.debug("creating literal with content \"{}\", language {}, datatype {}", content, language,
      type);
  if (language == null && type == null) {
    return valueFactory.createLiteral(content);
  } else if (type == null) {
    return valueFactory.createLiteral(content, language.getLanguage());
  } else {
    return valueFactory.createLiteral(content, valueFactory.createIRI(type.toString()));
  }
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:13,代码来源:AbstractRdf4jBackend.java

示例8: testClear

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testClear() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value obj = vf.createLiteral("whatever");
    IRI context = vf.createIRI("http://whatever/context/");
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertableClear", true, 0, true, 0, null, null);
    sail.initialize();
    sail.addStatement(subj, pred, obj, context);
    sail.addStatement(subj, pred, obj);
    sail.commit();
    iter = sail.getStatements(subj, pred, obj, true);
    assertTrue(iter.hasNext());
    iter.close();
    sail.clear(context);
    iter = sail.getStatements(subj, pred, obj, true);
    assertTrue(iter.hasNext());
    iter.close();
    iter = sail.getStatements(subj, pred, obj, true, context);
    assertFalse(iter.hasNext());
    iter.close();
    sail.clear();
    iter = sail.getStatements(subj, pred, obj, true);
    assertFalse(iter.hasNext());
    iter.close();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:29,代码来源:HBaseSailTest.java

示例9: testBigLiteral

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testBigLiteral() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://testBigLiteral/subject/");
    IRI pred = vf.createIRI("http://testBigLiteral/pred/");
    Value obj = vf.createLiteral(RandomStringUtils.random(100000));
    for (KeyValue kv : HalyardTableUtils.toKeyValues(subj, pred, obj, null, false, System.currentTimeMillis())) {
            table.put(new Put(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(), kv.getTimestamp()).add(kv));
    }
    table.flushCommits();

    try (ResultScanner rs = table.getScanner(HalyardTableUtils.scan(subj, pred, obj, null))) {
        assertEquals(obj, HalyardTableUtils.parseStatements(rs.next()).iterator().next().getObject());
    }
    try (ResultScanner rs = table.getScanner(HalyardTableUtils.scan(subj, pred, null, null))) {
        assertEquals(obj, HalyardTableUtils.parseStatements(rs.next()).iterator().next().getObject());
    }
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:19,代码来源:HalyardTableUtilsTest.java

示例10: testConflictingHash

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testConflictingHash() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://testConflictingHash/subject/");
    IRI pred1 = vf.createIRI("http://testConflictingHash/pred1/");
    IRI pred2 = vf.createIRI("http://testConflictingHash/pred2/");
    Value obj1 = vf.createLiteral("literal1");
    Value obj2 = vf.createLiteral("literal2");
    long timestamp = System.currentTimeMillis();
    KeyValue kv1[] = HalyardTableUtils.toKeyValues(subj, pred1, obj1, null, false, timestamp);
    KeyValue kv2[] = HalyardTableUtils.toKeyValues(subj, pred2, obj2, null, false, timestamp);
    for (int i=0; i<3; i++) {
        table.put(new Put(kv1[i].getRowArray(), kv1[i].getRowOffset(), kv1[i].getRowLength(), kv1[i].getTimestamp()).add(kv1[i]));
        KeyValue conflicting = new KeyValue(kv1[i].getRowArray(), kv1[i].getRowOffset(), kv1[i].getRowLength(),
                kv1[i].getFamilyArray(), kv1[i].getFamilyOffset(), kv1[i].getFamilyLength(),
                kv2[i].getQualifierArray(), kv1[i].getQualifierOffset(), kv1[i].getQualifierLength(),
                kv1[i].getTimestamp(), KeyValue.Type.Put, kv2[i].getValueArray(), kv1[i].getValueOffset(), kv1[i].getValueLength());
        table.put(new Put(conflicting.getRowArray(), conflicting.getRowOffset(), conflicting.getRowLength(), conflicting.getTimestamp()).add(conflicting));
    }
    table.flushCommits();

    try (ResultScanner rs = table.getScanner(HalyardTableUtils.scan(subj, pred1, obj1, null))) {
        List<Statement> res = HalyardTableUtils.parseStatements(rs.next());
        assertEquals(2, res.size());
        assertTrue(res.contains(SimpleValueFactory.getInstance().createStatement(subj, pred1, obj1)));
        assertTrue(res.contains(SimpleValueFactory.getInstance().createStatement(subj, pred2, obj2)));
    }
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:29,代码来源:HalyardTableUtilsTest.java

示例11: getCurrentTime

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
/**
 * Create date literal based on current time
 * @return  Literal object
 * @throws DatatypeConfigurationException 
 */
public static Literal getCurrentTime() throws 
        DatatypeConfigurationException {
    Date date = new Date();
    GregorianCalendar c = new GregorianCalendar();
    c.setTime(date);
    XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().
            newXMLGregorianCalendar(c);
    ValueFactory f = SimpleValueFactory.getInstance();
    Literal currentTime = f.createLiteral(xmlDate.toXMLFormat(),
                XMLSchema.DATETIME);
    return currentTime;
}
 
开发者ID:DTL-FAIRData,项目名称:fairmetadata4j,代码行数:18,代码来源:RDFUtils.java

示例12: generateValue

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Override
public Value generateValue(List<Object> row, ValueFactory valueFactory) {
    final String rawResult = super.process(row);
    if (rawResult == null) {
        return null;
    }

    return valueFactory.createLiteral(rawResult, typeUri);
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:10,代码来源:ValueGeneratorTyped.java

示例13: generateValue

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Override
public Value generateValue(List<Object> row, ValueFactory valueFactory) {
    final String rawResult = super.process(row);
    if (rawResult == null) {
        return null;
    }

    if (language != null) {
        return valueFactory.createLiteral(rawResult, language);
    } else {
        return valueFactory.createLiteral(rawResult);
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:14,代码来源:ValueGeneratorString.java

示例14: generateValue

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Override
public Value generateValue(List<Object> row, ValueFactory valueFactory) {
    final String rawResult = super.process(row);
    if (rawResult == null) {
        return null;
    }

    return valueFactory.createLiteral(rawResult, this.typeUri);
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:10,代码来源:ValueGeneratorTyped.java

示例15: generateValue

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Override
public Value generateValue(List<Object> row, ValueFactory valueFactory) {
    final String rawResult = super.process(row);
    if (rawResult == null) {
        return null;
    }

    if (this.language != null) {
        return valueFactory.createLiteral(rawResult, this.language);
    } else {
        return valueFactory.createLiteral(rawResult);
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:14,代码来源:ValueGeneratorString.java


注:本文中的org.eclipse.rdf4j.model.ValueFactory.createLiteral方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。