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

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

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

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

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

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

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

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

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

public FileTcProvider() {
  this.parser = Parser.getInstance();
  this.serializer = Serializer.getInstance();
}

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

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

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

public ClerezzaOntologyProvider(TcProvider store, OfflineConfiguration offline, Parser parser) {
  this();
  this.offlineConfig = offline;
  // Re-assign the TcManager if no store is supplied
  if (store == null) store = TcManager.getInstance();
  this.store = store;
  if (this.tcManager == null) this.tcManager = TcManager.getInstance();
  // Same for the parser
  if (parser == null) this.parser = Parser.getInstance();
  else this.parser = parser;
  activate(new Hashtable<String,Object>());
}

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

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

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

public ClerezzaOntologyProvider(TcProvider store, OfflineConfiguration offline, Parser parser) {
  this();
  this.offlineConfig = offline;
  // Re-assign the TcManager if no store is supplied
  if (store == null) store = TcManager.getInstance();
  this.store = store;
  if (this.tcManager == null) this.tcManager = TcManager.getInstance();
  // Same for the parser
  if (parser == null) this.parser = Parser.getInstance();
  else this.parser = parser;
  activate(new Hashtable<String,Object>());
}

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

public ClerezzaOntologyProvider(TcProvider store, OfflineConfiguration offline, Parser parser) {
  this();
  this.offlineConfig = offline;
  // Re-assign the TcManager if no store is supplied
  if (store == null) store = TcManager.getInstance();
  this.store = store;
  if (this.tcManager == null) this.tcManager = TcManager.getInstance();
  // Same for the parser
  if (parser == null) this.parser = Parser.getInstance();
  else this.parser = parser;
  activate(new Hashtable<String,Object>());
}

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

public synchronized void extract(String id, Document doc, Map<String, Object> params,
    Graph result)
    throws ExtractorException {
  if (params == null) {
    params = new HashMap<String, Object>();
  }
  params.put(this.uriParameter, id);
  initTransformerParameters(params);
  Source source = new DOMSource(doc);
  ByteArrayOutputStream writer = new ByteArrayOutputStream(8192);
  StreamResult output = new StreamResult(writer);
  try {
    this.transformer.transform(source, output);
    if (LOG.isDebugEnabled()) {
      String rdf = writer.toString("UTF-8");
      LOG.debug(rdf);
    }
    InputStream reader = new ByteArrayInputStream(writer.toByteArray());
    Parser rdfParser = Parser.getInstance();
    ImmutableGraph graph = rdfParser.parse(reader, this.syntax);
    result.addAll(graph);
  } catch (TransformerException e) {
    throw new ExtractorException(e.getMessage(), e);
  } catch (IOException e) {
    throw new ExtractorException(e.getMessage(), e);
  }
}

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

public synchronized void extract(String id, Document doc, Map<String, Object> params,
    Graph result)
    throws ExtractorException {
  if (params == null) {
    params = new HashMap<String, Object>();
  }
  params.put(this.uriParameter, id);
  initTransformerParameters(params);
  Source source = new DOMSource(doc);
  ByteArrayOutputStream writer = new ByteArrayOutputStream(8192);
  StreamResult output = new StreamResult(writer);
  try {
    this.transformer.transform(source, output);
    if (LOG.isDebugEnabled()) {
      String rdf = writer.toString("UTF-8");
      LOG.debug(rdf);
    }
    InputStream reader = new ByteArrayInputStream(writer.toByteArray());
    Parser rdfParser = Parser.getInstance();
    ImmutableGraph graph = rdfParser.parse(reader, this.syntax);
    result.addAll(graph);
  } catch (TransformerException e) {
    throw new ExtractorException(e.getMessage(), e);
  } catch (IOException e) {
    throw new ExtractorException(e.getMessage(), e);
  }
}

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

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

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

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

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

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

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

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

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

public static void assertRDFEquals(String actual, String reference,
                    String actualFormat, String referenceFormat) {
    Parser parser = Parser.getInstance();

    boolean equals = parser
        .parse(new ByteArrayInputStream(reference.getBytes()),
            referenceFormat).equals(
            parser.parse(
                new ByteArrayInputStream(actual.getBytes()),
                actualFormat));

    Assert.assertTrue(equals);
  }
}

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

/**
 * Creates an instance doing the transformation as specified by the
 * arguments.
 * @param arguments  specification of the transformation
 * @throws IOException  If an IO error occurs.
 */
public SchemaGen(SchemaGenArguments arguments)
    throws IOException, URISyntaxException {
  Parser parser = Parser.getInstance();
  InputStream serializedGraph = arguments.getSchemaUrl().openStream();
  schemaGraph = parser.parse(serializedGraph,
      arguments.getFormatIdentifier());
  className = arguments.getClassName();
  if (arguments.getNamespace() == null) {
    namespace = getOntologyUri();
  } else {
    namespace = arguments.getNamespace();
  }
}

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

/**
 * Creates an instance doing the transformation as specified by the
 * arguments.
 * @param arguments  specification of the transformation
 * @throws IOException  If an IO error occurs.
 */
public SchemaGen(SchemaGenArguments arguments)
    throws IOException, URISyntaxException {
  Parser parser = Parser.getInstance();
  InputStream serializedGraph = arguments.getSchemaUrl().openStream();
  schemaGraph = parser.parse(serializedGraph,
      arguments.getFormatIdentifier());
  className = arguments.getClassName();
  if (arguments.getNamespace() == null) {
    namespace = getOntologyUri();
  } else {
    namespace = arguments.getNamespace();
  }
}

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

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

相关文章