/** Set the output format for sending RDF graphs to the remote server. * This is used for the SPARQ Graph Store Protocol. */ public RDFConnectionRemoteBuilder triplesFormat(RDFFormat fmtTriples) { if ( ! RDFLanguages.isTriples(fmtTriples.getLang()) ) throw new RiotException("Not a language for RDF Graphs: "+fmtTriples); this.outputTriples = fmtTriples; return this; }
private ReaderRIOT createReader(ContentType ct) { Lang lang = RDFLanguages.contentTypeToLang(ct); if ( lang == null ) return null; @SuppressWarnings("deprecation") ReaderRIOTFactory r = RDFParserRegistry.getFactory(lang); if ( r == null ) return null; ReaderRIOT reader = createReader(r, lang); return reader ; }
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); }
protected static void read(Model model, String in, String langStr, String base) { Lang lang = null ; if ( langStr != null ) lang = RDFLanguages.nameToLang(langStr) ; RDFDataMgr.read(model, in, base, lang) ; } }
public static ContentType guessContentType(String resourceName) { if ( resourceName == null ) return null ; Lang lang = filenameToLang(resourceName) ; if ( lang == null ) return null ; return lang.getContentType() ; }
/** 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; }
/** Get the dataset writer factory associated with the language */ public static WriterDatasetRIOTFactory getWriterDatasetFactory(Lang lang) { RDFFormat serialization = defaultSerialization(lang) ; if ( serialization == null ) throw new RiotException("No default serialization for language " + lang) ; return getWriterDatasetFactory(serialization) ; }
/** Determine the Lang, given the URI target, any content type header string and a hint */ public static Lang determineLang(String target, String ctStr, Lang hintLang) { ContentType ct = WebContent.determineCT(ctStr, hintLang, target) ; if ( ct == null ) return hintLang ; Lang lang = RDFLanguages.contentTypeToLang(ct) ; if (lang == null ) return hintLang ; return lang ; }
/** Map {@link Lang} to {@link RDFFormat}, or throw an exception. */ private static RDFFormat langToFormatOrException(Lang lang) { RDFFormat serialization = RDFWriterRegistry.defaultSerialization(lang); if ( serialization == null ) throw new RiotException("No output format for "+lang) ; return 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); }
static void test(String url, String ct, Lang hint, Lang expected) { ContentType x = WebContent.determineCT(ct, hint, url) ; Lang lang = RDFDataMgr.determineLang(url, ct, hint) ; assertEquals(expected, lang) ; } }
@Override public void fatal(String message, long line, long col) { throw new RiotException(fmtMessage(message, line, col)) ; } } ;
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); }
/** * Parse the source, sending the results to a {@link Model}. * The source must be for triples; any quads are discarded. * Short form for {@code build().parse(model)} * which sends triples and prefixes to the {@code Model}. * * @param model */ public void parse(Model model) { build().parse(model); }