當前位置: 首頁>>代碼示例>>Java>>正文


Java FileManager類代碼示例

本文整理匯總了Java中com.hp.hpl.jena.util.FileManager的典型用法代碼示例。如果您正苦於以下問題:Java FileManager類的具體用法?Java FileManager怎麽用?Java FileManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileManager類屬於com.hp.hpl.jena.util包,在下文中一共展示了FileManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAllTestLists

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
@Parameters(name="{index}: {0}")
public static Collection<Object[]> getAllTestLists() {
	Collection<Object[]> results = new ArrayList<Object[]>();
	for (File dir: new File(TEST_SUITE_DIR).listFiles()) {
		if (!dir.isDirectory() || !new File(dir.getAbsolutePath() + "/manifest.ttl").exists()) continue;
		String absolutePath = dir.getAbsolutePath();
		Model model = FileManager.get().loadModel(absolutePath + "/manifest.ttl");
		ResultSet resultSet = QueryExecutionFactory.create(QUERY, model).execSelect();
		while (resultSet.hasNext()) {
			QuerySolution solution = resultSet.nextSolution();
			if (Arrays.asList(D2RQTestUtil.SKIPPED_R2RML_TESTS).contains(solution.getResource("s").getLocalName())) continue;
			results.add(new Object[]{
					PrettyPrinter.toString(solution.getResource("s")),
					absolutePath + "/create.sql",
					absolutePath + "/" + solution.getLiteral("rml").getLexicalForm(),
					(solution.get("nquad") == null) ? 
							null : 
							absolutePath + "/" + solution.getLiteral("nquad").getLexicalForm()
			});
		}
	}
	return results;
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:24,代碼來源:R2RMLTest.java

示例2: doIndexing

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
private void doIndexing(String ontologyId, String name, String description, String iri){
	Model model = FileManager.get().loadModel(iri);
	
	IndexingJobInput indexingJobInput = null;
	if(ontologyId == null) indexingJobInput = new IndexingJobInput(name, description, iri, model);
	else indexingJobInput = new IndexingJobInput(ontologyId, name, description, iri, model);
	try {
		String jobId = indexOntology(indexingJobInput);
		while(!jobManager.ping(jobId).isDone())
			Thread.sleep(1000);
		
	} catch (OntologyAlreadyExistingException | InterruptedException e) {
		log.error(e.getMessage(), e);
	}
	
}
 
開發者ID:teamdigitale,項目名稱:ontonethub,代碼行數:17,代碼來源:OntoNetHubImpl.java

示例3: readConfig

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
private ResultSet readConfig(String config) {
    Model model = FileManager.get().loadModel( config );
    String queryString =
            "PREFIX ingest: <http://localhost/ingest#> " +
                    "SELECT ?debug ?name ?source ?model ?namedGraph WHERE { " +
                    "    ?t a ingest:Transform ; " +
                    "       ingest:name ?name ;" +
                    "       ingest:source ?source ;" +
                    "       ingest:model ?model ; " +
                    "       ingest:namedGraph ?namedGraph ." +
                    " OPTIONAL { ?t ingest:debug ?debug }" +
                    "}";
    Query query = QueryFactory.create(queryString);
    QueryExecution qexec = QueryExecutionFactory.create(query, model);
    return qexec.execSelect();
}
 
開發者ID:lawlesst,項目名稱:karma2vivo,代碼行數:17,代碼來源:Batch.java

示例4: run

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
@Test
public void run() {
	SystemLoader loader = new SystemLoader();
	loader.setJdbcURL(db.getJdbcURL());
	loader.setUsername(db.getUser());
	loader.setMappingFile(mappingFile);
	loader.setStartupSQLScript(sqlFile);
	loader.setSystemBaseURI(BASE_URI);
	if (resultFile == null) {
		R2RMLReader reader = loader.getR2RMLReader();
		MappingValidator validator = new MappingValidator(
				reader.getMapping(), loader.getSQLConnection());
		validator.setReport(reader.getReport());
		validator.run();
		if (!reader.getReport().hasError()) {
			fail("Expected validation error");
		}
		return;
	}
	Model actualTriples = ModelFactory.createDefaultModel();
	actualTriples.add(loader.getModelD2RQ());
	Model expectedTriples = FileManager.get().loadModel(resultFile, "N-TRIPLES");
	ModelAssert.assertIsomorphic(expectedTriples, actualTriples);
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:25,代碼來源:R2RMLTest.java

示例5: readRdfFile

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
static void readRdfFile (String pathToRdfFile) {
        // create an empty model
        Model model = ModelFactory.createDefaultModel();

        // use the FileManager to find the input file
        InputStream in = FileManager.get().open( pathToRdfFile );
        if (in == null) {
            throw new IllegalArgumentException(
                    "File: " + pathToRdfFile + " not found");
        }

// read the RDF/XML file
        model.read(in, null);

// write it to standard out
        model.write(System.out);
    }
 
開發者ID:newsreader,項目名稱:StreamEventCoreference,代碼行數:18,代碼來源:RdfReader.java

示例6: readModelFromFile

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
public static Model readModelFromFile(String modelFile)
{
  Model aModel = ModelFactory.createDefaultModel();

  System.out.print("Reading from ");

  if (FileManager.get().hasCachedModel(modelFile))
  {
    System.out.print("cache: ");
    aModel = FileManager.get().getFromCache(modelFile);
  }
  else
  {
    System.out.print("file:  ");
    InputStream in = FileManager.get().open( modelFile );
    if (in == null) {
      throw new IllegalArgumentException( "File: " + modelFile + " not found");
    }
    aModel.read(in, ""); 
    
    FileManager.get().addCacheModel(modelFile, aModel);
  }
  System.out.println(modelFile);

  return aModel;
}
 
開發者ID:vijayrajak,項目名稱:JenaKBClient,代碼行數:27,代碼來源:JenaUtils.java

示例7: isDisambiguationResource

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
public boolean isDisambiguationResource(String uri) {
    
    if(!linksLoaded){
        System.out.println(Settings.EN_DBPEDIA_DISAMBIGUATION_DATASET);
        System.out.println(Settings.DE_DBPEDIA_DISAMBIGUATION_DATASET);
        System.out.println(Settings.NL_DBPEDIA_DISAMBIGUATION_DATASET);
        InputStream in1 = FileManager.get().open( Settings.EN_DBPEDIA_DISAMBIGUATION_DATASET );
        InputStream in2 = FileManager.get().open( Settings.DE_DBPEDIA_DISAMBIGUATION_DATASET );
        InputStream in3 = FileManager.get().open( Settings.NL_DBPEDIA_DISAMBIGUATION_DATASET );
        model.read(in1, null, "N-TRIPLES");
        System.out.println("Loaded English disambiguation dataset.");
        model.read(in2, null, "N-TRIPLES");
        System.out.println("Loaded German disambiguation dataset.");
        model.read(in3, null, "N-TRIPLES");
        System.out.println("Loaded Dutch disambiguation dataset.");
        linksLoaded = true;
    }
    
    StmtIterator iter = model.listStatements( new SimpleSelector(
            ResourceFactory.createResource(uri), 
            ResourceFactory.createProperty("http://dbpedia.org/ontology/wikiPageDisambiguates"), 
                    (RDFNode)null));
    
    return iter.hasNext();
}
 
開發者ID:entityclassifier-eu,項目名稱:entityclassifier-core,代碼行數:26,代碼來源:DisambiguationPageValidator.java

示例8: creatSpdxDocument

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
/**
 * Encoding Treating
 * 
 * Date: 2013. 5. 22. ���� 12:30:31
 * Author: ytaek.kim
 * 
 * Method Brief : 
 * @param fileNameOrUrl
 * @return
 * @throws IOException
 * @throws InvalidSPDXAnalysisException
 *
 * #Logs:
 */
public static SPDXDocument creatSpdxDocument(String fileNameOrUrl, String charsetName) throws IOException, InvalidSPDXAnalysisException {
	try {
		Class.forName("net.rootdev.javardfa.jena.RDFaReader");
	} catch(java.lang.ClassNotFoundException e) {
		logger.warn("Unable to load the RDFaReader Class");
	}  

	InputStream spdxRdfInput = FileManager.get().open(fileNameOrUrl);
	if (spdxRdfInput == null)
		throw new FileNotFoundException("Unable to open \"" + fileNameOrUrl + "\" for reading");
	
	InputStreamReader inputReader = new InputStreamReader(spdxRdfInput, charsetName);
	
	Model model = ModelFactory.createDefaultModel();
	model.read(inputReader, figureBaseUri(fileNameOrUrl), fileType(fileNameOrUrl));
	return new SPDXDocument(model);
}
 
開發者ID:spdx,項目名稱:ATTIC-osit,代碼行數:32,代碼來源:SPDXDocumentFactory.java

示例9: createModelFromRdfFile

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
/**
 * This method loads data from given RDF file in a model.
 * @param inputFileName The path to the RDF file
 * @return model
 */
private Model createModelFromRdfFile(String inputFileName) {
	// create an empty model
  	    Model model = ModelFactory.createDefaultModel();

   	// use the FileManager to find the input file
   	InputStream in = FileManager.get().open(inputFileName);
   	
   	if (in == null) {
   	    throw new IllegalArgumentException(
   	                                 "File: " + inputFileName + " not found");
   	}

   	// read the RDF/XML file
   	model.read(in, null);
	return model;
}
 
開發者ID:gsergiu,項目名稱:music-genres,代碼行數:22,代碼來源:SkosUtils.java

示例10: write

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
public static void write(GraphDatabaseService njgraph) {
	InputStream in = FileManager.get().open( inputFileName );
	if (in == null) {
           throw new IllegalArgumentException( "File: " + inputFileName + " not found");
       }
       
	Model model = ModelFactory.createDefaultModel();
       model.read(in,"","RDF");
       double triples = model.size();
       System.out.println("Model loaded with " +  triples + " triples");
       
	NeoGraph graph = new NeoGraph(njgraph);
	Model njmodel = ModelFactory.createModelForGraph(graph);
	graph.startBulkLoad();
	System.out.println("NeoGraph Model initiated");
	StopWatch watch = new StopWatch();
	//log.info(njmodel.add(model));
	njmodel.add(model);
	System.out.println("Storing completed (ms): " + watch.stop());
	graph.stopBulkLoad();
}
 
開發者ID:semr,項目名稱:neo4jena,代碼行數:22,代碼來源:Wine.java

示例11: findInputStream

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
/**
   * This method converts a configuration path filename to a Jena policy file to an
   * InputStream and a uri string
   * @param configFilename
   *
   * @return -- an Object[2] array: 0th element is an InputStream, 1st element is a URI string used for guessing the language and for writing back to disk
   */
  protected static Object[] findInputStream(String configFilename) {
      FileManager fm = new FileManager();
      fm.addLocatorFile();
      fm.addLocatorURL();
      fm.addLocatorClassLoader( fm.getClass().getClassLoader() );

      InputStream in = null ;
      String uri = null;
      StringTokenizer pathElems = new StringTokenizer( configFilename, FileManager.PATH_DELIMITER );
      while (in == null && pathElems.hasMoreTokens()) {
          uri = pathElems.nextToken();
          in = fm.openNoMap( uri );
      }
      Object[] ret = new Object[2];
      ret[0] = in;
      ret[1] = uri;
      try {
	in.close();
} catch (IOException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
      return ret;
  }
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:32,代碼來源:ConfigurationManager.java

示例12: findInputStream

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
/**
 * This method converts a configuration path filename to a Jena policy file to an
 * InputStream and a uri string
 * @param configFilename
 *
 * @return -- an Object[2] array: 0th element is an InputStream, 1st element is a URI string used for guessing the language and for writing back to disk
 */
protected static Object[] findInputStream(String configFilename) {
    FileManager fm = new FileManager();
    fm.addLocatorFile();
    fm.addLocatorURL();
    fm.addLocatorClassLoader( fm.getClass().getClassLoader() );

    InputStream in = null ;
    String uri = null;
    StringTokenizer pathElems = new StringTokenizer( configFilename, FileManager.PATH_DELIMITER );
    while (in == null && pathElems.hasMoreTokens()) {
        uri = pathElems.nextToken();
        in = fm.openNoMap( uri );
    }
    Object[] ret = new Object[2];
    ret[0] = in;
    ret[1] = uri;
    return ret;
}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:26,代碼來源:ConfigurationManager.java

示例13: main

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
public static void main( String[] args )
{
	// load some data that uses RDFS
	Model data = FileManager.get().loadModel("file:data/input/turtle/ex5-data.ttl");

	
	Reasoner reasoner = ReasonerRegistry.getRDFSReasoner();
	reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel, 
               ReasonerVocabulary.RDFS_DEFAULT);
	InfModel infmodel = ModelFactory.createInfModel(reasoner, data );
	
	/* Do a SPARQL Query over the data in the model */
	String queryString = "SELECT ?x  ?z WHERE { ?x <http://www.example.org/example#worksFor> ?z }" ;

	/* Now create and execute the query using a Query object */
	Query query = QueryFactory.create(queryString) ;
	QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;

	QueryExecUtils.executeQuery(qexec);
	
	System.out.println( "\n----------\ndone" );
	
}
 
開發者ID:fogbeam,項目名稱:JenaTutorial,代碼行數:24,代碼來源:SparqlQueryWithPropertySubclass.java

示例14: main

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
public static void main(String args[])
{
	String filename = "example4.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// ** TASK 5.1: Read the ontology from the given file **
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// ** TASK 5.2: Write the ontology **
	model.write(System.out, "RDF/XML-ABBREV");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:21,代碼來源:Task05.java

示例15: main

import com.hp.hpl.jena.util.FileManager; //導入依賴的package包/類
public static void main( String[] args )
{

	Model schema = FileManager.get().loadModel("file:data/input/turtle/ex1-schema.ttl");
	Model data = FileManager.get().loadModel("file:data/input/turtle/ex1-data.ttl");
	InfModel infmodel = ModelFactory.createRDFSModel(schema, data);
	        
	
	ValidityReport validity = infmodel.validate();
	if (validity.isValid()) {
	    System.out.println("\nOK");
	} else {
	    System.out.println("\nConflicts");
	    for (Iterator i = validity.getReports(); i.hasNext(); ) {
	        ValidityReport.Report report = (ValidityReport.Report)i.next();
	        System.out.println(" - " + report);
	    }
	}
	
	System.out.println( "done" );
	
}
 
開發者ID:fogbeam,項目名稱:JenaTutorial,代碼行數:23,代碼來源:ReadRDF_And_Validate.java


注:本文中的com.hp.hpl.jena.util.FileManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。