/** * 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()); }
/** * returns a list of all mimetypes which can be produced by implemented serializers * @return */ @Override public List<String> getProducedTypes() { Set<String> producedTypes = new LinkedHashSet<>(); for(RDFFormat format : RDFWriterRegistry.getInstance().getKeys()) { // Ignore binary formats if(format.hasCharset()) { producedTypes.addAll(format.getMIMETypes()); } } return new ArrayList<>(producedTypes); }
/** * 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()); }
/** * returns a list of all mimetypes which can be produced by implemented serializers * @return */ @Override public List<String> getProducedTypes() { Set<String> producedTypes = new LinkedHashSet<>(); for(RDFFormat format : RDFWriterRegistry.getInstance().getKeys()) { // Ignore binary formats if(format.hasCharset()) { producedTypes.addAll(format.getMIMETypes()); } } return new ArrayList<>(producedTypes); }
public LdpWebService() { producedRdfTypes = new ArrayList<>(); final List<RDFFormat> availableWriters = LdpUtils.filterAvailableWriters(LdpService.SERVER_PREFERED_RDF_FORMATS); for(RDFFormat format : RDFWriterRegistry.getInstance().getKeys()) { final String primaryQ; final int idx = availableWriters.indexOf(format); if (idx < 0) { // not a prefered format primaryQ = ";q=0.5"; } else { // a prefered format primaryQ = String.format(Locale.ENGLISH, ";q=%.1f", Math.max(1.0-(idx*0.1), 0.55)); } final String secondaryQ = ";q=0.3"; final List<String> mimeTypes = format.getMIMETypes(); for (int i = 0; i < mimeTypes.size(); i++) { final String mime = mimeTypes.get(i); if (i == 0) { // first mimetype is the default producedRdfTypes.add(MarmottaHttpUtils.parseContentType(mime + primaryQ)); } else { producedRdfTypes.add(MarmottaHttpUtils.parseContentType(mime + secondaryQ)); } } } Collections.sort(producedRdfTypes); log.debug("Available RDF Serializer: {}", producedRdfTypes); }
formats.addAll(RDFWriterRegistry.getInstance().getKeys()); formats.addAll(TupleQueryResultFormat.values()); for (FileFormat f: formats) {
formats.addAll(RDFWriterRegistry.getInstance().getKeys()); formats.addAll(TupleQueryResultFormat.values()); for (FileFormat f: formats) {