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

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

本文整理了Java中org.apache.clerezza.rdf.core.serializedform.Parser.getInstance()方法的一些代码示例,展示了Parser.getInstance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.getInstance()方法的具体详情如下:
包路径:org.apache.clerezza.rdf.core.serializedform.Parser
类名称:Parser
方法名:getInstance

Parser.getInstance介绍

[英]This returns the singleton instance, if an instance has been previously created (e.g. by OSGi declarative services) this instance is returned, otherwise a new instance is created and providers are injected using the service provider interface (META-INF/services/)
[中]这将返回单例实例,如果以前创建过实例(例如,由OSGi声明性服务创建),则返回该实例,否则将创建一个新实例,并使用服务提供程序接口(META-INF/services/)注入提供程序

代码示例

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

  1. /**
  2. * Creates a new graph input source by parsing <code>content</code> into a graph created using the
  3. * supplied {@link TcProvider}, assuming it has the given format.
  4. *
  5. * @param content
  6. * the serialized graph content.
  7. * @param formatIdentifier
  8. * the format to parse the content as.
  9. * @param tcProvider
  10. * the provider that will create the graph where the triples will be stored.
  11. */
  12. public GraphContentInputSource(InputStream content, String formatIdentifier, TcProvider tcProvider) {
  13. this(content, formatIdentifier, tcProvider, Parser.getInstance());
  14. }

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

  1. /**
  2. * Creates a new graph input source by parsing <code>content</code> into a graph created using the
  3. * supplied {@link TcProvider}, assuming it has the given format.
  4. *
  5. * @param content
  6. * the serialized graph content.
  7. * @param formatIdentifier
  8. * the format to parse the content as.
  9. * @param tcProvider
  10. * the provider that will create the graph where the triples will be stored.
  11. */
  12. public GraphContentInputSource(InputStream content, String formatIdentifier, TcProvider tcProvider) {
  13. this(content, formatIdentifier, tcProvider, Parser.getInstance());
  14. }

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

  1. /**
  2. * Creates a new graph input source by parsing <code>content</code> into a graph created using the
  3. * supplied {@link TcProvider}, assuming it has the given format.
  4. *
  5. * @param content
  6. * the serialized graph content.
  7. * @param formatIdentifier
  8. * the format to parse the content as.
  9. * @param tcProvider
  10. * the provider that will create the graph where the triples will be stored.
  11. */
  12. public GraphContentInputSource(InputStream content, String formatIdentifier, TcProvider tcProvider) {
  13. this(content, formatIdentifier, tcProvider, Parser.getInstance());
  14. }

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

  1. public FileTcProvider() {
  2. this.parser = Parser.getInstance();
  3. this.serializer = Serializer.getInstance();
  4. }

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

  1. @Override
  2. public void setCache(OntologyProvider<?> cache) {
  3. if (cache == null) cache = new ClerezzaOntologyProvider(TcManager.getInstance(), null,
  4. Parser.getInstance());
  5. else {
  6. Object store = cache.getStore();
  7. if (!(store instanceof TcProvider || store instanceof OWLOntologyManager)) throw new IllegalArgumentException(
  8. "Type "
  9. + store.getClass()
  10. + "is not supported. This ontology library implementation only supports caches based on either "
  11. + TcProvider.class + " or " + OWLOntologyManager.class);
  12. }
  13. this.cache = cache;
  14. }

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

  1. public ClerezzaOntologyProvider(TcProvider store, OfflineConfiguration offline, Parser parser) {
  2. this();
  3. this.offlineConfig = offline;
  4. // Re-assign the TcManager if no store is supplied
  5. if (store == null) store = TcManager.getInstance();
  6. this.store = store;
  7. if (this.tcManager == null) this.tcManager = TcManager.getInstance();
  8. // Same for the parser
  9. if (parser == null) this.parser = Parser.getInstance();
  10. else this.parser = parser;
  11. activate(new Hashtable<String,Object>());
  12. }

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

  1. @Override
  2. public void setCache(OntologyProvider<?> cache) {
  3. if (cache == null) cache = new ClerezzaOntologyProvider(TcManager.getInstance(), null,
  4. Parser.getInstance());
  5. else {
  6. Object store = cache.getStore();
  7. if (!(store instanceof TcProvider || store instanceof OWLOntologyManager)) throw new IllegalArgumentException(
  8. "Type "
  9. + store.getClass()
  10. + "is not supported. This ontology library implementation only supports caches based on either "
  11. + TcProvider.class + " or " + OWLOntologyManager.class);
  12. }
  13. this.cache = cache;
  14. }

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

  1. public ClerezzaOntologyProvider(TcProvider store, OfflineConfiguration offline, Parser parser) {
  2. this();
  3. this.offlineConfig = offline;
  4. // Re-assign the TcManager if no store is supplied
  5. if (store == null) store = TcManager.getInstance();
  6. this.store = store;
  7. if (this.tcManager == null) this.tcManager = TcManager.getInstance();
  8. // Same for the parser
  9. if (parser == null) this.parser = Parser.getInstance();
  10. else this.parser = parser;
  11. activate(new Hashtable<String,Object>());
  12. }

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

  1. public ClerezzaOntologyProvider(TcProvider store, OfflineConfiguration offline, Parser parser) {
  2. this();
  3. this.offlineConfig = offline;
  4. // Re-assign the TcManager if no store is supplied
  5. if (store == null) store = TcManager.getInstance();
  6. this.store = store;
  7. if (this.tcManager == null) this.tcManager = TcManager.getInstance();
  8. // Same for the parser
  9. if (parser == null) this.parser = Parser.getInstance();
  10. else this.parser = parser;
  11. activate(new Hashtable<String,Object>());
  12. }

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.enhancer.engines.htmlextractor

  1. public synchronized void extract(String id, Document doc, Map<String, Object> params,
  2. Graph result)
  3. throws ExtractorException {
  4. if (params == null) {
  5. params = new HashMap<String, Object>();
  6. }
  7. params.put(this.uriParameter, id);
  8. initTransformerParameters(params);
  9. Source source = new DOMSource(doc);
  10. ByteArrayOutputStream writer = new ByteArrayOutputStream(8192);
  11. StreamResult output = new StreamResult(writer);
  12. try {
  13. this.transformer.transform(source, output);
  14. if (LOG.isDebugEnabled()) {
  15. String rdf = writer.toString("UTF-8");
  16. LOG.debug(rdf);
  17. }
  18. InputStream reader = new ByteArrayInputStream(writer.toByteArray());
  19. Parser rdfParser = Parser.getInstance();
  20. ImmutableGraph graph = rdfParser.parse(reader, this.syntax);
  21. result.addAll(graph);
  22. } catch (TransformerException e) {
  23. throw new ExtractorException(e.getMessage(), e);
  24. } catch (IOException e) {
  25. throw new ExtractorException(e.getMessage(), e);
  26. }
  27. }

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

  1. public synchronized void extract(String id, Document doc, Map<String, Object> params,
  2. Graph result)
  3. throws ExtractorException {
  4. if (params == null) {
  5. params = new HashMap<String, Object>();
  6. }
  7. params.put(this.uriParameter, id);
  8. initTransformerParameters(params);
  9. Source source = new DOMSource(doc);
  10. ByteArrayOutputStream writer = new ByteArrayOutputStream(8192);
  11. StreamResult output = new StreamResult(writer);
  12. try {
  13. this.transformer.transform(source, output);
  14. if (LOG.isDebugEnabled()) {
  15. String rdf = writer.toString("UTF-8");
  16. LOG.debug(rdf);
  17. }
  18. InputStream reader = new ByteArrayInputStream(writer.toByteArray());
  19. Parser rdfParser = Parser.getInstance();
  20. ImmutableGraph graph = rdfParser.parse(reader, this.syntax);
  21. result.addAll(graph);
  22. } catch (TransformerException e) {
  23. throw new ExtractorException(e.getMessage(), e);
  24. } catch (IOException e) {
  25. throw new ExtractorException(e.getMessage(), e);
  26. }
  27. }

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

  1. Graph parsedGraph = Parser.getInstance().parse(is,
  2. SupportedFormat.RDF_XML);
  3. is.close();

