本文整理汇总了Java中org.openrdf.rio.RDFParserRegistry.getFileFormatForFileName方法的典型用法代码示例。如果您正苦于以下问题:Java RDFParserRegistry.getFileFormatForFileName方法的具体用法?Java RDFParserRegistry.getFileFormatForFileName怎么用?Java RDFParserRegistry.getFileFormatForFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.rio.RDFParserRegistry
的用法示例。
在下文中一共展示了RDFParserRegistry.getFileFormatForFileName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFormat
import org.openrdf.rio.RDFParserRegistry; //导入方法依赖的package包/类
private static RDFFormat getFormat(File file){
String fileName = file.getName();
if (fileName.endsWith(".n3")){
fileName = "try.ttl";
}
RDFParserRegistry reg = RDFParserRegistry.getInstance();
FileFormat fileFormat = reg.getFileFormatForFileName(fileName);
if (fileFormat == null || !(fileFormat instanceof RDFFormat)){
//added bridgeDB/OPS specific extension here if required.
logger.warn("OpenRDF does not know the RDF Format for " + fileName);
logger.warn("Using the default format " + DEFAULT_FILE_FORMAT);
return DEFAULT_FILE_FORMAT;
} else {
return (RDFFormat)fileFormat;
}
}
示例2: getParser
import org.openrdf.rio.RDFParserRegistry; //导入方法依赖的package包/类
public static RDFParser getParser(String address, String rdfFormatName) throws BridgeDBException{
RDFParserRegistry reg = RDFParserRegistry.getInstance();
RDFFormat format = null;
if (rdfFormatName == null || rdfFormatName.isEmpty()){
if (address.endsWith(".gz")){
address = address.substring(0, address.length()-3);
}
if (address.endsWith(".n3")){
address = "try.ttl";
}
FileFormat fileFormat = reg.getFileFormatForFileName(address);
if (fileFormat == null || !(fileFormat instanceof RDFFormat)){
//added bridgeDB/OPS specific extension here if required.
logger.warn("OpenRDF does not know the RDF Format for " + address);
logger.warn("Using the default format " + DEFAULT_PARSER);
return DEFAULT_PARSER;
}
format = (RDFFormat)fileFormat;
} else {
for (RDFFormat rdfFormat:RDFFormat.values()){
if (rdfFormat.getName().equalsIgnoreCase(rdfFormatName)){
format = rdfFormat;
}
if (format == null){
throw new BridgeDBException("No RdfFormat with name " + rdfFormatName + " known");
}
}
}
RDFParserFactory factory = reg.get(format);
return factory.getParser();
}
示例3: getFormat
import org.openrdf.rio.RDFParserRegistry; //导入方法依赖的package包/类
private static RDFFormat getFormat(String fileName) throws BridgeDBException{
if (fileName.endsWith(".n3")){
fileName = "try.ttl";
}
RDFParserRegistry reg = RDFParserRegistry.getInstance();
FileFormat fileFormat = reg.getFileFormatForFileName(fileName);
if (fileFormat == null || !(fileFormat instanceof RDFFormat)){
//added bridgeDB/OPS specific extension here if required.
throw new BridgeDBException("failed");
} else {
return (RDFFormat)fileFormat;
}
}