当前位置: 首页>>代码示例>>Java>>正文


Java RDFParserRegistry类代码示例

本文整理汇总了Java中org.openrdf.rio.RDFParserRegistry的典型用法代码示例。如果您正苦于以下问题:Java RDFParserRegistry类的具体用法?Java RDFParserRegistry怎么用?Java RDFParserRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RDFParserRegistry类属于org.openrdf.rio包,在下文中一共展示了RDFParserRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initRio

import org.openrdf.rio.RDFParserRegistry; //导入依赖的package包/类
/**
 * This is needed, because Rio is unable to find the Parser/Writer Factories
 * automatically when the jar gets deployed as plugin inside the Neo4j
 * Server.
 */
private synchronized void initRio() {
	if (!rioInitialized) {
		RDFParserRegistry parserRegistry = RDFParserRegistry.getInstance();
		parserRegistry.add(new TurtleParserFactory());
		parserRegistry.add(new YARSParserFactory());
		parserRegistry.add(new RDFXMLParserFactory());
		parserRegistry.add(new NTriplesParserFactory());
		parserRegistry.add(new RDFJSONParserFactory());
		RDFWriterRegistry writerRegistry = RDFWriterRegistry.getInstance();
		writerRegistry.add(new TurtleWriterFactory());
		writerRegistry.add(new YARSWriterFactory());
		writerRegistry.add(new RDFXMLWriterFactory());
		writerRegistry.add(new NTriplesWriterFactory());
		writerRegistry.add(new RDFJSONWriterFactory());
		rioInitialized = true;
	}
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:23,代码来源:RepositoryRegistry.java

示例2: LDPathWrapper

import org.openrdf.rio.RDFParserRegistry; //导入依赖的package包/类
/**
 * Create an LDPathWrapper Object
 * @param backend the linkeddata backend
 */
public LDPathWrapper(final LDCacheBackend backend) {

    // Register the Sesame RDF Parsers manually
    // TODO: use the OSGi service registry as described in:
    // http://blog.osgi.org/2013/02/javautilserviceloader-in-osgi.html
    RDFParserRegistry.getInstance().add(new RDFXMLParserFactory());
    RDFParserRegistry.getInstance().add(new NTriplesParserFactory());
    RDFParserRegistry.getInstance().add(new TurtleParserFactory());
    RDFParserRegistry.getInstance().add(new N3ParserFactory());
    RDFParserRegistry.getInstance().add(new SesameJSONLDParserFactory());
    RDFParserRegistry.getInstance().add(new RDFJSONParserFactory());
    RDFParserRegistry.getInstance().add(new SesameRDFaParserFactory());
    RDFParserRegistry.getInstance().add(new TriGParserFactory());
    BooleanQueryResultParserRegistry.getInstance().add(new SPARQLBooleanXMLParserFactory());
    TupleQueryResultParserRegistry.getInstance().add(new SPARQLResultsXMLParserFactory());

    ldpath = new LDPath<Value>(backend);
}
 
开发者ID:fcrepo4-exts,项目名称:fcrepo-camel-toolbox,代码行数:23,代码来源:LDPathWrapper.java

示例3: initRio

import org.openrdf.rio.RDFParserRegistry; //导入依赖的package包/类
/**
 * This is needed, because Rio is unable to find the Parser/Writer Factories
 * automatically when the jar gets deployed as plugin inside the Neo4j
 * Server.
 */
private synchronized void initRio() {
	if (!rioInitialized) {
		RDFParserRegistry parserRegistry = RDFParserRegistry.getInstance();
		parserRegistry.add(new TurtleParserFactory());
		parserRegistry.add(new RDFXMLParserFactory());
		parserRegistry.add(new NTriplesParserFactory());
		parserRegistry.add(new RDFJSONParserFactory());
		RDFWriterRegistry writerRegistry = RDFWriterRegistry.getInstance();
		writerRegistry.add(new TurtleWriterFactory());
		writerRegistry.add(new RDFXMLWriterFactory());
		writerRegistry.add(new NTriplesWriterFactory());
		writerRegistry.add(new RDFJSONWriterFactory());
		rioInitialized = true;
	}
}
 
开发者ID:niclashoyer,项目名称:neo4j-sparql-extension,代码行数:21,代码来源:RepositoryRegistry.java

示例4: getAcceptHeaderValue

import org.openrdf.rio.RDFParserRegistry; //导入依赖的package包/类
private String getAcceptHeaderValue() {
    final Set<RDFFormat> rdfFormats = RDFParserRegistry.getInstance().getKeys();
    final Iterator<String> acceptParams = RDFFormat.getAcceptParams(rdfFormats, false, RDFFormat.TURTLE).iterator();
    if (acceptParams.hasNext()) {
        final StringBuilder sb = new StringBuilder();
        while (acceptParams.hasNext()) {
            sb.append(acceptParams.next());
            if (acceptParams.hasNext()) {
                sb.append(", ");
            }
        }
        return sb.toString();
    } else {
        return null;
    }
}
 
开发者ID:tkurz,项目名称:sesame-vocab-builder,代码行数:17,代码来源:VocabularyBuilderMojo.java

示例5: data

import org.openrdf.rio.RDFParserRegistry; //导入依赖的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 implementations on classpath", result.isEmpty());
    return result;
}
 
开发者ID:tkurz,项目名称:sesame-vocab-builder,代码行数:19,代码来源:VocabBuilderTest.java

示例6: 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;
    }
}
 
开发者ID:bridgedb,项目名称:BridgeDb,代码行数:17,代码来源:BridgeDBRdfHandler.java

示例7: forFileName

