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


Java RDF类代码示例

本文整理汇总了Java中org.apache.commons.rdf.api.RDF的典型用法代码示例。如果您正苦于以下问题:Java RDF类的具体用法?Java RDF怎么用?Java RDF使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: stringToQuad

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
/**
 * Parse a string into a Quad
 * @param rdf the RDF object
 * @param line the line of text
 * @return the Quad
 */
public static Optional<Quad> stringToQuad(final RDF rdf, final String line) {
    final DatasetGraph dataset = create();
    try {
        fromString(line).lang(NQUADS).parse(dataset);
    } catch (final RiotException ex) {
        LOGGER.warn("Skipping invalid data value: {}", line);
        return empty();
    }
    final Iterator<org.apache.jena.sparql.core.Quad> i = dataset.find();
    if (i.hasNext()) {
        return of(i.next()).map(x -> asQuad(rdf, x));
    }
    return empty();
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:21,代码来源:FileUtils.java

示例2: StreamReader

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
/**
 * Create an iterator that reads a file line-by-line in reverse
 * @param rdf the RDF object
 * @param file the file
 * @param identifier the identifier
 * @param time the time
 */
public StreamReader(final RDF rdf, final File file, final IRI identifier, final Instant time) {
    this.rdf = rdf;
    this.time = time;
    this.identifier = identifier;
    try {
        this.reader = new ReversedLinesFileReader(file, UTF_8);
        this.line = reader.readLine();
    } catch (final IOException ex) {
        throw new UncheckedIOException(ex);
    }
    bufferIter = readPatch();
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:20,代码来源:RDFPatch.java

示例3: testServiceLoaderLookup

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Test
public void testServiceLoaderLookup() {
    final ServiceLoader<RDF> loader = ServiceLoader.load(RDF.class);
    for (final RDF impl : loader) {
        if (impl instanceof RDF4J) {
            return; // yay
        }
    }
    fail("RDF4J not found in ServiceLoader");
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:11,代码来源:RDF4JServiceLoaderTest.java

示例4: testServiceLoaderLookup

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Test
public void testServiceLoaderLookup() {
    final ServiceLoader<RDF> loader = ServiceLoader.load(RDF.class);
    for (final RDF impl : loader) {
        if (impl instanceof SimpleRDF) {
            return; // yay
        }
    }
    fail("SimpleRDF not found in ServiceLoader");
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:11,代码来源:SimpleServiceLoaderTest.java

示例5: parseSynchronusly

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Override
protected void parseSynchronusly() throws IOException, IllegalStateException, RDFParseException {
    // From parseSynchronusly both of these are always present
    final RDF factory = getRdfTermFactory().get();
    final Consumer<Quad> t = getTarget();

    // well - each parsing is unique. This should hopefully
    // catch any accidental double parsing
    final IRI parsing = factory.createIRI("urn:uuid:" + UUID.randomUUID());
    t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/greeting"),
            factory.createLiteral("Hello world")));

    // Now we'll expose the finalized AbstractRDFParser settings
    // so they can be inspected by the junit test

    if (getSourceIri().isPresent()) {
        t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/source"),
                getSourceIri().get()));
    }
    if (getSourceFile().isPresent()) {
        t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/source"),
                factory.createIRI(getSourceFile().get().toUri().toString())));
    }
    if (getSourceInputStream().isPresent()) {
        t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/source"),
                factory.createBlankNode()));
    }

    if (getBase().isPresent()) {
        t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/base"), getBase().get()));
    }
    if (getContentType().isPresent()) {
        t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/contentType"),
                factory.createLiteral(getContentType().get())));
    }
    if (getContentTypeSyntax().isPresent()) {
        t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/contentTypeSyntax"),
                factory.createLiteral(getContentTypeSyntax().get().name())));
    }
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:41,代码来源:DummyRDFParserBuilder.java

