本文整理了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
[英]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
/**
* 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.
*
* @param target the Graph to which the parsed triples are added
* @param serializedGraph an inputstream with the serialization
* @param formatIdentifier a string identifying the format (usually the MIME-type)
* @throws UnsupportedFormatException
*/
public void parse(Graph target, InputStream serializedGraph,
String formatIdentifier) throws UnsupportedFormatException {
parse(target, serializedGraph, formatIdentifier, null);
}
代码示例来源:origin: org.apache.clerezza/rdf.core
/**
* 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.
*
* @param serializedGraph an inputstream with the serialization
* @param formatIdentifier a string identifying the format (usually the MIME-type)
* @return the ImmutableGraph read from the stream
* @throws UnsupportedFormatException
*/
public ImmutableGraph parse(InputStream serializedGraph,
String formatIdentifier) throws UnsupportedFormatException {
return parse(serializedGraph, formatIdentifier, null);
}
代码示例来源:origin: apache/clerezza
/**
* 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.
*
* @param serializedGraph an inputstream with the serialization
* @param formatIdentifier a string identifying the format (usually the MIME-type)
* @return the ImmutableGraph read from the stream
* @throws UnsupportedFormatException
*/
public ImmutableGraph parse(InputStream serializedGraph,
String formatIdentifier) throws UnsupportedFormatException {
return parse(serializedGraph, formatIdentifier, null);
}
代码示例来源:origin: apache/clerezza
/**
* 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.
*
* @param target the Graph to which the parsed triples are added
* @param serializedGraph an inputstream with the serialization
* @param formatIdentifier a string identifying the format (usually the MIME-type)
* @throws UnsupportedFormatException
*/
public void parse(Graph target, InputStream serializedGraph,
String formatIdentifier) throws UnsupportedFormatException {
parse(target, serializedGraph, formatIdentifier, null);
}
代码示例来源:origin: org.apache.clerezza/jaxrs.rdf.providers
@Override
public ImmutableGraph readFrom(Class<ImmutableGraph> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders,
InputStream entityStream)
throws IOException, WebApplicationException {
return parser.parse(entityStream, mediaType.toString());
}
}
代码示例来源:origin: apache/clerezza
@Override
public ImmutableGraph readFrom(Class<ImmutableGraph> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders,
InputStream entityStream)
throws IOException, WebApplicationException {
return parser.parse(entityStream, mediaType.toString());
}
}
代码示例来源:origin: org.apache.clerezza/platform.config
private void readConfigGraphFile(Graph mGraph) {
URL config = getClass().getResource(DEFAULT_SYSTEM_GRAPH);
if (config == null) {
throw new RuntimeException("no config file found");
}
try {
parser.parse(mGraph, config.openStream(),
SupportedFormat.RDF_XML, null);
} catch (IOException ex) {
logger.warn("Cannot parse coniguration at URL: {}", config);
throw new RuntimeException(ex);
}
}
代码示例来源:origin: org.apache.clerezza/jaxrs.rdf.providers
@Override
public Graph readFrom(Class<Graph> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
Graph result = new SimpleGraph();
return parser.parse(entityStream, mediaType.toString());
}
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.commons.web.base
@Override
public void parse(Graph target, InputStream serializedGraph, String format, IRI baseUri) {
String formatIdentifier = cleanFormat(format);
if(SupportedFormat.TEXT_RDF_NT.equals(formatIdentifier)){
parser.parse(target, serializedGraph, SupportedFormat.N_TRIPLE, baseUri);
} else {
throw new IllegalArgumentException("This serializer only supports "+ SupportedFormat.TEXT_RDF_NT +
"(parsed: " + format +" | format: " + formatIdentifier + ")!");
}
}
/**
代码示例来源:origin: apache/stanbol
@Override
public void parse(Graph target, InputStream serializedGraph, String format, IRI baseUri) {
String formatIdentifier = cleanFormat(format);
if(SupportedFormat.TEXT_RDF_NT.equals(formatIdentifier)){
parser.parse(target, serializedGraph, SupportedFormat.N_TRIPLE, baseUri);
} else {
throw new IllegalArgumentException("This serializer only supports "+ SupportedFormat.TEXT_RDF_NT +
"(parsed: " + format +" | format: " + formatIdentifier + ")!");
}
}
/**
代码示例来源:origin: apache/clerezza
@Override
public Graph readFrom(Class<Graph> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
Graph result = new SimpleGraph();
return parser.parse(entityStream, mediaType.toString());
}
}
代码示例来源:origin: apache/stanbol
private void loadRecipesData(Bundle b) {
Enumeration e = b.findEntries(RECIPES_PATH_IN_BUNDLE, "*", false);
if (e != null) {
while (e.hasMoreElements()) {
URL rdfResource = (URL) e.nextElement();
try {
parser.parse(recipesGraph, rdfResource.openStream(), guessFormat(rdfResource));
} catch (IOException ex) {
log.error("Couldn't parse recipe data "+e+" in bundle"+b, ex);
}
}
}
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.ontologymanager.multiplexer.clerezza
@Override
public OWLOntologyID loadInStore(InputStream data,
String formatIdentifier,
boolean force,
Origin<?>... references) {
if (data == null) throw new IllegalArgumentException("No data to load ontologies from.");
if (formatIdentifier == null || formatIdentifier.trim().isEmpty()) throw new IllegalArgumentException(
"A non-null, non-blank format identifier is required for parsing the data stream.");
checkReplaceability(references);
// This method only tries the supplied format once.
log.debug("Trying to parse data stream with format {}", formatIdentifier);
Graph rdfData = parser.parse(data, formatIdentifier);
log.debug("SUCCESS format {}.", formatIdentifier);
return loadInStore(rdfData, force, references);
}
代码示例来源:origin: apache/stanbol
@Override
public OWLOntologyID loadInStore(InputStream data,
String formatIdentifier,
boolean force,
Origin<?>... references) {
if (data == null) throw new IllegalArgumentException("No data to load ontologies from.");
if (formatIdentifier == null || formatIdentifier.trim().isEmpty()) throw new IllegalArgumentException(
"A non-null, non-blank format identifier is required for parsing the data stream.");
checkReplaceability(references);
// This method only tries the supplied format once.
log.debug("Trying to parse data stream with format {}", formatIdentifier);
Graph rdfData = parser.parse(data, formatIdentifier);
log.debug("SUCCESS format {}.", formatIdentifier);
return loadInStore(rdfData, force, references);
}
代码示例来源:origin: org.apache.clerezza/rdf.file.storage
public FileGraph(File file, Parser parser, Serializer serializer) {
this.file = file;
String fileEnding = extractFileEnding(file.getPath());
fileType = getMediaTypeForFileEnding(fileEnding);
this.serializer = serializer;
try {
if (file.exists() && file.length() != 0) {
InputStream fio = new FileInputStream(file);
ImmutableGraph graph = parser.parse(fio, fileType);
addAllNoFileAccess(graph);
} else {
file.createNewFile();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.apache.clerezza/rdf.core
/**
* 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.
*
* @param serializedGraph an inputstream with the serialization
* @param formatIdentifier a string identifying the format (usually the MIME-type)
* @param baseUri the uri against which relative uri-refs are evaluated
* @return the ImmutableGraph read from the stream
* @throws UnsupportedFormatException
*/
public ImmutableGraph parse(InputStream serializedGraph,
String formatIdentifier, IRI baseUri) throws UnsupportedFormatException {
Graph graph = new SimpleMGraph();
parse(graph, serializedGraph, formatIdentifier, baseUri);
return graph.getImmutableGraph();
}
代码示例来源:origin: org.apache.clerezza/platform.documentation
private Graph getDocumentationGraph(URL docUrl, String symbolicName) {
try {
ImmutableGraph parsedGraph = parser.parse(docUrl.openStream(),
SupportedFormat.N_TRIPLE);
IRI baseUri = config.getDefaultBaseUri();
return new SimpleGraph(new UriMutatorIterator(
parsedGraph.iterator(), baseUri.getUnicodeString(), symbolicName));
} catch (IOException ex) {
logger.warn("Cannot parse documentation at URL: {}", docUrl);
throw new RuntimeException(ex);
}
}
代码示例来源:origin: apache/stanbol
public final Representation dereference(String uri) throws IOException {
long start = System.currentTimeMillis();
String format = SupportedFormat.RDF_XML;
InputStream in = dereference(uri, format);
long queryEnd = System.currentTimeMillis();
log.debug(" > DereferenceTime: {}",(queryEnd-start));
if(in != null){
Graph rdfData = new IndexedGraph(parser.parse(in, format,new IRI(getBaseUri())));
long parseEnd = System.currentTimeMillis();
log.debug(" > ParseTime: {}",(parseEnd-queryEnd));
return valueFactory.createRdfRepresentation(new IRI(uri), rdfData);
} else {
return null;
}
}
代码示例来源:origin: apache/stanbol
@Override
public final Representation dereference(String uri) throws IOException{
long start = System.currentTimeMillis();
String format = SupportedFormat.RDF_XML;
InputStream in = dereference(uri, format);
long queryEnd = System.currentTimeMillis();
log.debug(" > DereferenceTime: "+(queryEnd-start));
if(in != null){
Graph rdfData = new IndexedGraph(parser.parse(in, format,new IRI(getBaseUri())));
long parseEnd = System.currentTimeMillis();
log.debug(" > ParseTime: "+(parseEnd-queryEnd));
return valueFactory.createRdfRepresentation(new IRI(uri), rdfData);
} else {
return null;
}
}
}
代码示例来源: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!