本文整理了Java中org.openrdf.rio.Rio.getParserFormatForMIMEType
方法的一些代码示例,展示了Rio.getParserFormatForMIMEType
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rio.getParserFormatForMIMEType
方法的具体详情如下:
包路径:org.openrdf.rio.Rio
类名称:Rio
方法名:getParserFormatForMIMEType
[英]Tries to match a MIME type against the list of RDF formats that can be parsed.
[中]尝试将MIME类型与可解析的RDF格式列表相匹配。
代码示例来源:origin: com.github.tkurz.sesame/vocab-builder-core
/**
* Create a new VocabularyBuilder, reading the vocab definition from the provided file
*
* @param filename the input file to read the vocab from
* @param format the format of the vocab file, may be {@code null}
* @throws java.io.IOException if the file could not be read
* @throws RDFParseException if the format of the vocab could not be detected or is unknown.
*/
public VocabBuilder(String filename, String format) throws IOException, RDFParseException {
this(filename, format != null ? Rio.getParserFormatForMIMEType(format) : null);
}
代码示例来源:origin: org.apache.marmotta/marmotta-core
/**
* returns a parser for a given mimetype; null if no parser defined
* @param mimetype
* @return
*/
@Override
public RDFFormat getParser(String mimetype) {
return Rio.getParserFormatForMIMEType(mimetype);
}
代码示例来源:origin: apache/marmotta
/**
* returns a parser for a given mimetype; null if no parser defined
* @param mimetype
* @return
*/
@Override
public RDFFormat getParser(String mimetype) {
return Rio.getParserFormatForMIMEType(mimetype);
}
代码示例来源:origin: apache/marmotta
/**
* Get the RDF format from a user specfication (either mime type or short cut)
* @param spec
* @return
*/
private static RDFFormat getRDFFormat(String spec) {
if(StringUtils.equalsIgnoreCase(spec,"turtle")) {
return RDFFormat.TURTLE;
} else if(StringUtils.equalsIgnoreCase(spec,"n3")) {
return RDFFormat.N3;
} else if(StringUtils.equalsIgnoreCase(spec,"nquads")) {
return RDFFormat.NQUADS;
} else if(StringUtils.equalsIgnoreCase(spec,"rdf")) {
return RDFFormat.RDFXML;
} else if(StringUtils.equalsIgnoreCase(spec,"xml")) {
return RDFFormat.RDFXML;
} else if(StringUtils.equalsIgnoreCase(spec,"geonames")) {
return GeonamesFormat.FORMAT;
} else if(spec != null) {
return Rio.getParserFormatForMIMEType(spec);
} else {
return null;
}
}
代码示例来源:origin: org.apache.marmotta/marmotta-loader-core
/**
* Get the RDF format from a user specfication (either mime type or short cut)
* @param spec
* @return
*/
private static RDFFormat getRDFFormat(String spec) {
if(StringUtils.equalsIgnoreCase(spec,"turtle")) {
return RDFFormat.TURTLE;
} else if(StringUtils.equalsIgnoreCase(spec,"n3")) {
return RDFFormat.N3;
} else if(StringUtils.equalsIgnoreCase(spec,"nquads")) {
return RDFFormat.NQUADS;
} else if(StringUtils.equalsIgnoreCase(spec,"rdf")) {
return RDFFormat.RDFXML;
} else if(StringUtils.equalsIgnoreCase(spec,"xml")) {
return RDFFormat.RDFXML;
} else if(StringUtils.equalsIgnoreCase(spec,"geonames")) {
return GeonamesFormat.FORMAT;
} else if(spec != null) {
return Rio.getParserFormatForMIMEType(spec);
} else {
return null;
}
}
代码示例来源:origin: org.apache.marmotta/marmotta-sesame-matchers
/**
* Wrap a {@link org.apache.marmotta.commons.sesame.test.base.AbstractRepositoryConnectionMatcher} with a {@link org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher},
* to match the provided matcher against an serialized RDF-String.
*
* @param mimeType the MimeType used to guess the RDFFormat for de-serializing the RDF
* @param baseUri the baseUri used for de-serializing the RDF
* @param matcher the Matcher to wrap
* @see Rio#getParserFormatForMIMEType(String)
* @see org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher#wrap(org.openrdf.rio.RDFFormat, String, org.hamcrest.Matcher)
*/
public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(String mimeType, String baseUri, Matcher<V> matcher) {
final RDFFormat format = Rio.getParserFormatForMIMEType(mimeType);
if (format == null) throw new UnsupportedRDFormatException(mimeType);
return RdfStringMatcher.wrap(format, baseUri, matcher);
}
代码示例来源:origin: apache/marmotta
/**
* Wrap a {@link org.apache.marmotta.commons.sesame.test.base.AbstractRepositoryConnectionMatcher} with a {@link org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher},
* to match the provided matcher against an serialized RDF-String.
*
* @param mimeType the MimeType used to guess the RDFFormat for de-serializing the RDF
* @param baseUri the baseUri used for de-serializing the RDF
* @param matcher the Matcher to wrap
* @see Rio#getParserFormatForMIMEType(String)
* @see org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher#wrap(org.openrdf.rio.RDFFormat, String, org.hamcrest.Matcher)
*/
public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(String mimeType, String baseUri, Matcher<V> matcher) {
final RDFFormat format = Rio.getParserFormatForMIMEType(mimeType);
if (format == null) throw new UnsupportedRDFormatException(mimeType);
return RdfStringMatcher.wrap(format, baseUri, matcher);
}
代码示例来源:origin: ldp4j/ldp4j
private TripleProducer getProducer(String content) {
RDFFormat sesameFormat =
Rio.
getParserFormatForMIMEType(
this.format.getMime(),
RDFFormat.TURTLE);
TripleProducer producer=null;
switch(unmarshallStyle) {
case PARSER_BASED:
producer=new ParserBasedTripleProducer(content,sesameFormat,this.baseURI.toString());
break;
case REPOSITORY_BASED:
producer=new RepositoryBasedTripleProducer(content,sesameFormat,this.baseURI.toString());
break;
default:
throw new AssertionError("Unsupported unmarshalling style '"+unmarshallStyle+"'");
}
return producer;
}
代码示例来源:origin: org.apache.marmotta/marmotta-sesame-matchers
/**
* Wrap a {@link org.apache.marmotta.commons.sesame.test.base.AbstractRepositoryConnectionMatcher} with a {@link org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher},
* to match the provided matcher against an serialized RDF-String.
*
* @param mimeType the MimeType used to guess the RDFFormat for de-serializing the RDF
* @param baseUri the baseUri used for de-serializing the RDF
* @param matchers the Matchers to wrap
* @see Rio#getParserFormatForMIMEType(String)
* @see org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher#wrap(org.openrdf.rio.RDFFormat, String, org.hamcrest.Matcher)
*/
@SafeVarargs
public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(String mimeType, String baseUri, Matcher<V>... matchers) {
final RDFFormat format = Rio.getParserFormatForMIMEType(mimeType);
if (format == null) throw new UnsupportedRDFormatException(mimeType);
return RdfStringMatcher.wrap(format, baseUri, CoreMatchers.allOf(matchers));
}
代码示例来源:origin: apache/marmotta
/**
* Wrap a {@link org.apache.marmotta.commons.sesame.test.base.AbstractRepositoryConnectionMatcher} with a {@link org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher},
* to match the provided matcher against an serialized RDF-String.
*
* @param mimeType the MimeType used to guess the RDFFormat for de-serializing the RDF
* @param baseUri the baseUri used for de-serializing the RDF
* @param matchers the Matchers to wrap
* @see Rio#getParserFormatForMIMEType(String)
* @see org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher#wrap(org.openrdf.rio.RDFFormat, String, org.hamcrest.Matcher)
*/
@SafeVarargs
public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(String mimeType, String baseUri, Matcher<V>... matchers) {
final RDFFormat format = Rio.getParserFormatForMIMEType(mimeType);
if (format == null) throw new UnsupportedRDFormatException(mimeType);
return RdfStringMatcher.wrap(format, baseUri, CoreMatchers.allOf(matchers));
}
代码示例来源:origin: apache/marmotta
/**
* Wrap a {@link org.apache.marmotta.commons.sesame.test.base.AbstractRepositoryConnectionMatcher} with a {@link org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher},
* to match the provided matcher against an serialized RDF-String.
*
* @param mimeType the MimeType used to guess the RDFFormat for de-serializing the RDF
* @param baseUri the baseUri used for de-serializing the RDF
* @param matcher1 the Matcher to wrap
* @param matcher2 the Matcher to wrap
* @see Rio#getParserFormatForMIMEType(String)
* @see org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher#wrap(org.openrdf.rio.RDFFormat, String, org.hamcrest.Matcher)
*/
public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(String mimeType, String baseUri, Matcher<V> matcher1, Matcher<V> matcher2) {
final RDFFormat format = Rio.getParserFormatForMIMEType(mimeType);
if (format == null) throw new UnsupportedRDFormatException(mimeType);
return RdfStringMatcher.wrap(format, baseUri, CoreMatchers.allOf(matcher1, matcher2));
}
代码示例来源:origin: org.apache.marmotta/marmotta-sesame-matchers
/**
* Wrap a {@link org.apache.marmotta.commons.sesame.test.base.AbstractRepositoryConnectionMatcher} with a {@link org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher},
* to match the provided matcher against an serialized RDF-String.
*
* @param mimeType the MimeType used to guess the RDFFormat for de-serializing the RDF
* @param baseUri the baseUri used for de-serializing the RDF
* @param matcher1 the Matcher to wrap
* @param matcher2 the Matcher to wrap
* @see Rio#getParserFormatForMIMEType(String)
* @see org.apache.marmotta.commons.sesame.test.base.RdfStringMatcher#wrap(org.openrdf.rio.RDFFormat, String, org.hamcrest.Matcher)
*/
public static <T extends String, V extends RepositoryConnection> Matcher<T> rdfStringMatches(String mimeType, String baseUri, Matcher<V> matcher1, Matcher<V> matcher2) {
final RDFFormat format = Rio.getParserFormatForMIMEType(mimeType);
if (format == null) throw new UnsupportedRDFormatException(mimeType);
return RdfStringMatcher.wrap(format, baseUri, CoreMatchers.allOf(matcher1, matcher2));
}
代码示例来源:origin: org.apache.marmotta/marmotta-core
final String fmt = prop.getProperty("format");
if (fmt != null) {
RDFFormat rdfFormat = Rio.getParserFormatForMIMEType(fmt);
if (rdfFormat != null) {
format = rdfFormat.getDefaultMIMEType();
代码示例来源:origin: apache/marmotta
public FileBackend(URL url, String mimetype) {
super();
RDFFormat format = null;
if(mimetype != null) {
format = Rio.getParserFormatForMIMEType(mimetype);
}
try {
Repository repository = new SailRepository(new MemoryStore());
repository.initialize();
setRepository(repository);
RepositoryConnection connection = repository.getConnection();
try {
connection.add(url,null,format);
} finally {
connection.close();
}
} catch (RDFParseException e) {
log.error("error parsing RDF input data from url {}",url,e);
} catch (IOException e) {
log.error("I/O error while reading input data from url {}", url, e);
} catch (RepositoryException e) {
log.error("error initialising connection to Sesame in-memory repository",e);
}
}
代码示例来源:origin: apache/marmotta
public FileBackend(File file, String mimetype) {
super();
RDFFormat format = null;
if(mimetype != null) {
format = Rio.getParserFormatForMIMEType(mimetype);
}
try {
Repository repository = new SailRepository(new MemoryStore());
repository.initialize();
setRepository(repository);
RepositoryConnection connection = repository.getConnection();
try {
connection.add(file,null,format);
} finally {
connection.close();
}
} catch (RDFParseException e) {
log.error("error parsing RDF input data from file {}",file,e);
} catch (IOException e) {
log.error("I/O error while reading input data from file {}", file, e);
} catch (RepositoryException e) {
log.error("error initialising connection to Sesame in-memory repository",e);
}
}
代码示例来源:origin: org.openrdf.sesame/sesame-http-server-spring
request.getInputStream(),
baseURI,
Rio.getParserFormatForMIMEType(request.getContentType()).orElseThrow(
Rio.unsupportedFormat(request.getContentType())));
break;
case DELETE:
RDFParser parser = Rio.createParser(
Rio.getParserFormatForMIMEType(request.getContentType()).orElseThrow(
Rio.unsupportedFormat(request.getContentType())), conn.getValueFactory());
parser.setRDFHandler(new WildcardRDFRemover(conn));
代码示例来源:origin: com.github.ansell.sesame-rio-extensions/sesame-rio-extensions-rdfjson
@Test
public void testParserFactoryRegisteredAlternate()
{
final RDFFormat fmt = Rio.getParserFormatForMIMEType("application/json");
Assert.assertNotNull("Could not find the RDF/JSON RDFFormat instance", fmt);
final RDFParser parser = Rio.createParser(fmt);
Assert.assertTrue(parser instanceof RDFJSONParser);
}
代码示例来源:origin: com.github.ansell.sesame-rio-extensions/sesame-rio-extensions-rdfjson
@Test
public void testParserFactoryRegistered()
{
final RDFFormat fmt = Rio.getParserFormatForMIMEType("application/rdf+json");
Assert.assertNotNull("Could not find the RDF/JSON RDFFormat instance", fmt);
final RDFParser parser = Rio.createParser(fmt);
Assert.assertTrue(parser instanceof RDFJSONParser);
}
代码示例来源:origin: org.openrdf.sesame/sesame-http-server-spring
RDFFormat rdfFormat = Rio.getParserFormatForMIMEType(mimeType).orElseThrow(
() -> new ClientHTTPException(SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported MIME type: " + mimeType));
代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl
private Collection<Annotation> parseInput(final Representation entity) throws ResourceException
final RDFFormat inputFormat = Rio.getParserFormatForMIMEType(entity.getMediaType().getName());
内容来源于网络,如有侵权,请联系作者删除!