private static RDFFormat chooseFormat(RDFFormat format, Lang lang) { if ( format != null ) return format; if ( lang == null ) //throw new RiotException("No syntax for output") ; return null; format = RDFWriterRegistry.defaultSerialization(lang); return format; }
private static boolean datasetWriterExistsForLang(Lang lang) { RDFFormat serialization = RDFWriterRegistry.defaultSerialization(lang) ; WriterDatasetRIOTFactory wf = RDFWriterRegistry.getWriterDatasetFactory(serialization) ; return wf != null; }
/** Get the graph writer factory associated with the language */ public static WriterGraphRIOTFactory getWriterGraphFactory(Lang lang) { RDFFormat serialization = defaultSerialization(lang) ; if ( serialization == null ) throw new RiotException("No default serialization for language " + lang) ; return getWriterGraphFactory(serialization) ; }
@Test public void jenaSystem_write_3() { assertEquals(jsonldFmt1, RDFWriterRegistry.defaultSerialization(JenaJSONLD.JSONLD)); assertNotNull(RDFWriterRegistry.getWriterGraphFactory(jsonldFmt1)); assertNotNull(RDFWriterRegistry.getWriterGraphFactory(jsonldFmt2)); assertTrue(RDFWriterRegistry.registeredGraphFormats().contains(jsonldFmt1)); assertTrue(RDFWriterRegistry.registeredGraphFormats().contains(jsonldFmt2)); assertNotNull(RDFWriterRegistry.getWriterDatasetFactory(jsonldFmt1)); assertNotNull(RDFWriterRegistry.getWriterDatasetFactory(jsonldFmt2)); assertTrue(RDFWriterRegistry.registeredDatasetFormats().contains(jsonldFmt1)); assertTrue(RDFWriterRegistry.registeredDatasetFormats().contains(jsonldFmt2)); }
@Test public void jenaSystem_write_2() { if ( istriples ) assertNotNull(RDFWriterRegistry.getWriterGraphFactory(lang)) ; if ( isquads ) assertNotNull(RDFWriterRegistry.getWriterDatasetFactory(lang)) ; assertNotNull(RDFWriterRegistry.defaultSerialization(lang)) ; }
private void testregistration(RDFFormat format) { assertTrue("No writer registered for format "+format, RDFWriterRegistry.contains(format)) ; assertTrue( RDFWriterRegistry.getWriterGraphFactory(format) != null || RDFWriterRegistry.getWriterDatasetFactory(format) != null ) ; }
@Test public void jenaSystem_write_2() { assertTrue(RDFWriterRegistry.registeredGraphFormats().contains(format)) ; if ( istriples ) assertNotNull(RDFWriterRegistry.getWriterGraphFactory(format)) ; if ( isquads ) assertNotNull(RDFWriterRegistry.getWriterDatasetFactory(format)) ; }
@Override public void postParse() { // Try as dataset, then as graph. WriterDatasetRIOTFactory w = RDFWriterRegistry.getWriterDatasetFactory(fmt) ; if ( w != null ) { RDFDataMgr.write(outputWrite, dsg, fmt) ; return ; } WriterGraphRIOTFactory wg = RDFWriterRegistry.getWriterGraphFactory(fmt) ; if ( wg != null ) { RDFDataMgr.write(System.out, dsg.getDefaultGraph(), fmt) ; return ; } throw new InternalErrorException("failed to find the writer: "+fmt) ; } } ;
@Test public void setup_04() { assertTrue(RDFWriterRegistry.contains(THRIFT)) ; assertNotNull(RDFWriterRegistry.getWriterDatasetFactory(THRIFT)) ; assertTrue(RDFWriterRegistry.contains(RDFFormat.RDF_THRIFT)) ; assertNotNull(RDFWriterRegistry.getWriterDatasetFactory(RDFFormat.RDF_THRIFT)) ; assertTrue(RDFWriterRegistry.contains(RDFFormat.RDF_THRIFT_VALUES)) ; assertNotNull(RDFWriterRegistry.getWriterDatasetFactory(RDFFormat.RDF_THRIFT_VALUES)) ; } }
private static WriterDatasetRIOT createDatasetWriter$(RDFFormat serialization) { WriterDatasetRIOTFactory wf = RDFWriterRegistry.getWriterDatasetFactory(serialization); if ( wf == null ) throw new RiotException("No dataset writer for " + serialization); return wf.create(serialization); }
@Test public void xjenaSystem_write_3() { RDFWriterRegistry.contains(format); if ( istriples ) assertTrue(RDFWriterRegistry.registeredGraphFormats().contains(format)); if ( isquads ) assertTrue(RDFWriterRegistry.registeredDatasetFormats().contains(format)); } }
private static WriterGraphRIOT createGraphWriter$(RDFFormat serialization) { WriterGraphRIOTFactory wf = RDFWriterRegistry.getWriterGraphFactory(serialization); if ( wf == null ) throw new RiotException("No graph writer for " + serialization); return wf.create(serialization); }
/** Does the language have a registered output format? */ public static boolean contains(Lang lang) { if ( !langToFormat.containsKey(lang) ) return false ; RDFFormat fmt = langToFormat.get(lang) ; return contains(fmt) ; }
protected RDFWriterBuilder writer() { if ( jenaName == null ) throw new IllegalArgumentException("Jena writer name is null"); // For writing via model.write(), use any old names for jena writers. (As of 2107-03 - there are none) RDFFormat format = RDFWriterRegistry.getFormatForJenaWriter(jenaName) ; RDFWriterBuilder builder = org.apache.jena.riot.RDFWriter.create(); if ( format != null ) return builder.format(format); Lang lang = RDFLanguages.nameToLang(jenaName); if ( lang != null ) return builder.lang(lang); throw new RiotException("No graph writer for '" + jenaName + "'"); }
public static void init() { if ( initialized ) return ; synchronized (initLock) { if ( initialized ) return ; initialized = true ; // Becareful with what this touches - don't touch ARQ.* // because that depends on Jena core and we may be // initializing because IO_Ctl (ie. Jena core) // called RIOT.init. RDFLanguages.init() ; RDFParserRegistry.init() ; RDFWriterRegistry.init() ; IO_Jena.wireIntoJena() ; // Don't register JMX info with ARQ as it may not be initialized // itself and we can get into a circularity. // This is done in ARQ.init at the proper moment. } }
@Test public void jenaSystem_write_2() { assertNotNull(RDFWriterRegistry.getWriterGraphFactory(JenaJSONLD.JSONLD)); assertNotNull(RDFWriterRegistry.getWriterDatasetFactory(JenaJSONLD.JSONLD)); assertNotNull(RDFWriterRegistry.defaultSerialization(JenaJSONLD.JSONLD)); }
private void testregistration(Lang lang) { assertTrue("No writer registered for language "+lang, RDFWriterRegistry.contains(lang)) ; assertTrue( RDFWriterRegistry.getWriterGraphFactory(lang) != null || RDFWriterRegistry.getWriterDatasetFactory(lang) != null ) ; }
@Override public void postParse() { // Try as dataset, then as graph. WriterDatasetRIOTFactory w = RDFWriterRegistry.getWriterDatasetFactory(fmt) ; if ( w != null ) { RDFDataMgr.write(outputWrite, dsg, fmt) ; return ; } WriterGraphRIOTFactory wg = RDFWriterRegistry.getWriterGraphFactory(fmt) ; if ( wg != null ) { RDFDataMgr.write(System.out, dsg.getDefaultGraph(), fmt) ; return ; } throw new InternalErrorException("failed to find the writer: "+fmt) ; } } ;
private static WriterDatasetRIOT createDatasetWriter$(RDFFormat serialization) { WriterDatasetRIOTFactory wf = RDFWriterRegistry.getWriterDatasetFactory(serialization); if ( wf == null ) throw new RiotException("No dataset writer for " + serialization); return wf.create(serialization); }
private static WriterGraphRIOT createGraphWriter$(RDFFormat serialization) { WriterGraphRIOTFactory wf = RDFWriterRegistry.getWriterGraphFactory(serialization); if ( wf == null ) throw new RiotException("No graph writer for " + serialization); return wf.create(serialization); }