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

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

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

Parser.parse介绍

[英]Parses a serialized ImmutableGraph from an InputStream. This delegates the processing to the provider registered for the specified format, if the formatIdentifier contains a ';'-character only the section before that character is used for choosing the provider.
[中]从InputStream解析序列化的ImmutableGraph。如果formatIdentifier包含“;”字符,则将处理委托给为指定格式注册的提供程序-仅字符用于选择提供程序的字符前的部分。

代码示例

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

  1. /**
  2. * Parses a serialized ImmutableGraph from an InputStream. This delegates the
  3. * processing to the provider registered for the specified format, if
  4. * the formatIdentifier contains a ';'-character only the section before
  5. * that character is used for choosing the provider.
  6. *
  7. * @param target the Graph to which the parsed triples are added
  8. * @param serializedGraph an inputstream with the serialization
  9. * @param formatIdentifier a string identifying the format (usually the MIME-type)
  10. * @throws UnsupportedFormatException
  11. */
  12. public void parse(Graph target, InputStream serializedGraph,
  13. String formatIdentifier) throws UnsupportedFormatException {
  14. parse(target, serializedGraph, formatIdentifier, null);
  15. }

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

  1. /**
  2. * Parses a serialized ImmutableGraph from an InputStream. This delegates the
  3. * processing to the provider registered for the specified format, if
  4. * the formatIdentifier contains a ';'-character only the section before
  5. * that character is used for choosing the provider.
  6. *
  7. * @param serializedGraph an inputstream with the serialization
  8. * @param formatIdentifier a string identifying the format (usually the MIME-type)
  9. * @return the ImmutableGraph read from the stream
  10. * @throws UnsupportedFormatException
  11. */
  12. public ImmutableGraph parse(InputStream serializedGraph,
  13. String formatIdentifier) throws UnsupportedFormatException {
  14. return parse(serializedGraph, formatIdentifier, null);
  15. }

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

  1. /**
  2. * Parses a serialized ImmutableGraph from an InputStream. This delegates the
  3. * processing to the provider registered for the specified format, if
  4. * the formatIdentifier contains a ';'-character only the section before
  5. * that character is used for choosing the provider.
  6. *
  7. * @param serializedGraph an inputstream with the serialization
  8. * @param formatIdentifier a string identifying the format (usually the MIME-type)
  9. * @return the ImmutableGraph read from the stream
  10. * @throws UnsupportedFormatException
  11. */
  12. public ImmutableGraph parse(InputStream serializedGraph,
  13. String formatIdentifier) throws UnsupportedFormatException {
  14. return parse(serializedGraph, formatIdentifier, null);
  15. }

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

  1. /**
  2. * Parses a serialized ImmutableGraph from an InputStream. This delegates the
  3. * processing to the provider registered for the specified format, if
  4. * the formatIdentifier contains a ';'-character only the section before
  5. * that character is used for choosing the provider.
  6. *
  7. * @param target the Graph to which the parsed triples are added
  8. * @param serializedGraph an inputstream with the serialization
  9. * @param formatIdentifier a string identifying the format (usually the MIME-type)
  10. * @throws UnsupportedFormatException
  11. */
  12. public void parse(Graph target, InputStream serializedGraph,
  13. String formatIdentifier) throws UnsupportedFormatException {
  14. parse(target, serializedGraph, formatIdentifier, null);
  15. }

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

  1. @Override
  2. public ImmutableGraph readFrom(Class<ImmutableGraph> type, Type genericType,
  3. Annotation[] annotations, MediaType mediaType,
  4. MultivaluedMap<String, String> httpHeaders,
  5. InputStream entityStream)
  6. throws IOException, WebApplicationException {
  7. return parser.parse(entityStream, mediaType.toString());
  8. }
  9. }

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

  1. @Override
  2. public ImmutableGraph readFrom(Class<ImmutableGraph> type, Type genericType,
  3. Annotation[] annotations, MediaType mediaType,
  4. MultivaluedMap<String, String> httpHeaders,
  5. InputStream entityStream)
  6. throws IOException, WebApplicationException {
  7. return parser.parse(entityStream, mediaType.toString());
  8. }
  9. }

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

  1. private void readConfigGraphFile(Graph mGraph) {
  2. URL config = getClass().getResource(DEFAULT_SYSTEM_GRAPH);
  3. if (config == null) {
  4. throw new RuntimeException("no config file found");
  5. }
  6. try {
  7. parser.parse(mGraph, config.openStream(),
  8. SupportedFormat.RDF_XML, null);
  9. } catch (IOException ex) {
  10. logger.warn("Cannot parse coniguration at URL: {}", config);
  11. throw new RuntimeException(ex);
  12. }
  13. }

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

  1. @Override
  2. public Graph readFrom(Class<Graph> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
  3. Graph result = new SimpleGraph();
  4. return parser.parse(entityStream, mediaType.toString());
  5. }
  6. }

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.commons.web.base

  1. @Override
  2. public void parse(Graph target, InputStream serializedGraph, String format, IRI baseUri) {
  3. String formatIdentifier = cleanFormat(format);
  4. if(SupportedFormat.TEXT_RDF_NT.equals(formatIdentifier)){
  5. parser.parse(target, serializedGraph, SupportedFormat.N_TRIPLE, baseUri);
  6. } else {
  7. throw new IllegalArgumentException("This serializer only supports "+ SupportedFormat.TEXT_RDF_NT +
  8. "(parsed: " + format +" | format: " + formatIdentifier + ")!");
  9. }
  10. }
  11. /**

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

  1. @Override
  2. public void parse(Graph target, InputStream serializedGraph, String format, IRI baseUri) {
  3. String formatIdentifier = cleanFormat(format);
  4. if(SupportedFormat.TEXT_RDF_NT.equals(formatIdentifier)){
  5. parser.parse(target, serializedGraph, SupportedFormat.N_TRIPLE, baseUri);
  6. } else {
  7. throw new IllegalArgumentException("This serializer only supports "+ SupportedFormat.TEXT_RDF_NT +
  8. "(parsed: " + format +" | format: " + formatIdentifier + ")!");
  9. }
  10. }
  11. /**

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

  1. @Override
  2. public Graph readFrom(Class<Graph> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
  3. Graph result = new SimpleGraph();
  4. return parser.parse(entityStream, mediaType.toString());
  5. }
  6. }

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

  1. private void loadRecipesData(Bundle b) {
  2. Enumeration e = b.findEntries(RECIPES_PATH_IN_BUNDLE, "*", false);
  3. if (e != null) {
  4. while (e.hasMoreElements()) {
  5. URL rdfResource = (URL) e.nextElement();
  6. try {
  7. parser.parse(recipesGraph, rdfResource.openStream(), guessFormat(rdfResource));
  8. } catch (IOException ex) {
  9. log.error("Couldn't parse recipe data "+e+" in bundle"+b, ex);
  10. }
  11. }
  12. }
  13. }

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

  1. @Override
  2. public OWLOntologyID loadInStore(InputStream data,
  3. String formatIdentifier,
  4. boolean force,
  5. Origin<?>... references) {
  6. if (data == null) throw new IllegalArgumentException("No data to load ontologies from.");
  7. if (formatIdentifier == null || formatIdentifier.trim().isEmpty()) throw new IllegalArgumentException(
  8. "A non-null, non-blank format identifier is required for parsing the data stream.");
  9. checkReplaceability(references);
  10. // This method only tries the supplied format once.
  11. log.debug("Trying to parse data stream with format {}", formatIdentifier);
  12. Graph rdfData = parser.parse(data, formatIdentifier);
  13. log.debug("SUCCESS format {}.", formatIdentifier);
  14. return loadInStore(rdfData, force, references);
  15. }

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

  1. @Override
  2. public OWLOntologyID loadInStore(InputStream data,
  3. String formatIdentifier,
  4. boolean force,
  5. Origin<?>... references) {
  6. if (data == null) throw new IllegalArgumentException("No data to load ontologies from.");
  7. if (formatIdentifier == null || formatIdentifier.trim().isEmpty()) throw new IllegalArgumentException(
  8. "A non-null, non-blank format identifier is required for parsing the data stream.");
  9. checkReplaceability(references);
  10. // This method only tries the supplied format once.
  11. log.debug("Trying to parse data stream with format {}", formatIdentifier);
  12. Graph rdfData = parser.parse(data, formatIdentifier);
  13. log.debug("SUCCESS format {}.", formatIdentifier);
  14. return loadInStore(rdfData, force, references);
  15. }

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

  1. public FileGraph(File file, Parser parser, Serializer serializer) {
  2. this.file = file;
  3. String fileEnding = extractFileEnding(file.getPath());
  4. fileType = getMediaTypeForFileEnding(fileEnding);
  5. this.serializer = serializer;
  6. try {
  7. if (file.exists() && file.length() != 0) {
  8. InputStream fio = new FileInputStream(file);
  9. ImmutableGraph graph = parser.parse(fio, fileType);
  10. addAllNoFileAccess(graph);
  11. } else {
  12. file.createNewFile();
  13. }
  14. } catch (IOException e) {
  15. throw new RuntimeException(e);
  16. }
  17. }

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

  1. /**
  2. * Parses a serialized ImmutableGraph from an InputStream. This delegates the
  3. * processing to the provider registered for the specified format, if
  4. * the formatIdentifier contains a ';'-character only the section before
  5. * that character is used for choosing the provider.
  6. *
  7. * @param serializedGraph an inputstream with the serialization
  8. * @param formatIdentifier a string identifying the format (usually the MIME-type)
  9. * @param baseUri the uri against which relative uri-refs are evaluated
  10. * @return the ImmutableGraph read from the stream
  11. * @throws UnsupportedFormatException
  12. */
  13. public ImmutableGraph parse(InputStream serializedGraph,
  14. String formatIdentifier, IRI baseUri) throws UnsupportedFormatException {
  15. Graph graph = new SimpleMGraph();
  16. parse(graph, serializedGraph, formatIdentifier, baseUri);
  17. return graph.getImmutableGraph();
  18. }

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

  1. private Graph getDocumentationGraph(URL docUrl, String symbolicName) {
  2. try {
  3. ImmutableGraph parsedGraph = parser.parse(docUrl.openStream(),
  4. SupportedFormat.N_TRIPLE);
  5. IRI baseUri = config.getDefaultBaseUri();
  6. return new SimpleGraph(new UriMutatorIterator(
  7. parsedGraph.iterator(), baseUri.getUnicodeString(), symbolicName));
  8. } catch (IOException ex) {
  9. logger.warn("Cannot parse documentation at URL: {}", docUrl);
  10. throw new RuntimeException(ex);
  11. }
  12. }

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

  1. public final Representation dereference(String uri) throws IOException {
  2. long start = System.currentTimeMillis();
  3. String format = SupportedFormat.RDF_XML;
  4. InputStream in = dereference(uri, format);
  5. long queryEnd = System.currentTimeMillis();
  6. log.debug(" > DereferenceTime: {}",(queryEnd-start));
  7. if(in != null){
  8. Graph rdfData = new IndexedGraph(parser.parse(in, format,new IRI(getBaseUri())));
  9. long parseEnd = System.currentTimeMillis();
  10. log.debug(" > ParseTime: {}",(parseEnd-queryEnd));
  11. return valueFactory.createRdfRepresentation(new IRI(uri), rdfData);
  12. } else {
  13. return null;
  14. }
  15. }

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

  1. @Override
  2. public final Representation dereference(String uri) throws IOException{
  3. long start = System.currentTimeMillis();
  4. String format = SupportedFormat.RDF_XML;
  5. InputStream in = dereference(uri, format);
  6. long queryEnd = System.currentTimeMillis();
  7. log.debug(" > DereferenceTime: "+(queryEnd-start));
  8. if(in != null){
  9. Graph rdfData = new IndexedGraph(parser.parse(in, format,new IRI(getBaseUri())));
  10. long parseEnd = System.currentTimeMillis();
  11. log.debug(" > ParseTime: "+(parseEnd-queryEnd));
  12. return valueFactory.createRdfRepresentation(new IRI(uri), rdfData);
  13. } else {
  14. return null;
  15. }
  16. }
  17. }

代码示例来源: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. }

相关文章