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


Java Rio.write方法代码示例

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


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

示例1: convertStmtListToRDF

import org.eclipse.rdf4j.rio.Rio; //导入方法依赖的package包/类
/**
 * Convert Model of RMap object to an OutputStream of RDF.
 *
 * @param model Model of RMap object to be converted
 * @param rdfType RDF Format for serialization
 * @return OutputStream containing RDF serialization of RMap object
 * @throws RMapException the r map exception
 */
public OutputStream convertStmtListToRDF(Model model, RDFType rdfType) 
throws RMapException	{
	if (model==null){
		throw new RMapException("Null or empty Statement model");
	}
	if (rdfType==null){
		throw new RMapException("RDF format name null");
	}	
	RDFFormat rdfFormat = null;
	OutputStream bOut = new ByteArrayOutputStream();
	try {
		rdfFormat = this.getRDFFormatConstant(rdfType);
		Rio.write(model, bOut, rdfFormat);
	} catch (Exception e) {
		throw new RMapException("Exception thrown creating RDF from statement list",e);
	}
	return bOut;		
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:27,代码来源:RioRDFHandler.java

示例2: triple2Rdf

import org.eclipse.rdf4j.rio.Rio; //导入方法依赖的package包/类
public OutputStream triple2Rdf(RMapTriple triple, RDFType rdfType) throws RMapException, RMapDefectiveArgumentException {
	if (triple == null){
		throw new RMapException("Null triple");
	}
	if (rdfType==null){
		throw new RMapException("null rdf format name");
	}
	Statement stmt = ORAdapter.rmapTriple2Rdf4jStatement(triple);

	RDFFormat rdfFormat = null;
	OutputStream bOut = new ByteArrayOutputStream();
	try {
		rdfFormat = this.getRDFFormatConstant(rdfType);
		Rio.write(stmt, bOut, rdfFormat);
	} catch (Exception e) {
		throw new RMapException("Exception thrown creating RDF from statement",e);
	}
	return bOut;
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:20,代码来源:RioRDFHandler.java

示例3: setUp

import org.eclipse.rdf4j.rio.Rio; //导入方法依赖的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

示例4: writeTo

import org.eclipse.rdf4j.rio.Rio; //导入方法依赖的package包/类
@Override
public void writeTo(GraphEntity graphEntity, Class<?> type, Type genericType,
    Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> multivaluedMap,
    OutputStream outputStream) throws IOException {
  Model model = QueryResults.asModel(graphEntity.getQueryResult());
  Rio.write(model, outputStream, format);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:8,代码来源:GraphEntityWriter.java

示例5: handle

import org.eclipse.rdf4j.rio.Rio; //导入方法依赖的package包/类
@Override
public void handle(HttpExchange httpExchange) {
  try {
    ByteArrayOutputStream output = new ByteArrayOutputStream();

    if (parent.graphResult == null && parent.tupleResultBuilder == null) {
      fail("Please specify either a graph or tuple result for your stub.");
    }

    if (parent.graphResult != null) {
      httpExchange.getResponseHeaders().add("Content-Type", MediaTypes.TURTLE);
      Rio.write(parent.graphResult, output, RDFFormat.TURTLE);
    } else {
      httpExchange.getResponseHeaders().add("Content-Type", MediaTypes.SPARQL_RESULTS_JSON);
      TupleQueryResultWriter writer = new SPARQLResultsJSONWriter(output);
      QueryResults.report(parent.tupleResultBuilder.build(), writer);
    }

    httpExchange.sendResponseHeaders(200, output.size());
    OutputStream responseBody = httpExchange.getResponseBody();
    responseBody.write(output.toByteArray());
    responseBody.close();

  } catch (Exception ex) {
    fail(ex.getMessage());
  }
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:28,代码来源:SparqlHttpStub.java

示例6: writeInternal

import org.eclipse.rdf4j.rio.Rio; //导入方法依赖的package包/类
@Override
@RunAsSystem
protected void writeInternal(Model model, HttpOutputMessage httpOutputMessage) throws IOException
{
	Rio.write(model, httpOutputMessage.getBody(), TURTLE);
	httpOutputMessage.getBody().close();
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:8,代码来源:RdfConverter.java

示例7: commit

import org.eclipse.rdf4j.rio.Rio; //导入方法依赖的package包/类
@Override
public void commit() throws RdfProcessingFailedException {
  try {
    inputStream.close();
    FileWriter newFileWriter = new FileWriter(descriptionFile, false); //false for overwrite file (true=concat)
    Rio.write(model, newFileWriter, RDFFormat.RDFXML);
    newFileWriter.flush();
    newFileWriter.close();
    importStatus.setStatus("Description saved");
  } catch (IOException e) {
    throw new RdfProcessingFailedException(e);
  }
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:14,代码来源:RdfDescriptionSaver.java

示例8: createDescriptionNode

import org.eclipse.rdf4j.rio.Rio; //导入方法依赖的package包/类
private void createDescriptionNode(Description description, RDFFormat parseFormat, Interpreter interpreter) {
  try {
    Model model = Rio.parse(IOUtils.toInputStream(description.getRawContent()), "", parseFormat);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Rio.write(model, out, RDFFormat.JSONLD);
    ObjectMapper mapper = new ObjectMapper();
    content = mapper.readTree(out.toString());
  } catch (Exception e) { // catch all e.g. org.xml.sax.SAXParseException
    rawContent = description.getRawContent();
    error = new ErrorView(e, interpreter);
  }
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:13,代码来源:DescriptionView.java

示例9: saveAlignment

import org.eclipse.rdf4j.rio.Rio; //导入方法依赖的package包/类
@Override
public <ONTORES1, ONTORES2> void saveAlignment(
		Alignment<ONTORES1, ONTORES2> alignment, String pathToSave,
		VALIDITY validityWanted) throws IOException {


	ValueFactory factory = SimpleValueFactory.getInstance();
	Model model = new LinkedHashModel();
	model.setNamespace("skos", "http://www.w3.org/2004/02/skos/core#");
	model.setNamespace("", "http://www.w3.org/2004/02/skos/core#");

	final OntoContainer<ONTORES1> onto1 = alignment.getOnto1();
	final OntoContainer<ONTORES2> onto2 = alignment.getOnto2();

	Statement typeStatement =null;

	for (Mapping<ONTORES1, ONTORES2> mapping : alignment.getMapping()) {
		if(validityWanted != null && !mapping.getValidity().equals(validityWanted))
			continue;

		IRI propertyToUsed = null;

		if(mapping.getType() == MAPPING_TYPE.EQUIV)
			propertyToUsed = SKOS.EXACT_MATCH;

		else if(mapping.getType() == MAPPING_TYPE.SUBSUMES)
			propertyToUsed = SKOS.BROAD_MATCH;
		else if(mapping.getType() == MAPPING_TYPE.SUBSUMEDBY)
			propertyToUsed = SKOS.NARROW_MATCH;		
		else if(mapping.getType() == MAPPING_TYPE.OVERLAP)
			propertyToUsed = SKOS.CLOSE_MATCH;			   
		else if(mapping.getType() == MAPPING_TYPE.RELATED)
			propertyToUsed = SKOS.RELATED;
		else
			continue;

		IRI res1= factory.createIRI(onto1.getURI(mapping.getFirstConcept()).toString());
		IRI res2= factory.createIRI(onto2.getURI(mapping.getSecondConcept()).toString());
		typeStatement=factory.createStatement(res1, propertyToUsed, res2);
		model.add(typeStatement);
	}

	FileOutputStream stream = new FileOutputStream(pathToSave);
	Rio.write(model, stream, RDFFormat.RDFXML);	
}
 
开发者ID:lmazuel,项目名称:onagui,代码行数:46,代码来源:SkosImpl.java

示例10: main

import org.eclipse.rdf4j.rio.Rio; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  InputStream resourceAsStream = new FileInputStream(args[0]);
  Model model = Rio.parse(resourceAsStream, "", RDFFormat.NQUADS);
  Rio.write(model, new FileOutputStream(args[1]), RDFFormat.TURTLE);
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:6,代码来源:RdfConverter.java


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