@Override public Node createURI(String x, long line, long col) { // Special cases that don't resolve. // <_:....> is a blank node. // <::...> is "don't touch" used for a fixed-up prefix name if ( !RiotLib.isBNodeIRI(x) && !RiotLib.isPrefixIRI(x) ) // Really is an URI! x = resolveIRI(x, line, col); return factory.createURI(x); }
public Prologue sub(PrefixMap newMappings, String base) { // New prefix mappings PrefixMap ext = getPrefixMap() ; if ( newMappings != null ) ext = PrefixMapFactory.extend(ext) ; // New base. IRIResolver r = resolver ; if ( base != null ) r = IRIResolver.create(base) ; return new Prologue(ext, r) ; }
public static Prologue create(String base, PrefixMapping pmapping) { PrefixMap pmap = null ; if ( pmapping != null ) { pmap = PrefixMapFactory.createForInput(pmapping) ; } IRIResolver resolver = null ; if ( base != null ) resolver = IRIResolver.create(base) ; return new Prologue(pmap, resolver) ; }
private static void write$(StreamRDF s, Iterator<Triple> iter) { s.start() ; StreamOps.sendTriplesToStream(iter, s) ; s.finish(); }
/** Send the triples of graph and it's prefix mapping to a StreamRDF, enclosed in stream.start()/stream.finish() */ public static void graphToStream(Graph graph, StreamRDF stream) { stream.start(); sendGraphToStream(graph, stream) ; stream.finish() ; }
/** Send a dataset to a StreamRDF as prefixes, triples and quads, enclosed in stream.start()/stream.finish() */ public static void datasetToStream(DatasetGraph datasetGraph, StreamRDF stream) { stream.start() ; sendDatasetToStream(datasetGraph, stream) ; stream.finish() ; }
static ParserProfile profile() { // Don't do anything with IRIs or blank nodes. Prologue prologue = new Prologue(PrefixMapFactory.createForInput(), IRIResolver.createNoResolve()) ; ErrorHandler handler = ErrorHandlerFactory.getDefaultErrorHandler() ; FactoryRDF factory = RiotLib.factoryRDF(LabelToNode.createUseLabelAsGiven()) ; ParserProfile profile = RiotLib.createParserProfile(factory, handler, false); return profile ; }
@Override protected void emit(Node subject, Node predicate, Node object) { Triple t = profile.createTriple(subject, predicate, object, currLine, currCol) ; dest.triple(t) ; } }
/** Write a Graph in streaming fashion * * @param output OutputStream * @param graph Graph to write * @param lang Syntax */ public static void write(OutputStream output, Graph graph, RDFFormat lang) { StreamRDF stream = getWriterStream(output, lang) ; StreamOps.graphToStream(graph, stream) ; }
/** Write a DatasetGraph in streaming fashion * * @param output OutputStream * @param datasetGraph DatasetGraph to write * @param format Syntax */ public static void write(OutputStream output, DatasetGraph datasetGraph, RDFFormat format) { StreamRDF stream = getWriterStream(output, format) ; StreamOps.datasetToStream(datasetGraph, stream) ; }
/** Get a StreamRDF destination that will output in syntax {@code Lang} * and is guaranteed to do so in a scaling, streaming fashion. * @param output OutputStream * @param lang The syntax * @return StreamRDF, or null if Lang does not have a streaming format. * @see StreamOps#graphToStream * @see StreamOps#datasetToStream */ public static StreamRDF getWriterStream(OutputStream output, Lang lang) { RDFFormat fmt = registry.choose(lang) ; return getWriterStream(output, fmt) ; }
@Override public void add(String prefix, IRI iri) { prefix = canonicalPrefix(prefix); // Add to local always. local.add(prefix, iri); }
/** * Creates a new prefix map, initialized from a Map of prefix to IRI string. * * @param pmap Mapping from prefix to IRI string * @return Prefix Map */ public static PrefixMap createForInput(Map<String, String> pmap) { PrefixMap created = createForInput(); created.putAll(pmap); return created; }
/** * Creates a new prefix map, initialized from a Map of prefix to IRI string. * * @param pmap Mapping from prefix to IRI string * @return Prefix Map */ public static PrefixMap createForOutput(Map<String, String> pmap) { PrefixMap created = createForOutput(); created.putAll(pmap); return created; }
/** Write a DatasetGraph in streaming fashion * * @param output OutputStream * @param datasetGraph DatasetGraph to write * @param lang Syntax */ public static void write(OutputStream output, DatasetGraph datasetGraph, Lang lang) { RDFFormat fmt = registry.choose(lang) ; write(output, datasetGraph, fmt) ; }
@Override protected PrefixMap getPrefixMap() { return new PrefixMapWrapper(new PrefixMapStd()); } }
/** Create a quad - this operation call {@link #checkTriple} if checking is enabled. */ @Override public Quad createQuad(Node graph, Node subject, Node predicate, Node object, long line, long col) { if ( checking ) checkQuad(graph, subject, predicate, object, line, col); return factory.createQuad(graph, subject, predicate, object); }
public Prologue sub(PrefixMap newMappings, String base) { // New prefix mappings PrefixMap ext = getPrefixMap() ; if ( newMappings != null ) ext = PrefixMapFactory.extend(ext) ; // New base. IRIResolver r = resolver ; if ( base != null ) r = IRIResolver.create(base) ; return new Prologue(ext, r) ; }