示例6: testServiceLoaderLookup

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Test
public void testServiceLoaderLookup() {
    final ServiceLoader<RDF> loader = ServiceLoader.load(RDF.class);
    for (final RDF impl : loader) {
        if (impl instanceof JsonLdRDF) {
            return; // yay
        }
    }
    fail("JsonLdRDF not found in ServiceLoader");
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:11,代码来源:JsonLdServiceLoaderTest.java

示例7: asRDFTerm

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
/**
 * Convert from Jena {@link Node} to any Commons RDF implementation.
 * <p>
 * Note that if the {@link Node#isBlank()}, then the factory's
 * {@link RDF#createBlankNode(String)} will be used, meaning that care
 * should be taken if reusing an {@link RDF} instance for multiple
 * conversion sessions.
 *
 * @see #asRDFTerm(Node)
 *
 * @param factory
 *            {@link RDF} to use for creating {@link RDFTerm}.
 * @param node
 *            The Jena Node to adapt. It's {@link Node#isConcrete()} must be
 *            <code>true</code>.
 * @return Adapted {@link RDFTerm}
 * @throws ConversionException
 *             If the {@link Node} can't be represented as an
 *             {@link RDFTerm}, e.g. if the node is not concrete or
 *             represents a variable in Jena.
 */
public static RDFTerm asRDFTerm(final RDF factory, final Node node) {
    if (node == null) {
        return null;
    }
    if (factory instanceof JenaRDF) {
        // No need to convert, just wrap
        return ((JenaRDF) factory).asRDFTerm(node);
    }
    if (node.isURI()) {
        return factory.createIRI(node.getURI());
    }
    if (node.isLiteral()) {
        final String lang = node.getLiteralLanguage();
        if (lang != null && !lang.isEmpty()) {
            return factory.createLiteral(node.getLiteralLexicalForm(), lang);
        }
        if (node.getLiteralDatatype().equals(XSDDatatype.XSDstring)) {
            return factory.createLiteral(node.getLiteralLexicalForm());
        }
        final IRI dt = factory.createIRI(node.getLiteralDatatype().getURI());
        return factory.createLiteral(node.getLiteralLexicalForm(), dt);
    }
    if (node.isBlank()) {
        // The factory
        return factory.createBlankNode(node.getBlankNodeLabel());
    }
    throw new ConversionException("Node is not a concrete RDF Term: " + node);
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:50,代码来源:JenaRDF.java

示例8: testServiceLoaderLookup

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Test
public void testServiceLoaderLookup() {
    final ServiceLoader<RDF> loader = ServiceLoader.load(RDF.class);
    for (final RDF impl : loader) {
        if (impl instanceof JenaRDF) {
            return; // yay
        }
    }
    fail("JenaRDF not found in ServiceLoader");
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:11,代码来源:JenaServiceLoaderTest.java

示例9: datasetImplToStringTest

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Test
public void datasetImplToStringTest() {
    RDF rdf = createFactory();
    JenaDataset jena = (JenaDataset) rdf.createDataset();
    final IRI graph = rdf.createIRI("http://example.com/");
    final IRI s = rdf.createIRI("http://example.com/s");
    final IRI p = rdf.createIRI("http://example.com/p");
    final Literal literal123 = rdf.createLiteral("123", Types.XSD_INTEGER);
    jena.add(graph, s, p, literal123);
    String out = jena.toString();
    assertEquals("<http://example.com/s> <http://example.com/p> \"123\"^^<http://www"
            + ".w3.org/2001/XMLSchema#integer> <http://example.com/> .\n", out);
    assertEquals(10L, dataset.size());
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:15,代码来源:DatasetJenaTest.java

示例10: createFactory

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Override
public RDF createFactory() {
    return new RDF4J();
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:5,代码来源:RDF4JTest.java

示例11: createFactory

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Override
public RDF createFactory() {
    return new NativeStoreRDF();
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:5,代码来源:NativeStoreGraphTest.java

示例12: createFactory

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Override
public RDF createFactory() {
    return new MemoryStoreRDF();
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:5,代码来源:MemoryGraphTest.java

示例13: createFactory

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Override
public RDF createFactory() {
    return new MemoryGraphTest.MemoryStoreRDF();
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:5,代码来源:MemoryStoreRDFTest.java

示例14: createFactory

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Override
public RDF createFactory() {
    return new SimpleRDF();
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:5,代码来源:SimpleDatasetTest.java

示例15: createFactory

import org.apache.commons.rdf.api.RDF; //导入依赖的package包/类
@Override
public RDF createFactory() {
    return new JsonLdRDF();
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:5,代码来源:JsonLdDatasetTest.java


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