本文整理汇总了Java中org.eclipse.rdf4j.rio.UnsupportedRDFormatException类的典型用法代码示例。如果您正苦于以下问题:Java UnsupportedRDFormatException类的具体用法?Java UnsupportedRDFormatException怎么用?Java UnsupportedRDFormatException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnsupportedRDFormatException类属于org.eclipse.rdf4j.rio包,在下文中一共展示了UnsupportedRDFormatException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: data
import org.eclipse.rdf4j.rio.UnsupportedRDFormatException; //导入依赖的package包/类
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
Collection<Object[]> result = new ArrayList<>();
for (RDFFormat nextParserFormat : RDFParserRegistry.getInstance().getKeys()) {
try {
// Try to create a writer, as not all formats (RDFa for example) have writers,
// and we can't automatically test those formats like this
OutputStream out = new ByteArrayOutputStream();
Rio.createWriter(nextParserFormat, out);
// If the writer creation did not throw an exception, add it to the list
result.add(new Object[]{nextParserFormat});
} catch(UnsupportedRDFormatException e) {
// Ignore to drop this format from the list
}
}
assertFalse("No RDFFormats found with RDFParser and RDFWriter implementations on classpath", result.isEmpty());
return result;
}
示例2: getFileContentAsStatements
import org.eclipse.rdf4j.rio.UnsupportedRDFormatException; //导入依赖的package包/类
/**
* Method to read the content of a turtle file
*
* @param fileName Turtle file name
* @param baseURI
* @return File content as a string
*/
public static List<Statement> getFileContentAsStatements(String fileName,
String baseURI) {
List<Statement> statements = null;
try {
String content = getFileContentAsString(fileName);
StringReader reader = new StringReader(content);
Model model;
model = Rio.parse(reader, baseURI, FILE_FORMAT);
Iterator<Statement> it = model.iterator();
statements = Lists.newArrayList(it);
} catch (IOException | RDFParseException |
UnsupportedRDFormatException ex) {
LOGGER.error("Error getting turle file",ex);
}
return statements;
}
示例3: getStatements
import org.eclipse.rdf4j.rio.UnsupportedRDFormatException; //导入依赖的package包/类
/**
* Create List<Statements> from rdf string
*
* @param rdfString RDF string
* @param baseUri Base uri
* @param format RDF format
* @return
* @throws MetadataParserException
*/
public static List<Statement> getStatements(String rdfString, IRI baseUri,
RDFFormat format) throws MetadataParserException {
String uri;
if (baseUri == null) {
uri = "http://example.com/dummyResource";
} else {
uri = baseUri.stringValue();
}
try {
Model model = Rio.parse(new StringReader(rdfString), uri , format);
Iterator<Statement> it = model.iterator();
List<Statement> statements = ImmutableList.copyOf(it);
return statements;
} catch (RDFParseException | UnsupportedRDFormatException |
IOException ex) {
String errMsg = "Error reading dataset metadata content"
+ ex.getMessage();
LOGGER.error(errMsg);
throw (new MetadataParserException(errMsg));
}
}
示例4: getFileContentAsStatements
import org.eclipse.rdf4j.rio.UnsupportedRDFormatException; //导入依赖的package包/类
/**
* Method to read the content of a turtle file
*
* @param fileName Turtle file name
* @param baseURI RDF content's base uri
* @return File content as a string
*/
public static List<Statement> getFileContentAsStatements(String fileName,
String baseURI) {
List<Statement> statements = null;
try {
String content = getFileContentAsString(fileName);
StringReader reader = new StringReader(content);
Model model;
model = Rio.parse(reader, baseURI, FILE_FORMAT);
Iterator<Statement> it = model.iterator();
statements = Lists.newArrayList(it);
} catch (IOException | RDFParseException |
UnsupportedRDFormatException ex) {
LOGGER.error("Error getting turle file",ex);
}
return statements;
}
示例5: personLoader_givenPersonSelector_shouldLoadFourPeople
import org.eclipse.rdf4j.rio.UnsupportedRDFormatException; //导入依赖的package包/类
@Test
public void personLoader_givenPersonSelector_shouldLoadFourPeople()
throws RDFParseException, UnsupportedRDFormatException, IOException {
Set<Person> people = RdfObjectLoader.load(selectPersons, Person.class, model);
assertThat("4 people should be loaded", people, hasSize(4));
}
示例6: personLoader_givenPersonSelector_shouldLoadFourPeopleOneWithAddress
import org.eclipse.rdf4j.rio.UnsupportedRDFormatException; //导入依赖的package包/类
@Test
public void personLoader_givenPersonSelector_shouldLoadFourPeopleOneWithAddress()
throws RDFParseException, UnsupportedRDFormatException, IOException {
Set<Person> people = RdfObjectLoader.load(selectPersons, Person.class, model);
int peopleWithAddr =
(int) people.stream()
.filter(p -> p.getAddress() != null)
.count();
assertThat("1 person with address should be loaded", peopleWithAddr, is(1));
}
示例7: addressLoader_givenAddressSelector_shouldLoadOneAddress
import org.eclipse.rdf4j.rio.UnsupportedRDFormatException; //导入依赖的package包/类
@Test
public void addressLoader_givenAddressSelector_shouldLoadOneAddress()
throws RDFParseException, UnsupportedRDFormatException, IOException {
Set<PostalAddress> addresses = RdfObjectLoader.load(selectAddresses, PostalAddress.class, model);
assertThat("1 address should be loaded", addresses.size(), is(1));
}
示例8: personLoader_givenAllResourcesSelector_shouldLoadEightPeople
import org.eclipse.rdf4j.rio.UnsupportedRDFormatException; //导入依赖的package包/类
@Test
public void personLoader_givenAllResourcesSelector_shouldLoadEightPeople()
throws RDFParseException, UnsupportedRDFormatException, IOException {
Set<Person> people = RdfObjectLoader.load(selectAllResources, Person.class, model);
assertThat("", people, hasSize(8));
}
示例9: addressLoader_givenAddressSelectorAndUpperCaseAdapter_shouldLoadAddressWithUppercaseLiterals
import org.eclipse.rdf4j.rio.UnsupportedRDFormatException; //导入依赖的package包/类
@Test
public void addressLoader_givenAddressSelectorAndUpperCaseAdapter_shouldLoadAddressWithUppercaseLiterals()
throws RDFParseException, UnsupportedRDFormatException, IOException {
Set<PostalAddress> addresses = RdfObjectLoader.load(selectAddresses, PostalAddress.class, model, uppercaser);
PostalAddress address = Iterables.getOnlyElement(addresses);
assertThat("", address.getStreetAddress(), is("1700 KRAFT DRIVE, SUITE 2408"));
assertThat("", address.getAddressLocality(), is("BLACKSBURG"));
assertThat("", address.getAddressRegion(), is("VA"));
assertThat("", address.getPostalCode(), is("24060"));
}