本文整理匯總了Java中org.openrdf.rio.RDFFormat.RDFXML屬性的典型用法代碼示例。如果您正苦於以下問題:Java RDFFormat.RDFXML屬性的具體用法?Java RDFFormat.RDFXML怎麽用?Java RDFFormat.RDFXML使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.openrdf.rio.RDFFormat
的用法示例。
在下文中一共展示了RDFFormat.RDFXML屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRDFFormat
/**
* Returns an instance of {@link org.openrdf.rio.RDFFormat} for a
* given MIME-Type string.
*
* @param mimetype the MIME-Type as string
* @return the corresponding RDF-Format
*/
protected RDFFormat getRDFFormat(String mimetype) {
switch (mimetype) {
default:
case RDFMediaType.RDF_TURTLE:
return RDFFormat.TURTLE;
case RDFMediaType.RDF_YARS:
return RDFFormat.YARS;
case RDFMediaType.RDF_XML:
return RDFFormat.RDFXML;
case RDFMediaType.RDF_NTRIPLES:
return RDFFormat.NTRIPLES;
case RDFMediaType.RDF_JSON:
return RDFFormat.RDFJSON;
}
}
示例2: getRequestedAcceptHeader
public static RDFFormat getRequestedAcceptHeader(String contentType) {
RDFFormat requesetedContentType = null;
if (contentType == null || contentType.isEmpty()) {
requesetedContentType = RDFFormat.TURTLE;
}
else if (contentType.contentEquals(
RDFFormat.TURTLE.getDefaultMIMEType()) ||
contentType.contains(MediaType.ALL_VALUE)) {
requesetedContentType = RDFFormat.TURTLE;
}
else if (contentType.contentEquals(
RDFFormat.JSONLD.getDefaultMIMEType())) {
requesetedContentType = RDFFormat.JSONLD;
}
else if (contentType.contentEquals(
RDFFormat.N3.getDefaultMIMEType())) {
requesetedContentType = RDFFormat.N3;
}
else if (contentType.contentEquals(
RDFFormat.RDFXML.getDefaultMIMEType())) {
requesetedContentType = RDFFormat.RDFXML;
}
return requesetedContentType;
}
示例3: parseFormat
/** Converts a command-line RDF type name into the appropriate Sesame type value. */
private static RDFFormat parseFormat(String format) {
switch(format) {
case "binary": return RDFFormat.BINARY;
case "json-ld": return RDFFormat.JSONLD;
case "n3": return RDFFormat.N3;
case "n-quads": return RDFFormat.NQUADS;
case "n-triples": return RDFFormat.NTRIPLES;
case "rdf-a": return RDFFormat.RDFA;
case "rdf-json": return RDFFormat.RDFJSON;
case "rdf-xml": return RDFFormat.RDFXML;
case "trig": return RDFFormat.TRIG;
case "trix": return RDFFormat.TRIX;
case "turtle": return RDFFormat.TURTLE;
}
return null;
}
示例4: importFile
/**
* Imports the the file found in the given file path in the repository under
* the given graphspace.
*
* @param fileFullPath the path of the file that will be imported
* @param directoryGraph the graphspace that will be used
* @throws DataImportException is thrown if any error is occurred
*/
@Override
public void importFile(String fileFullPath, String directoryGraph) throws DataImportException {
File file = new File(fileFullPath);
if (!file.exists()) {
throw new DataImportException("The given file (\"" + fileFullPath + "\") does not exist");
}
RDFFormat chosenFormat = RDFFormat.NTRIPLES;
if (file.getAbsolutePath().toLowerCase().endsWith(Resources.rdfDefaultExtension)) {
chosenFormat = RDFFormat.RDFXML;
logger.debug("Recognized the format of the file (" + file.getName() + "): " + chosenFormat);
} else if (file.getAbsolutePath().toLowerCase().endsWith(Resources.ntriplesDefaultExtension1)
|| file.getAbsolutePath().toLowerCase().endsWith(Resources.ntriplesDefaultExtension2)) {
chosenFormat = RDFFormat.NTRIPLES;
logger.debug("Recognized the format of the file (" + file.getName() + "): " + chosenFormat);
} else {
logger.debug("Couldn't recognize the format of the file (" + file.getName() + "): Trying with " + chosenFormat);
}
this.repoManager.importData(file, chosenFormat, directoryGraph);
}
示例5: load
/**
* Loads all triples found in the datafile associated with the given name.
*
* @param datafileName the name of the datafile.
* @param graphs an optional set of target graph URIs.
* @throws Exception hopefully never, otherwise the test fails.
*/
protected void load(final MisteryGuest data) throws Exception {
if (data.datasets == null || data.datasets.length == 0) {
return;
}
for (final String datafileName : data.datasets) {
final RDFFormat format = datafileName.endsWith(".ttl") ? RDFFormat.TURTLE : RDFFormat.RDFXML;
if (data.graphURI != null) {
localConnection.add(source(datafileName), DUMMY_BASE_URI, format, localConnection.getValueFactory().createURI(data.graphURI));
cumulusConnection.add(source(datafileName), DUMMY_BASE_URI, format, cumulusConnection.getValueFactory().createURI(data.graphURI));
} else {
localConnection.add(source(datafileName), DUMMY_BASE_URI, format);
cumulusConnection.add(source(datafileName), DUMMY_BASE_URI, format);
}
}
}
示例6: FileDocumentIO
public FileDocumentIO(boolean validate) {
File file = SBOLUtils.setupFile();
String fileName = file.getName();
RDFFormat format = fileName.endsWith(".xml") ? RDFFormat.RDFXML
: RDFFormat.forFileName(fileName, RDFFormat.RDFXML);
// reader = SublimeSBOLFactory.createReader(format, validate);
// writer = SublimeSBOLFactory.createWriter(format, validate);
}
示例7: loadRdf
@RequestMapping(value = "/loadrdf", method = RequestMethod.POST)
public void loadRdf(@RequestParam(required = false) final String format,
@RequestParam(value = RdfCloudTripleStoreConfiguration.CONF_CV, required = false) final String cv,
@RequestParam(required = false) final String graph,
@RequestBody final String body,
final HttpServletResponse response)
throws RepositoryException, IOException, RDFParseException {
final List<Resource> authList = new ArrayList<Resource>();
RDFFormat format_r = RDFFormat.RDFXML;
if (format != null) {
format_r = RDFFormat.valueOf(format);
if (format_r == null) {
throw new RuntimeException("RDFFormat[" + format + "] not found");
}
}
if (graph != null) {
authList.add(VALUE_FACTORY.createURI(graph));
}
SailRepositoryConnection conn = null;
try {
conn = repository.getConnection();
if (conn.getSailConnection() instanceof RdfCloudTripleStoreConnection && cv != null) {
final RdfCloudTripleStoreConnection<?> sailConnection = (RdfCloudTripleStoreConnection<?>) conn.getSailConnection();
sailConnection.getConf().set(RdfCloudTripleStoreConfiguration.CONF_CV, cv);
}
conn.add(new StringReader(body), "", format_r);
conn.commit();
} finally {
if (conn != null) {
conn.close();
}
}
}
示例8: testGetStatements
/**
* test get Statemetns.
* @throws Exception The test would fails if Exception occurs
*/
@Test
public void testGetStatements() throws Exception {
//insert some statments first
for (final String tripleAsString : _data) {
final Statement triple = parseNX(tripleAsString).iterator().next();
TRIPLE_STORE.addData(triple);
}
//test get the statements
String uri = BASE_URI + Protocol.REPOSITORIES + "/" + REPO_ID + "/" + Protocol.STATEMENTS;
File tmp = WebTestUtils.tmpFile();
final ServletOutputStream servletOutputStream = new StubServletOutputStream(tmp);
final HttpServletRequest request = mockHttpRequest(uri, METHOD_GET);
when(request.getParameter(Protocol.SUBJECT_PARAM_NAME)).thenReturn(DEVICE);
when(request.getParameter(Protocol.ACCEPT_PARAM_NAME)).thenReturn(MIMETYPE_RDF_XML);
when(request.getCharacterEncoding()).thenReturn(UTF_8);
final HttpServletResponse response = mock(HttpServletResponse.class);
when(response.getOutputStream()).thenReturn(servletOutputStream);
GetMethod method = new GetMethod(uri);
RDFFormat format = RDFFormat.RDFXML;
RDFParser parser = Rio.createParser(format, valueFactory);
parser.setParserConfig(parser.getParserConfig());
StatementCollector collector = new StatementCollector();
parser.setRDFHandler(collector);
_classUnderTest.service(request, response);
parser.parse(new FileInputStream(tmp), method.getURI().getURI());
assertTrue(!collector.getStatements().isEmpty());
verify(response).setStatus(HttpServletResponse.SC_OK);
servletOutputStream.close();
}
示例9: storeInRepo
public void storeInRepo(String src, String baseURI, String context, String format,
Boolean inference) throws RDFParseException, RepositoryException, IOException,
RDFHandlerException, InvalidDatasetFormatFault {
RDFFormat realFormat = null;
GeosparqlRDFHandlerBase.ENABLE_INFERENCE = inference;
if ((baseURI != null) && (baseURI.equals(""))) {
baseURI = null;
}
URI uriContext;
if ((context == null) || (context.equals(""))) {
uriContext = null;
} else {
ValueFactory f = repo.getValueFactory();
uriContext = f.createURI(context);
}
if (format.equalsIgnoreCase("N3") || format.equals(RDFFormat.N3.getName())) {
realFormat = RDFFormat.N3;
} else if (format.equalsIgnoreCase("NTRIPLES") || format.equals(RDFFormat.NTRIPLES.getName())) {
realFormat = RDFFormat.NTRIPLES;
} else if (format.equalsIgnoreCase("RDFXML") || format.equals(RDFFormat.RDFXML.getName())) {
realFormat = RDFFormat.RDFXML;
} else if (format.equalsIgnoreCase("TURTLE") || format.equals(RDFFormat.TURTLE.getName())) {
realFormat = RDFFormat.TURTLE;
} else {
throw new InvalidDatasetFormatFault();
}
try {
URL source = new URL(src);
storeURL(source, baseURI, uriContext, realFormat);
} catch (MalformedURLException e) {
URL fromClasspath = getClass().getResource(src);
if (fromClasspath != null) {
storeURL(fromClasspath, baseURI, uriContext, realFormat);
} else {
File file = new File(src);
if (file.exists()) {
storeURL(new URL("file://" + src), baseURI, uriContext, realFormat);
} else {
logger.info("File \"{}\" does not exist. Trying reading as String.", src);
storeString((String) src, baseURI, uriContext, realFormat);
}
}
}
}