本文整理了Java中org.apache.jena.riot.RDFLanguages.isQuads
方法的一些代码示例,展示了RDFLanguages.isQuads
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RDFLanguages.isQuads
方法的具体详情如下:
包路径:org.apache.jena.riot.RDFLanguages
类名称:RDFLanguages
方法名:isQuads
[英]return true if the language is registered as a quads language.
[中]如果语言注册为quads语言,则返回true。
代码示例来源:origin: apache/jena
public void setDatasetContentType(String contentType) {
// Check that this is a valid setting
Lang lang = RDFLanguages.contentTypeToLang(contentType);
if (lang == null)
throw new IllegalArgumentException("Given Content Type '" + contentType + "' is not supported by RIOT");
if (!RDFLanguages.isQuads(lang))
throw new IllegalArgumentException("Given Content Type '" + contentType + "' is not a RDF Dataset format");
datasetContentType = contentType;
}
代码示例来源:origin: apache/jena
@Override
protected RecordReader<LongWritable, QuadWritable> selectRecordReader(Lang lang) throws IOException {
if (!RDFLanguages.isQuads(lang))
throw new IOException(
lang.getLabel()
+ " is not a RDF quads format, perhaps you wanted TriplesInputFormat or TriplesOrQuadsInputFormat instead?");
// This will throw an appropriate error if the language does not support
// triples
return HadoopRdfIORegistry.createQuadReader(lang);
}
代码示例来源:origin: org.apache.jena/jena-elephas-io
@Override
protected RecordReader<LongWritable, QuadWritable> selectRecordReader(Lang lang) throws IOException {
if (!RDFLanguages.isQuads(lang))
throw new IOException(
lang.getLabel()
+ " is not a RDF quads format, perhaps you wanted TriplesInputFormat or TriplesOrQuadsInputFormat instead?");
// This will throw an appropriate error if the language does not support
// triples
return HadoopRdfIORegistry.createQuadReader(lang);
}
代码示例来源:origin: apache/jena
@Override
protected RecordWriter<TKey, QuadWritable> getRecordWriter(Writer writer, Configuration config, Path outputPath)
throws IOException {
Lang lang = RDFLanguages.filenameToLang(outputPath.getName());
if (lang == null)
throw new IOException("There is no registered RDF language for the output file " + outputPath.toString());
if (!RDFLanguages.isQuads(lang))
throw new IOException(
lang.getName()
+ " is not a RDF quads format, perhaps you wanted TriplesOutputFormat or TriplesOrQuadsOutputFormat instead?");
// This will throw an appropriate error if the language does not support
// writing quads
return HadoopRdfIORegistry.<TKey> createQuadWriter(lang, writer, config);
}
代码示例来源:origin: org.apache.jena/jena-elephas-io
@Override
protected RecordWriter<TKey, QuadWritable> getRecordWriter(Writer writer, Configuration config, Path outputPath)
throws IOException {
Lang lang = RDFLanguages.filenameToLang(outputPath.getName());
if (lang == null)
throw new IOException("There is no registered RDF language for the output file " + outputPath.toString());
if (!RDFLanguages.isQuads(lang))
throw new IOException(
lang.getName()
+ " is not a RDF quads format, perhaps you wanted TriplesOutputFormat or TriplesOrQuadsOutputFormat instead?");
// This will throw an appropriate error if the language does not support
// writing quads
return HadoopRdfIORegistry.<TKey> createQuadWriter(lang, writer, config);
}
代码示例来源:origin: apache/jena
/** Set the output format for sending RDF Datasets to the remote server.
* This is used for HTTP PUT and POST to a dataset.
* This must be a quads format.
*/
public RDFConnectionRemoteBuilder quadsFormat(RDFFormat fmtQuads) {
if ( ! RDFLanguages.isQuads(fmtQuads.getLang()) )
throw new RiotException("Not a language for RDF Datasets: "+fmtQuads);
this.outputQuads = fmtQuads;
return this;
}
代码示例来源:origin: org.apache.jena/jena-rdfconnection
/** Set the output format for sending RDF Datasets to the remote server.
* This is used for HTTP PUT and POST to a dataset.
* This must be a quads format.
*/
public RDFConnectionRemoteBuilder quadsFormat(RDFFormat fmtQuads) {
if ( ! RDFLanguages.isQuads(fmtQuads.getLang()) )
throw new RiotException("Not a language for RDF Datasets: "+fmtQuads);
this.outputQuads = fmtQuads;
return this;
}
代码示例来源:origin: AtomGraph/Core
public boolean isQuadsMediaType(MediaType mediaType)
{
MediaType formatType = new MediaType(mediaType.getType(), mediaType.getSubtype()); // discard charset param
Lang lang = RDFLanguages.contentTypeToLang(formatType.toString());
return lang != null && RDFLanguages.isQuads(lang);
}
代码示例来源:origin: apache/jena
/** Set the output format for sending RDF Datasets to the remote server.
* This is used for HTTP PUT and POST to a dataset.
* This must be a quads format.
*/
public RDFConnectionRemoteBuilder quadsFormat(Lang langQuads) {
Objects.requireNonNull(langQuads);
if ( ! RDFLanguages.isQuads(langQuads) )
throw new RiotException("Not a language for RDF Datasets: "+langQuads);
RDFFormat fmt = RDFWriterRegistry.defaultSerialization(langQuads);
if ( fmt == null )
throw new RiotException("Language name not recognized: "+langQuads);
quadsFormat(fmt);
return this;
}
代码示例来源:origin: org.apache.jena/jena-rdfconnection
/** Set the output format for sending RDF Datasets to the remote server.
* This is used for HTTP PUT and POST to a dataset.
* This must be a quads format.
*/
public RDFConnectionRemoteBuilder quadsFormat(Lang langQuads) {
Objects.requireNonNull(langQuads);
if ( ! RDFLanguages.isQuads(langQuads) )
throw new RiotException("Not a language for RDF Datasets: "+langQuads);
RDFFormat fmt = RDFWriterRegistry.defaultSerialization(langQuads);
if ( fmt == null )
throw new RiotException("Language name not recognized: "+langQuads);
quadsFormat(fmt);
return this;
}
代码示例来源:origin: apache/jena
@Override
protected RecordWriter<TKey, QuadWritable> getRecordWriter(Writer writer, Configuration config, Path outputPath)
throws IOException {
Lang lang = RDFLanguages.filenameToLang(outputPath.getName());
if (lang == null)
throw new IOException("There is no registered RDF language for the output file " + outputPath.toString());
if (!RDFLanguages.isQuads(lang) && !RDFLanguages.isTriples(lang))
throw new IOException(lang.getName() + " is not a RDF triples/quads format");
if (HadoopRdfIORegistry.hasQuadWriter(lang)) {
// Supports quads directly
return HadoopRdfIORegistry.<TKey> createQuadWriter(lang, writer, config);
} else {
// Try to create a triples writer and wrap downwards from quads
// This will throw an error if a triple writer is not available
return new QuadsToTriplesWriter<TKey>(HadoopRdfIORegistry.<TKey> createTripleWriter(lang, writer, config));
}
}
代码示例来源:origin: apache/jena
@Override
protected RecordReader<LongWritable, QuadWritable> selectRecordReader(Lang lang) throws IOException {
if (!RDFLanguages.isQuads(lang) && !RDFLanguages.isTriples(lang))
throw new IOException(lang.getLabel() + " is not a RDF triples/quads format");
if (HadoopRdfIORegistry.hasQuadReader(lang)) {
// Supports quads directly
return HadoopRdfIORegistry.createQuadReader(lang);
} else {
// Try to create a triples reader and wrap upwards into quads
// This will throw an error if a triple reader is not available
return new TriplesToQuadsReader(HadoopRdfIORegistry.createTripleReader(lang));
}
}
代码示例来源:origin: org.apache.jena/jena-elephas-io
@Override
protected RecordReader<LongWritable, QuadWritable> selectRecordReader(Lang lang) throws IOException {
if (!RDFLanguages.isQuads(lang) && !RDFLanguages.isTriples(lang))
throw new IOException(lang.getLabel() + " is not a RDF triples/quads format");
if (HadoopRdfIORegistry.hasQuadReader(lang)) {
// Supports quads directly
return HadoopRdfIORegistry.createQuadReader(lang);
} else {
// Try to create a triples reader and wrap upwards into quads
// This will throw an error if a triple reader is not available
return new TriplesToQuadsReader(HadoopRdfIORegistry.createTripleReader(lang));
}
}
代码示例来源:origin: apache/jena
/** Get a StreamRDF destination that will output in syntax {@code RDFFormat}
* and is guaranteed to do so in a scaling, streaming fashion.
* @param output OutputStream
* @param format The syntax (as an {@link RDFFormat})
* @return StreamRDF, or null if format is not registered for streaming.
* @see StreamOps#graphToStream
* @see StreamOps#datasetToStream
*/
public static StreamRDF getWriterStream(OutputStream output, RDFFormat format) {
StreamRDFWriterFactory x = registry.get(format) ;
if ( x == null )
throw new RiotException("Failed to find a writer factory for "+format) ;
StreamRDF stream = x.create(output, format) ;
if ( ! RDFLanguages.isQuads(format.getLang()) )
// Only pass through triples.
stream = new StreamTriplesOnly(stream) ;
return stream ;
}
代码示例来源:origin: apache/jena
/** Send a file to named graph (or "default" or null for the default graph).
* <p>
* The Content-Type is inferred from the file extension.
* <p>
* "Replace" means overwrite existing data, othewise the date is added to the target.
*/
protected void upload(String graph, String file, boolean replace) {
// if triples
Lang lang = RDFLanguages.filenameToLang(file);
if ( RDFLanguages.isQuads(lang) )
throw new ARQException("Can't load quads into a graph");
if ( ! RDFLanguages.isTriples(lang) )
throw new ARQException("Not an RDF format: "+file+" (lang="+lang+")");
String url = LibRDFConn.urlForGraph(svcGraphStore, graph);
doPutPost(url, file, lang, replace);
}
代码示例来源:origin: org.apache.jena/jena-rdfconnection
/** Send a file to named graph (or "default" or null for the default graph).
* <p>
* The Content-Type is inferred from the file extension.
* <p>
* "Replace" means overwrite existing data, othewise the date is added to the target.
*/
protected void upload(String graph, String file, boolean replace) {
// if triples
Lang lang = RDFLanguages.filenameToLang(file);
if ( RDFLanguages.isQuads(lang) )
throw new ARQException("Can't load quads into a graph");
if ( ! RDFLanguages.isTriples(lang) )
throw new ARQException("Not an RDF format: "+file+" (lang="+lang+")");
String url = LibRDFConn.urlForGraph(svcGraphStore, graph);
doPutPost(url, file, lang, replace);
}
代码示例来源:origin: apache/jena
@Override
protected void exec()
{
DatasetGraph dsg = super.getDatasetGraphTDB() ;
// Prefer stream over fully pretty output formats.
RDFFormat fmt = modLangOutput.getOutputStreamFormat() ;
// Stream writing happens naturally - no need to call StreamRDFWriter.
//if ( fmt != null && StreamRDFWriter.registered(fmt) )
if ( fmt == null )
fmt = modLangOutput.getOutputFormatted() ;
if ( fmt == null )
// Default.
fmt = RDFFormat.NQUADS ;
if ( ! RDFLanguages.isQuads(fmt.getLang() ))
throw new CmdException("Databases can be dumped only in quad formats (e.g. Trig, N-Quads), not "+fmt.getLang()) ;
RDFDataMgr.write(System.out, dsg, fmt) ;
}
}
代码示例来源:origin: apache/jena
@Override
protected void exec() {
DatasetGraph dsg = getDatasetGraph() ;
// Prefer stream over fully pretty output formats.
RDFFormat fmt = modLangOutput.getOutputStreamFormat() ;
// Stream writing happens naturally - no need to call StreamRDFWriter.
//if ( fmt != null && StreamRDFWriter.registered(fmt) )
if ( fmt == null )
fmt = modLangOutput.getOutputFormatted() ;
if ( fmt == null )
// Default.
fmt = RDFFormat.NQUADS ;
if ( ! RDFLanguages.isQuads(fmt.getLang() ))
throw new CmdException("Databases can be dumped only in quad formats (e.g. Trig, N-Quads), not "+fmt.getLang()) ;
RDFFormat fmtFinal = fmt ;
Txn.executeRead(dsg, ()->RDFDataMgr.write(System.out, dsg, fmtFinal));
}
}
代码示例来源:origin: apache/jena
@Test public void jenaSystem_read_1() {
assertTrue(RDFLanguages.isRegistered(lang)) ;
if ( istriples )
assertTrue(RDFLanguages.isTriples(lang)) ;
else
assertFalse(RDFLanguages.isTriples(lang)) ;
if (isquads )
assertTrue(RDFLanguages.isQuads(lang)) ;
else
assertFalse(RDFLanguages.isQuads(lang)) ;
}
代码示例来源:origin: com.github.jsonld-java/jsonld-java-jena
@Test
public void jenaSystem_read_1() {
assertTrue(RDFLanguages.isRegistered(JenaJSONLD.JSONLD));
assertTrue(RDFLanguages.isTriples(JenaJSONLD.JSONLD));
assertTrue(RDFLanguages.isQuads(JenaJSONLD.JSONLD));
}
内容来源于网络,如有侵权,请联系作者删除!