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


Java RDFHandlerException类代码示例

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


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

示例1: exportEmptyStore

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
@Test
public final void exportEmptyStore()
        throws RDF4JException
{
    IRI dirgraph = conn.getValueFactory().createIRI("http://marklogic.com/dirgraph");

    Assert.assertEquals(0L, conn.size());
    conn.exportStatements(null, null, null, false, new RDFHandlerBase() {

        @Override
        public void handleStatement(Statement st1)
                throws RDFHandlerException {
            Assert.assertNull(st1);
        }

    }, dirgraph);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:18,代码来源:MarkLogicRepositoryConnectionTest.java

示例2: testAddDelete

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
@Test
public void testAddDelete() throws org.eclipse.rdf4j.RDF4JException {
	final Statement st1 = vf.createStatement(john, fname, johnfname);
	try {
		testWriterCon.begin();
		testWriterCon.add(st1);
		testWriterCon.prepareUpdate(QueryLanguage.SPARQL, "DELETE DATA {<" + john.stringValue() + "> <"
				+ fname.stringValue() + "> \"" + johnfname.stringValue() + "\"}").execute();
		testWriterCon.commit();
	} catch (Exception e) {
		logger.debug(e.getMessage());
	} finally {
		if (testWriterCon.isActive())
			testWriterCon.rollback();
	}
	testWriterCon.exportStatements(null, null, null, false, new AbstractRDFHandler() {

		@Override
		public void handleStatement(Statement st) throws RDFHandlerException {
			assertThat(st, is(not(equalTo(st1))));
		}
	});
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:24,代码来源:MarkLogicRepositoryConnectionTest.java

示例3: writeGraphQueryResult

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
@Override
public void writeGraphQueryResult(GraphQueryResult queryResult) throws ExportException {
    try {
        writer.startRDF();
        for (Map.Entry<String, String> me : queryResult.getNamespaces().entrySet()) {
            writer.handleNamespace(me.getKey(), me.getValue());
        }
        while (queryResult.hasNext()) {
            writer.handleStatement(queryResult.next());
            tick();
        }
        writer.endRDF();
    } catch (QueryEvaluationException | RDFHandlerException e) {
        throw new ExportException(e);
    }
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:17,代码来源:HalyardExport.java

示例4: getTriplesCount

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
private static int getTriplesCount(String uri, String compression, RDFFormat format) throws Exception {
    InputStream in = FileSystem.get(URI.create(uri), HBaseServerTestInstance.getInstanceConfig()).open(new Path(uri));
    try {
        if (compression != null) {
            in = new CompressorStreamFactory().createCompressorInputStream(compression, in);
        }
        RDFParser parser = Rio.createParser(format);
        final AtomicInteger i = new AtomicInteger();
        parser.setRDFHandler(new AbstractRDFHandler(){
            @Override
            public void handleStatement(Statement st) throws RDFHandlerException {
                i.incrementAndGet();
            }
        });
        parser.parse(in, uri);
        return i.get();
    } finally {
        in.close();
    }
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:21,代码来源:HalyardExportTest.java

示例5: getString

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
/**
 * Convert Metadata object to RDF string
 *
 * @param <T>
 * @param metadata Subclass of metadata object
 * @param format RDF format
 * @return RDF string
 * @throws MetadataException
 */
public static <T extends Metadata> String getString(@Nonnull T metadata,
        @Nonnull RDFFormat format)
        throws MetadataException {
    Preconditions.checkNotNull(metadata,
            "Metadata object must not be null.");
    Preconditions.checkNotNull(format, "RDF format must not be null.");
    
    StringWriter sw = new StringWriter();
    RDFWriter writer = Rio.createWriter(format, sw);
    List<Statement> statement = getStatements(metadata);
    try {
        propagateToHandler(statement, writer);
    } catch (RepositoryException | RDFHandlerException ex) {
        LOGGER.error("Error reading RDF statements");
        throw (new MetadataException(ex.getMessage()));
    }
    return sw.toString();
}
 
开发者ID:DTL-FAIRData,项目名称:fairmetadata4j,代码行数:28,代码来源:MetadataUtils.java

示例6: propagateToHandler

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
private static void propagateToHandler(List<Statement> statements,
        RDFHandler handler)
        throws RDFHandlerException, RepositoryException {
    handler.startRDF();
    handler.handleNamespace(RDF.PREFIX, RDF.NAMESPACE);
    handler.handleNamespace(RDFS.PREFIX, RDFS.NAMESPACE);
    handler.handleNamespace(DCAT.PREFIX, DCAT.NAMESPACE);
    handler.handleNamespace(XMLSchema.PREFIX, XMLSchema.NAMESPACE);
    handler.handleNamespace(OWL.PREFIX, OWL.NAMESPACE);
    handler.handleNamespace(DCTERMS.PREFIX, DCTERMS.NAMESPACE);
    handler.handleNamespace(FDP.PREFIX, FDP.NAMESPACE);
    handler.handleNamespace(R3D.PREFIX, R3D.NAMESPACE);
    handler.handleNamespace("lang",
            "http://id.loc.gov/vocabulary/iso639-1/");
    for (Statement st : statements) {
        handler.handleStatement(st);
    }
    handler.endRDF();
}
 
开发者ID:DTL-FAIRData,项目名称:fairmetadata4j,代码行数:20,代码来源:MetadataUtils.java

示例7: triple

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
private void triple(String s, String p, String o, String graph) {
    if (s == null || p == null || o == null) {
        // TODO: i don't know what to do here!!!!
        return;
    }

    Statement result;
    // This method is always called with three Resources as subject
    // predicate and object
    if (graph == null) {
        result = vf.createStatement(createResource(s), vf.createIRI(p), createResource(o));
    } else {
        result = vf.createStatement(createResource(s), vf.createIRI(p), createResource(o),
                createResource(graph));
    }

    if (handler != null) {
        try {
            handler.handleStatement(result);
        } catch (final RDFHandlerException e) {
            throw new RuntimeException(e);
        }
    }
}
 
开发者ID:jsonld-java,项目名称:jsonld-java-tools,代码行数:25,代码来源:RDF4JJSONLDTripleCallback.java

示例8: handleStatement

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
@Override
public void handleStatement(final org.eclipse.rdf4j.model.Statement st)
        throws org.eclipse.rdf4j.rio.RDFHandlerException {
    // TODO: if getRdfTermFactory() is a non-rdf4j factory, should
    // we use factory.createQuad() instead?
    // Unsure what is the promise of setting getRdfTermFactory() --
    // does it go all the way down to creating BlankNode, IRI and
    // Literal?
    quadTarget.accept(rdf4jTermFactory.asQuad(st));
    // Performance note:
    // Graph/Quad.add should pick up again our
    // RDF4JGraphLike.asStatement()
    // and avoid double conversion.
    // Additionally the RDF4JQuad and RDF4JTriple implementations
    // are lazily converting subj/obj/pred/graph.s
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:17,代码来源:RDF4JParser.java

示例9: startUp

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
@PostConstruct
public void startUp() throws IOException, RDFParseException, RDFHandlerException  {
    if(this.sparqlSamplesFile!=null){
        HashMapHandler handler = new HashMapHandler();
        RDFParser parser = Rio.createParser(RDFFormat.TURTLE);
        parser.setRDFHandler(handler);
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(this.sparqlSamplesFile);
            parser.parse(fis, "");
            this.samplesData = handler.getSamplesData();
        } finally {
            if(fis!=null){
                fis.close();
            }
        }            
    }
}
 
开发者ID:semagrow,项目名称:semagrow,代码行数:19,代码来源:SparqlSamplesController.java

示例10: endRDF

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
@Override
public void endRDF() throws RDFHandlerException {
    if (transactionOpen) {
        try {
            con.commit();
        } catch (RepositoryException e) {
            try {
                con.rollback();
            } catch (RepositoryException e1) {
                throw new RDFHandlerException(e1);
            }
            throw new RDFHandlerException(e);
        }
    }
    super.endRDF();
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:17,代码来源:CancellableCommitSizeInserter.java

示例11: handleStatement

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
@Override
public void handleStatement(Statement st) throws RDFHandlerException {
  try {
    if (Thread.currentThread().isInterrupted()) {
      rdfProcessor.commit();
      throw new RDFHandlerException("Interrupted");
    }
    String graph = st.getContext() == null ? defaultGraph : st.getContext().stringValue();
    rdfProcessor.onQuad(
      isAssertion(),
      handleNode(st.getSubject()),
      st.getPredicate().stringValue(),
      handleNode(st.getObject()),
      (st.getObject() instanceof Literal) ? ((Literal) st.getObject()).getDatatype().toString() : null,
      (st.getObject() instanceof Literal) ? ((Literal) st.getObject()).getLanguage().orElse(null) : null,
      graph
    );
  } catch (RdfProcessingFailedException e) {
    throw new RDFHandlerException(e);
  }
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:22,代码来源:TimRdfHandler.java

示例12: handleNamespace

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
public void handleNamespace(final String prefix,
                            final String uri) throws RDFHandlerException {
    try {
        c.setNamespace(prefix, uri);
    } catch (SailException e) {
        throw new RDFHandlerException(e);
    }
}
 
开发者ID:joshsh,项目名称:graphsail,代码行数:9,代码来源:SailAdder.java

示例13: handleStatement

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
public void handleStatement(final Statement s) throws RDFHandlerException {
    try {
        if (1 <= contexts.length) {
            for (Resource x : contexts) {
                c.addStatement(s.getSubject(), s.getPredicate(), s.getObject(), x);
            }
        } else {
            c.addStatement(s.getSubject(), s.getPredicate(), s.getObject(), s.getContext());
        }
    } catch (SailException e) {
        throw new RDFHandlerException(e);
    }
}
 
开发者ID:joshsh,项目名称:graphsail,代码行数:14,代码来源:SailAdder.java

示例14: evaluate

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
/**
 * evaluate graph query with RDFHandler
 *
 * @param resultHandler
 * @throws QueryEvaluationException
 * @throws RDFHandlerException
 */
@Override
public void evaluate(RDFHandler resultHandler) throws QueryEvaluationException, RDFHandlerException {
    GraphQueryResult queryResult = evaluate();
    if(queryResult.hasNext())
    {
        QueryResults.report(queryResult, resultHandler);
    }
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:16,代码来源:MarkLogicGraphQuery.java

示例15: testExportStatementsWithMultipleContexts

import org.eclipse.rdf4j.rio.RDFHandlerException; //导入依赖的package包/类
@Test
public void testExportStatementsWithMultipleContexts() throws Exception
{
    ValueFactory f = conn.getValueFactory();

    Resource context9 = conn.getValueFactory().createIRI("http://marklogic.com/test/context9");
    final IRI alice = f.createIRI("http://example.org/people/alice");
    IRI name = f.createIRI("http://example.org/ontology/name");
    Literal alicesName = f.createLiteral("Alice");

    Statement st1 = f.createStatement(alice, name, alicesName);
    conn.add(st1, context9);

    Resource context10 = conn.getValueFactory().createIRI("http://marklogic.com/test/context10");
    final IRI mark = f.createIRI("http://example.org/people/mark");
    Literal marksName = f.createLiteral("Mark");

    Statement st2 = f.createStatement(mark, name, marksName);
    conn.add(st2, context10);

    List<String> expected = new ArrayList<>(Arrays.asList(alice.stringValue(), name.stringValue(), alicesName.stringValue(), context9.stringValue(),
            mark.stringValue(), name.stringValue(), marksName.stringValue(), context10.stringValue()));

    List<String> out = new ArrayList<>();
    conn.exportStatements(null, null, null, true, new AbstractRDFHandler() {
        @Override
        public void handleStatement(Statement st) throws RDFHandlerException {
            out.add(st.getSubject().stringValue());
            out.add(st.getPredicate().stringValue());
            out.add(st.getObject().stringValue());
            out.add(st.getContext().stringValue());
        }
    }, context9, context10);

    Assert.assertEquals(expected.size(), out.size());
    conn.clear(context9);
    conn.clear(context10);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:39,代码来源:MarkLogicRepositoryConnectionTest.java


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