org.apache.clerezza.rdf.core.serializedform.Parser.getSupportedFormats()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(102)

本文整理了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

Parser.getSupportedFormats介绍

[英]Get a set of supported formats
[中]获取一组受支持的格式

代码示例

代码示例来源:origin: apache/stanbol

  1. /**
  2. * Parses an InputStream of RDF data and produces an Graph from them
  3. *
  4. * @param in The InputStream of RDF data
  5. * @param format the format of the RDF data
  6. *
  7. * @return the resulting Graph or null if the RDF serialization format is not supported by the parser
  8. */
  9. public Graph readModel(InputStream in, String format) {
  10. Parser parser = Parser.getInstance();
  11. if (parser.getSupportedFormats().contains(format)) {
  12. ImmutableGraph graph = parser.parse(in, format);
  13. Graph model = new SimpleGraph(graph);
  14. return model;
  15. } else {
  16. log.warn("Unsupported RDF format: {}\nSupported RDF formats: {}",
  17. format, parser.getSupportedFormats());
  18. }
  19. return null;
  20. }

代码示例来源:origin: org.apache.clerezza/rdf.core

  1. /**
  2. * Update providerMap with the providers in the providerList
  3. *
  4. */
  5. private void refreshProviderMap() {
  6. if (active) {
  7. try {
  8. final Map<String, ParsingProvider> newProviderMap = new HashMap<String, ParsingProvider>();
  9. for (ParsingProvider provider : providerList) {
  10. String[] formatIdentifiers = getFormatIdentifiers(provider);
  11. for (String formatIdentifier : formatIdentifiers) {
  12. newProviderMap.put(formatIdentifier, provider);
  13. }
  14. }
  15. providerMap = newProviderMap;
  16. if (configurationAdmin != null) { //i.e. when we are in an OSGi environment
  17. Dictionary<String, Object> newConfig = configurationAdmin.getConfiguration(getClass().getName()).getProperties();
  18. if (newConfig == null) {
  19. newConfig = new Hashtable<String, Object>();
  20. }
  21. Set<String> supportedFormats = getSupportedFormats();
  22. String[] supportedFromatsArray = supportedFormats.toArray(new String[supportedFormats.size()]);
  23. newConfig.put(SupportedFormat.supportedFormat, supportedFromatsArray);
  24. configurationAdmin.getConfiguration(getClass().getName()).update(newConfig);
  25. }
  26. } catch (IOException ex) {
  27. throw new RuntimeException(ex);
  28. }
  29. }
  30. }

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.ontologymanager.ontonet

  1. @Override
  2. public String loadInStore(InputStream data, String formatIdentifier, String preferredKey, boolean force) {
  3. if (data == null) throw new IllegalArgumentException("No data to load ontologies from.");
  4. // Force is ignored for the content, but the imports?
  5. // Get sorted list of supported formats, or use specified one.
  6. Collection<String> formats;
  7. if (formatIdentifier == null || "".equals(formatIdentifier.trim())) formats = OntologyUtils
  8. .getPreferredSupportedFormats(parser.getSupportedFormats());
  9. else formats = Collections.singleton(formatIdentifier);
  10. // Try each format, return on the first one that was parsed.
  11. for (String format : formats) {
  12. try {
  13. TripleCollection rdfData = parser.parse(data, format);
  14. return loadInStore(rdfData, preferredKey, force);
  15. } catch (UnsupportedFormatException e) {
  16. log.debug("Unsupported format format {}. Trying next one.", format);
  17. continue;
  18. } catch (Exception e) {
  19. log.debug("Parsing format " + format + " failed. Trying next one.", e);
  20. continue;
  21. }
  22. }
  23. // No parser worked, return null.
  24. log.error("All parsers failed, giving up.");
  25. return null;
  26. }

代码示例来源:origin: apache/clerezza

  1. /**
  2. * Update providerMap with the providers in the providerList
  3. *
  4. */
  5. private void refreshProviderMap() {
  6. if (active) {
  7. try {
  8. final Map<String, ParsingProvider> newProviderMap = new HashMap<String, ParsingProvider>();
  9. for (ParsingProvider provider : providerList) {
  10. String[] formatIdentifiers = getFormatIdentifiers(provider);
  11. for (String formatIdentifier : formatIdentifiers) {
  12. newProviderMap.put(formatIdentifier, provider);
  13. }
  14. }
  15. providerMap = newProviderMap;
  16. if (configurationAdmin != null) { //i.e. when we are in an OSGi environment
  17. Dictionary<String, Object> newConfig = configurationAdmin.getConfiguration(getClass().getName()).getProperties();
  18. if (newConfig == null) {
  19. newConfig = new Hashtable<String, Object>();
  20. }
  21. Set<String> supportedFormats = getSupportedFormats();
  22. String[] supportedFromatsArray = supportedFormats.toArray(new String[supportedFormats.size()]);
  23. newConfig.put(SupportedFormat.supportedFormat, supportedFromatsArray);
  24. configurationAdmin.getConfiguration(getClass().getName()).update(newConfig);
  25. }
  26. } catch (IOException ex) {
  27. throw new RuntimeException(ex);
  28. }
  29. }
  30. }

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.ontologymanager.ontonet

  1. .getPreferredSupportedFormats(parser.getSupportedFormats());
  2. else formats = Collections.singleton(formatIdentifier);
  3. for (String currentFormat : formats) {

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.ontologymanager.multiplexer.clerezza

  1. List<String> supported = OntologyUtils.getPreferredSupportedFormats(parser.getSupportedFormats());
  2. List<String> formats;
  3. if (formatIdentifier == null || "".equals(formatIdentifier.trim())) formats = supported;

代码示例来源:origin: apache/stanbol

  1. List<String> supported = OntologyUtils.getPreferredSupportedFormats(parser.getSupportedFormats());
  2. List<String> formats;
  3. if (formatIdentifier == null || "".equals(formatIdentifier.trim())) formats = supported;

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.ontologymanager.ontonet

  1. .getPreferredSupportedFormats(parser.getSupportedFormats());
  2. else formats = Collections.singleton(formatIdentifier);
  3. TripleCollection graph = null;

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.ontologymanager.sources.clerezza

  1. .getPreferredSupportedFormats(parser.getSupportedFormats());
  2. else formats = Collections.singleton(formatIdentifier);

代码示例来源:origin: apache/stanbol

  1. .getPreferredSupportedFormats(parser.getSupportedFormats());
  2. else formats = Collections.singleton(formatIdentifier);

相关文章