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 + "'"); }
private void test(String filename) { Model m = readModel(filename) ; ByteArrayOutputStream out2 = new ByteArrayOutputStream() ; RDFDataMgr.write(out2, m, RDFWriterRegistry.getFormatForJenaWriter(jenaFormatName)) ; ByteArrayOutputStream out1 = new ByteArrayOutputStream() ; m.write(out1, jenaFormatName) ; try { assertArrayEquals("Format: "+jenaFormatName, out2.toByteArray(), out1.toByteArray()) ; } catch (AssertionError ex) { String s1 = Bytes.bytes2string(out1.toByteArray()) ; String s2 = Bytes.bytes2string(out2.toByteArray()) ; System.out.print(s1) ; System.out.print(s2) ; throw ex ; } } }