本文整理了Java中org.apache.clerezza.rdf.core.serializedform.Parser.getSupportedFormats()
方法的一些代码示例,展示了Parser.getSupportedFormats()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.getSupportedFormats()
方法的具体详情如下:
包路径:org.apache.clerezza.rdf.core.serializedform.Parser
类名称:Parser
方法名:getSupportedFormats
[英]Get a set of supported formats
[中]获取一组受支持的格式
代码示例来源:origin: apache/stanbol
/**
* Parses an InputStream of RDF data and produces an Graph from them
*
* @param in The InputStream of RDF data
* @param format the format of the RDF data
*
* @return the resulting Graph or null if the RDF serialization format is not supported by the parser
*/
public Graph readModel(InputStream in, String format) {
Parser parser = Parser.getInstance();
if (parser.getSupportedFormats().contains(format)) {
ImmutableGraph graph = parser.parse(in, format);
Graph model = new SimpleGraph(graph);
return model;
} else {
log.warn("Unsupported RDF format: {}\nSupported RDF formats: {}",
format, parser.getSupportedFormats());
}
return null;
}
代码示例来源:origin: org.apache.clerezza/rdf.core
/**
* Update providerMap with the providers in the providerList
*
*/
private void refreshProviderMap() {
if (active) {
try {
final Map<String, ParsingProvider> newProviderMap = new HashMap<String, ParsingProvider>();
for (ParsingProvider provider : providerList) {
String[] formatIdentifiers = getFormatIdentifiers(provider);
for (String formatIdentifier : formatIdentifiers) {
newProviderMap.put(formatIdentifier, provider);
}
}
providerMap = newProviderMap;
if (configurationAdmin != null) { //i.e. when we are in an OSGi environment
Dictionary<String, Object> newConfig = configurationAdmin.getConfiguration(getClass().getName()).getProperties();
if (newConfig == null) {
newConfig = new Hashtable<String, Object>();
}
Set<String> supportedFormats = getSupportedFormats();
String[] supportedFromatsArray = supportedFormats.toArray(new String[supportedFormats.size()]);
newConfig.put(SupportedFormat.supportedFormat, supportedFromatsArray);
configurationAdmin.getConfiguration(getClass().getName()).update(newConfig);
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.ontologymanager.ontonet
@Override
public String loadInStore(InputStream data, String formatIdentifier, String preferredKey, boolean force) {
if (data == null) throw new IllegalArgumentException("No data to load ontologies from.");
// Force is ignored for the content, but the imports?
// Get sorted list of supported formats, or use specified one.
Collection<String> formats;
if (formatIdentifier == null || "".equals(formatIdentifier.trim())) formats = OntologyUtils
.getPreferredSupportedFormats(parser.getSupportedFormats());
else formats = Collections.singleton(formatIdentifier);
// Try each format, return on the first one that was parsed.
for (String format : formats) {
try {
TripleCollection rdfData = parser.parse(data, format);
return loadInStore(rdfData, preferredKey, force);
} catch (UnsupportedFormatException e) {
log.debug("Unsupported format format {}. Trying next one.", format);
continue;
} catch (Exception e) {
log.debug("Parsing format " + format + " failed. Trying next one.", e);
continue;
}
}
// No parser worked, return null.
log.error("All parsers failed, giving up.");
return null;
}
代码示例来源:origin: apache/clerezza
/**
* Update providerMap with the providers in the providerList
*
*/
private void refreshProviderMap() {
if (active) {
try {
final Map<String, ParsingProvider> newProviderMap = new HashMap<String, ParsingProvider>();
for (ParsingProvider provider : providerList) {
String[] formatIdentifiers = getFormatIdentifiers(provider);
for (String formatIdentifier : formatIdentifiers) {
newProviderMap.put(formatIdentifier, provider);
}
}
providerMap = newProviderMap;
if (configurationAdmin != null) { //i.e. when we are in an OSGi environment
Dictionary<String, Object> newConfig = configurationAdmin.getConfiguration(getClass().getName()).getProperties();
if (newConfig == null) {
newConfig = new Hashtable<String, Object>();
}
Set<String> supportedFormats = getSupportedFormats();
String[] supportedFromatsArray = supportedFormats.toArray(new String[supportedFormats.size()]);
newConfig.put(SupportedFormat.supportedFormat, supportedFromatsArray);
configurationAdmin.getConfiguration(getClass().getName()).update(newConfig);
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.ontologymanager.ontonet
.getPreferredSupportedFormats(parser.getSupportedFormats());
else formats = Collections.singleton(formatIdentifier);
for (String currentFormat : formats) {
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.ontologymanager.multiplexer.clerezza
List<String> supported = OntologyUtils.getPreferredSupportedFormats(parser.getSupportedFormats());
List<String> formats;
if (formatIdentifier == null || "".equals(formatIdentifier.trim())) formats = supported;
代码示例来源:origin: apache/stanbol
List<String> supported = OntologyUtils.getPreferredSupportedFormats(parser.getSupportedFormats());
List<String> formats;
if (formatIdentifier == null || "".equals(formatIdentifier.trim())) formats = supported;
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.ontologymanager.ontonet
.getPreferredSupportedFormats(parser.getSupportedFormats());
else formats = Collections.singleton(formatIdentifier);
TripleCollection graph = null;
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.ontologymanager.sources.clerezza
.getPreferredSupportedFormats(parser.getSupportedFormats());
else formats = Collections.singleton(formatIdentifier);
代码示例来源:origin: apache/stanbol
.getPreferredSupportedFormats(parser.getSupportedFormats());
else formats = Collections.singleton(formatIdentifier);
内容来源于网络,如有侵权,请联系作者删除!