import org.openrdf.rio.RDFParserRegistry; //导入依赖的package包/类
private RDFFormat forFileName(String path, RDFFormat fallback) {
	RDFFormat format = RDFFormat.forFileName(path);
	RDFParserRegistry registry = RDFParserRegistry.getInstance();
	if (format != null && registry.has(format))
		return format;
	return fallback;
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:8,代码来源:OntologyLoader.java

示例8: forMIMEType

import org.openrdf.rio.RDFParserRegistry; //导入依赖的package包/类
private RDFFormat forMIMEType(String contentType, RDFFormat fallback) {
	RDFFormat format = RDFFormat.forMIMEType(contentType);
	RDFParserRegistry registry = RDFParserRegistry.getInstance();
	if (format != null && registry.has(format))
		return format;
	return fallback;
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:8,代码来源:OntologyLoader.java

示例9: getAcceptHeader

import org.openrdf.rio.RDFParserRegistry; //导入依赖的package包/类
private String getAcceptHeader() {
	StringBuilder sb = new StringBuilder();
	String preferred = RDFFormat.RDFXML.getDefaultMIMEType();
	sb.append(preferred).append(";q=0.2");
	Set<RDFFormat> rdfFormats = RDFParserRegistry.getInstance().getKeys();
	for (RDFFormat format : rdfFormats) {
		for (String type : format.getMIMETypes()) {
			if (!preferred.equals(type)) {
				sb.append(", ").append(type);
			}
		}
	}
	return sb.toString();
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:15,代码来源:OntologyLoader.java

示例10: initialise

import org.openrdf.rio.RDFParserRegistry; //导入依赖的package包/类
@PostConstruct
public void initialise() {
    log.info("registering RDF importer ...");


    RDFParserRegistry parserRegistry = RDFParserRegistry.getInstance();

    acceptTypes = new ArrayList<String>();
    for(RDFFormat format : parserRegistry.getKeys()) {
        acceptTypes.addAll(format.getMIMETypes());
    }
    log.info(" - available parsers: {}", Arrays.toString(acceptTypes.toArray()));

}
 
开发者ID:apache,项目名称:marmotta,代码行数:15,代码来源:RDFImporterImpl.java

示例11: getAcceptTypes

import org.openrdf.rio.RDFParserRegistry; //导入依赖的package包/类
/**
 * returns a list of all mimetypes which can be parsed by implemented parsers
 * @return
 */
@Override
public List<String> getAcceptTypes() {
       Set<String> acceptTypes = new LinkedHashSet<String>();
       for(RDFFormat format : RDFParserRegistry.getInstance().getKeys()) {
           // Ignore binary formats
           if(format.hasCharset()) {
               acceptTypes.addAll(format.getMIMETypes());
           }
       }
       return new ArrayList<String>(acceptTypes);
}
 
开发者ID:apache,项目名称:marmotta,代码行数:16,代码来源:MarmottaIOServiceImpl.java

示例12: 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();
}
 
开发者ID:bridgedb,项目名称:BridgeDb,代码行数:32,代码来源:RdfParser.java

示例13: 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;
    }
}
 
开发者ID:bridgedb,项目名称:BridgeDb,代码行数:14,代码来源:LinkSetCombiner.java

示例14: main

import org.openrdf.rio.RDFParserRegistry; //导入依赖的package包/类
public static void main(String args[]) throws Exception
{
    options.addOption(OptionBuilder.withLongOpt("ontology")
            .hasArg()
            .withArgName("file")
            .isRequired()
            .withDescription("ontology file used to construct conversion scripts")
            .create());

    RDFParserRegistry.getInstance().add(new TurtleParserFactory());
    QueryParserRegistry.getInstance().add(new SPARQLParserFactory());

    org.openrdf.repository.Repository repo = new SailRepository(new MemoryStore());
    repo.initialize();
    RepositoryConnection con = repo.getConnection();

    CommandLineParser parser = new PosixParser();
    CommandLine commandLine = parser.parse(options,args);

    File inputFile = new File(commandLine.getOptionValue("ontology"));
    con.add(inputFile, "", RDFFormat.TURTLE);//forFileName(inputFile.getName()));

    Resource cube = new Resource() {
        @Override
        public String stringValue() {
            return "http://extbi.lab.aau.dk/ontology/ltpch/lineitemCube";
        }
    };
    int i = 0;
    OlapDenormalizer converter = new Qb4OlapToDenormalized(con,".*[/#_]","");
    for ( String q :converter.generateInstanceDataQueries(cube))
    {
        File f = new File("tmp/"+ i++ +".spql");
        Writer w = new FileWriter(f);
        w.write(converter.getPrefixes());
        w.write(q);
        w.flush();
        w.close();
    }
    RDFWriter writer = Rio.createWriter(RDFFormat.TURTLE, new FileWriter("meta.ttl"));
    Repository rep = converter.generateOntology(cube);
    rep.getConnection().prepareGraphQuery(QueryLanguage.SPARQL,
            "CONSTRUCT {?s ?p ?o } WHERE {?s ?p ?o } ").evaluate(writer);
    return;
}
 
开发者ID:abondoa,项目名称:swod,代码行数:46,代码来源:Main.java

示例15: getFormat

import org.openrdf.rio.RDFParserRegistry; //导入依赖的package包/类
private static RDFFormat getFormat(String format) {
    return RDFParserRegistry.getInstance().getFileFormatForMIMEType(format);
}
 
开发者ID:apache,项目名称:marmotta,代码行数:4,代码来源:RDFImporterImpl.java


注:本文中的org.openrdf.rio.RDFParserRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。