本文整理汇总了Java中org.openrdf.rio.RDFWriterFactory类的典型用法代码示例。如果您正苦于以下问题:Java RDFWriterFactory类的具体用法?Java RDFWriterFactory怎么用?Java RDFWriterFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RDFWriterFactory类属于org.openrdf.rio包,在下文中一共展示了RDFWriterFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExportStatementsResult
import org.openrdf.rio.RDFWriterFactory; //导入依赖的package包/类
/**
* Get all statements and export them as RDF.
*
* @param repository the Repository object
* @param request the HttpServletRequest object
* @param response the HttpServletResponse object
* @return a model and view for exporting the statements.
* @throws ClientHTTPException throws when errors in parameters
*/
private ModelAndView getExportStatementsResult(final Repository repository, final HttpServletRequest request,
final HttpServletResponse response)
throws ClientHTTPException {
ProtocolUtil.logRequestParameters(request);
ValueFactory vf = repository.getValueFactory();
URI graph = getGraphName(request, vf);
RDFWriterFactory rdfWriterFactory = ProtocolUtil.getAcceptableService(request, response,
RDFWriterRegistry.getInstance());
Map<String, Object> model = new HashMap<String, Object>();
model.put(ExportStatementsView.CONTEXTS_KEY, new Resource[] { graph });
model.put(ExportStatementsView.FACTORY_KEY, rdfWriterFactory);
model.put(ExportStatementsView.USE_INFERENCING_KEY, true);
model.put(ExportStatementsView.HEADERS_ONLY, METHOD_HEAD.equals(request.getMethod()));
return new ModelAndView(ExportStatementsView.getInstance(), model);
}
示例2: createWriter
import org.openrdf.rio.RDFWriterFactory; //导入依赖的package包/类
private RDFWriter createWriter(StringWriter writer) {
RDFWriter result=null;
if(format.equals(Format.TURTLE)) {
result=new TurtlePrettyPrinter(new MemValueFactory().createURI(baseURI.toString()),writer);
} else {
RDFWriterRegistry registry=RDFWriterRegistry.getInstance();
RDFFormat rawFormat=Rio.getWriterFormatForMIMEType(format.getMime(),RDFFormat.RDFXML);
RDFWriterFactory factory=registry.get(rawFormat);
result=factory.getWriter(writer);
if(format.equals(Format.JSON_LD)) {
result.getWriterConfig().set(JSONLDSettings.JSONLD_MODE,JSONLDMode.FLATTEN);
result.getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT,true);
}
}
return result;
}
示例3: SPARQLGraphStreamingOutput
import org.openrdf.rio.RDFWriterFactory; //导入依赖的package包/类
/**
* Creates a new graph streaming output that executes a CONSTRUCT query
* and streams the result.
*
* @param query the CONSTRUCT query to execute
* @param writerFactory a RDF writer factory to use for serialisation
* @param conn the connection to use for query execution
*/
public SPARQLGraphStreamingOutput(
GraphQuery query,
RDFWriterFactory writerFactory,
RepositoryConnection conn) {
super(conn);
this.query = query;
this.factory = writerFactory;
}
示例4: writeN3
import org.openrdf.rio.RDFWriterFactory; //导入依赖的package包/类
private void writeN3( Iterable<Statement> graph )
throws RDFHandlerException, IOException
{
RDFWriterFactory writerFactory = new N3WriterFactory();
RDFWriter writer = writerFactory.getWriter( System.out );
writeOutput( writer, graph );
}
示例5: writeXml
import org.openrdf.rio.RDFWriterFactory; //导入依赖的package包/类
private void writeXml( Iterable<Statement> graph )
throws RDFHandlerException, IOException
{
RDFWriterFactory writerFactory = new RDFXMLWriterFactory();
RDFWriter writer = writerFactory.getWriter( System.out );
writeOutput( writer, graph );
}
示例6: getExportStatementsResult
import org.openrdf.rio.RDFWriterFactory; //导入依赖的package包/类
/**
* Get all statements and export them as RDF.
*
* @param repository the Repository object
* @param request the HttpServletRequest object
* @param response the HttpServletResponse object
* @return a model and view for exporting the statements.
* @throws ClientHTTPException throws when there errors in parsing the request
*/
private ModelAndView getExportStatementsResult(final Repository repository, final HttpServletRequest request,
final HttpServletResponse response)
throws ClientHTTPException {
ProtocolUtil.logRequestParameters(request);
ValueFactory vf = repository.getValueFactory();
Resource subj = ProtocolUtil.parseResourceParam(request, SUBJECT_PARAM_NAME, vf);
URI pred = ProtocolUtil.parseURIParam(request, PREDICATE_PARAM_NAME, vf);
Value obj = ProtocolUtil.parseValueParam(request, OBJECT_PARAM_NAME, vf);
Resource[] contexts = ProtocolUtil.parseContextParam(request, CONTEXT_PARAM_NAME, vf);
boolean useInferencing = ProtocolUtil.parseBooleanParam(request, INCLUDE_INFERRED_PARAM_NAME, true);
RDFWriterFactory rdfWriterFactory = ProtocolUtil.getAcceptableService(request, response,
RDFWriterRegistry.getInstance());
Map<String, Object> model = new HashMap<String, Object>();
model.put(ExportStatementsView.SUBJECT_KEY, subj);
model.put(ExportStatementsView.PREDICATE_KEY, pred);
model.put(ExportStatementsView.OBJECT_KEY, obj);
model.put(ExportStatementsView.CONTEXTS_KEY, contexts);
model.put(ExportStatementsView.USE_INFERENCING_KEY, Boolean.valueOf(useInferencing));
model.put(ExportStatementsView.FACTORY_KEY, rdfWriterFactory);
model.put(ExportStatementsView.HEADERS_ONLY, METHOD_HEAD.equals(request.getMethod()));
model.put(ExportStatementsView.REPO_KEY, repository);
return new ModelAndView(ExportStatementsView.getInstance(), model);
}
示例7: getWriterIfPossible
import org.openrdf.rio.RDFWriterFactory; //导入依赖的package包/类
/**
* This method is required as at last check the BinaryRDFWriterFactory was not fully implemeneted.
* @param format
* @param writer
* @return
*/
private static RDFWriter getWriterIfPossible(RDFFormat format, Writer writer){
RDFWriterRegistry register = RDFWriterRegistry.getInstance();
RDFWriterFactory factory = register.get(format);
if (factory == null){
return null;
}
try {
return factory.getWriter(writer);
} catch (Exception ex){
logger.error(ex);
return null;
}
}
示例8: AbstractSerializer
import org.openrdf.rio.RDFWriterFactory; //导入依赖的package包/类
protected AbstractSerializer( Class<? extends RDFWriterFactory> writerFactoryClass )
{
this.writerFactoryClass = writerFactoryClass;
}
示例9: getRDFWriterFactory
import org.openrdf.rio.RDFWriterFactory; //导入依赖的package包/类
/**
* Returns a {@link RDFWriterFactory} that produces RDF data according to a
* given MIME-type.
*
* @param mimetype the mimetype
* @return the corresponding writer factory
*/
private RDFWriterFactory getRDFWriterFactory(String mimetype) {
RDFWriterRegistry registry = RDFWriterRegistry.getInstance();
return registry.get(getRDFFormat(mimetype));
}