代码示例来源: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.stanbol/org.apache.stanbol.ontologymanager.ontonet

  1. if (parser == null) parser = Parser.getInstance();

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

  1. if (parser == null) parser = Parser.getInstance();
  2. boolean loaded = false;

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

  1. if (parser == null) parser = Parser.getInstance();
  2. boolean loaded = false;

代码示例来源:origin: fusepoolP3/p3-batchrefine

  1. public static void assertRDFEquals(String actual, String reference,
  2. String actualFormat, String referenceFormat) {
  3. Parser parser = Parser.getInstance();
  4. boolean equals = parser
  5. .parse(new ByteArrayInputStream(reference.getBytes()),
  6. referenceFormat).equals(
  7. parser.parse(
  8. new ByteArrayInputStream(actual.getBytes()),
  9. actualFormat));
  10. Assert.assertTrue(equals);
  11. }
  12. }

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

  1. /**
  2. * Creates an instance doing the transformation as specified by the
  3. * arguments.
  4. * @param arguments specification of the transformation
  5. * @throws IOException If an IO error occurs.
  6. */
  7. public SchemaGen(SchemaGenArguments arguments)
  8. throws IOException, URISyntaxException {
  9. Parser parser = Parser.getInstance();
  10. InputStream serializedGraph = arguments.getSchemaUrl().openStream();
  11. schemaGraph = parser.parse(serializedGraph,
  12. arguments.getFormatIdentifier());
  13. className = arguments.getClassName();
  14. if (arguments.getNamespace() == null) {
  15. namespace = getOntologyUri();
  16. } else {
  17. namespace = arguments.getNamespace();
  18. }
  19. }

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

  1. /**
  2. * Creates an instance doing the transformation as specified by the
  3. * arguments.
  4. * @param arguments specification of the transformation
  5. * @throws IOException If an IO error occurs.
  6. */
  7. public SchemaGen(SchemaGenArguments arguments)
  8. throws IOException, URISyntaxException {
  9. Parser parser = Parser.getInstance();
  10. InputStream serializedGraph = arguments.getSchemaUrl().openStream();
  11. schemaGraph = parser.parse(serializedGraph,
  12. arguments.getFormatIdentifier());
  13. className = arguments.getClassName();
  14. if (arguments.getNamespace() == null) {
  15. namespace = getOntologyUri();
  16. } else {
  17. namespace = arguments.getNamespace();
  18. }
  19. }

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

  1. cache = new ClerezzaOntologyProvider(TcManager.getInstance(), offline, Parser.getInstance());
  2. if (this.cache != null) ((Library) child).setCache(this.cache);
  3. else ((Library) child).setCache(new ClerezzaOntologyProvider(TcManager.getInstance(),
  4. offline, Parser.getInstance()));

相关文章