private static RDFWriter getRioWriter(OutputStream stream) throws RDFHandlerException { RDFWriter writer = Rio.createWriter(RDFFormat.JSONLD, stream); writer.handleNamespace("sp", "https://streampipes.org/vocabulary/v1/"); writer.handleNamespace("ssn", "http://purl.oclc.org/NET/ssnx/ssn#"); writer.handleNamespace("xsd", "http://www.w3.org/2001/XMLSchema#"); writer.handleNamespace("empire", "urn:clarkparsia.com:empire:"); writer.handleNamespace("spi", "urn:streampipes.org:spi:"); writer.getWriterConfig().set(JSONLDSettings.JSONLD_MODE, JSONLDMode.COMPACT); writer.getWriterConfig().set(JSONLDSettings.OPTIMIZE, true); writer.getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT, true); return writer; }
/** * Tries to match the extension of a file name against the list of RDF formats that can be parsed. * * @param fileName * A file name. * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForFileName(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForFileName(String fileName) { return RDFFormat.matchFileName(fileName, RDFParserRegistry.getInstance().getKeys()); }
/** * Tries to match the extension of a file name against the list of RDF formats that can be written. * * @param fileName * A file name. * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getWriterFormatForFileName(String, RDFFormat) */ public static Optional<RDFFormat> getWriterFormatForFileName(String fileName) { return RDFFormat.matchFileName(fileName, RDFWriterRegistry.getInstance().getKeys()); }
/** * Tries to match a MIME type against the list of RDF formats that can be parsed. * * @param mimeType * A MIME type, e.g. "application/rdf+xml". * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForMIMEType(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForMIMEType(String mimeType) { return RDFFormat.matchMIMEType(mimeType, RDFParserRegistry.getInstance().getKeys()); }
public RDFWriter(OutputStream os, RDFFormat format) { this.writer = Rio.createWriter(format, os); this.writer.startRDF(); } public RDFWriter(java.io.Writer writer, RDFFormat format) {
/** * Reports a fatal error with associated line- and column number to the registered ParseErrorListener, if * any, and throws a <tt>ParseException</tt> afterwards. */ public static void reportFatalError(String msg, long lineNo, long columnNo, ParseErrorListener errListener) throws RDFParseException { if (errListener != null) { errListener.fatalError(msg, lineNo, columnNo); } throw new RDFParseException(msg, lineNo, columnNo); }
/** * Tries to match a MIME type against the list of RDF formats that can be written. * * @param mimeType * A MIME type, e.g. "application/rdf+xml". * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getWriterFormatForMIMEType(String, RDFFormat) */ public static Optional<RDFFormat> getWriterFormatForMIMEType(String mimeType) { return RDFFormat.matchMIMEType(mimeType, RDFWriterRegistry.getInstance().getKeys()); }
/** * Constructor for super-classes to specify which * {@link RDFFormat} they support. * * @param format The {@link RDFFormat} that this instance supports. */ public RioRDFPrefixDocumentFormat(RDFFormat format) { this.format = format; formatName = this.format.getName(); }
private static RDFWriter getRioWriter(OutputStream stream) throws RDFHandlerException { RDFWriter writer = Rio.createWriter(RDFFormat.JSONLD, stream); writer.handleNamespace("sp", "https://streampipes.org/vocabulary/v1/"); writer.handleNamespace("ssn", "http://purl.oclc.org/NET/ssnx/ssn#"); writer.handleNamespace("xsd", "http://www.w3.org/2001/XMLSchema#"); writer.handleNamespace("empire", "urn:clarkparsia.com:empire:"); writer.handleNamespace("spi", "urn:streampipes.org:spi:"); writer.getWriterConfig().set(JSONLDSettings.JSONLD_MODE, JSONLDMode.COMPACT); writer.getWriterConfig().set(JSONLDSettings.OPTIMIZE, true); writer.getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT, true); return writer; }
/** * Tries to match the extension of a file name against the list of RDF formats that can be parsed. * * @param fileName * A file name. * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForFileName(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForFileName(String fileName) { return RDFFormat.matchFileName(fileName, RDFParserRegistry.getInstance().getKeys()); }
/** * Tries to match a MIME type against the list of RDF formats that can be parsed. * * @param mimeType * A MIME type, e.g. "application/rdf+xml". * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForMIMEType(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForMIMEType(String mimeType) { return RDFFormat.matchMIMEType(mimeType, RDFParserRegistry.getInstance().getKeys()); }
public RDFWriter(java.io.Writer writer, RDFFormat format) { this.writer = Rio.createWriter(format, writer); this.writer.startRDF(); } // /////////////////////////////////////////////////////////////////////////
/** * Reports a fatal error with associated line- and column number to the registered ParseErrorListener, if * any, and throws a <tt>ParseException</tt> afterwards. */ public static void reportFatalError(String msg, long lineNo, long columnNo, ParseErrorListener errListener) throws RDFParseException { if (errListener != null) { errListener.fatalError(msg, lineNo, columnNo); } throw new RDFParseException(msg, lineNo, columnNo); }
/** * Tries to match the extension of a file name against the list of RDF formats that can be written. * * @param fileName * A file name. * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getWriterFormatForFileName(String, RDFFormat) */ public static Optional<RDFFormat> getWriterFormatForFileName(String fileName) { return RDFFormat.matchFileName(fileName, RDFWriterRegistry.getInstance().getKeys()); }
/** * Tries to match a MIME type against the list of RDF formats that can be written. * * @param mimeType * A MIME type, e.g. "application/rdf+xml". * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getWriterFormatForMIMEType(String, RDFFormat) */ public static Optional<RDFFormat> getWriterFormatForMIMEType(String mimeType) { return RDFFormat.matchMIMEType(mimeType, RDFWriterRegistry.getInstance().getKeys()); }
/** * Constructor for super-classes to specify which * {@link RDFFormat} they support. * * @param format The {@link RDFFormat} that this instance supports. */ public RioRDFNonPrefixDocumentFormat(RDFFormat format) { this.format = format; formatName = this.format.getName(); }
/** * Tries to match the extension of a file name against the list of RDF formats that can be parsed. * * @param fileName * A file name. * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForFileName(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForFileName(String fileName) { return RDFFormat.matchFileName(fileName, RDFParserRegistry.getInstance().getKeys()); }
/** * Tries to match a MIME type against the list of RDF formats that can be parsed. * * @param mimeType * A MIME type, e.g. "application/rdf+xml". * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForMIMEType(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForMIMEType(String mimeType) { return RDFFormat.matchMIMEType(mimeType, RDFParserRegistry.getInstance().getKeys()); }
/** * Tries to match the extension of a file name against the list of RDF formats that can be written. * * @param fileName * A file name. * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getWriterFormatForFileName(String, RDFFormat) */ public static Optional<RDFFormat> getWriterFormatForFileName(String fileName) { return RDFFormat.matchFileName(fileName, RDFWriterRegistry.getInstance().getKeys()); }
/** * Tries to match a MIME type against the list of RDF formats that can be written. * * @param mimeType * A MIME type, e.g. "application/rdf+xml". * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getWriterFormatForMIMEType(String, RDFFormat) */ public static Optional<RDFFormat> getWriterFormatForMIMEType(String mimeType) { return RDFFormat.matchMIMEType(mimeType, RDFWriterRegistry.getInstance().getKeys()); }