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


Java Lock类代码示例

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


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

示例1: DumpRDF2disk

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public void DumpRDF2disk() {
    OutputStream out;
    DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
    Date date = new Date();
    String dump = logpath+"buffered-"+dateFormat.format(date)+".ttl";
    File f = new File(dump);
    Model Dump = ModelFactory.createDefaultModel();
    if (f.exists()) {
        Dump = RDFDataMgr.loadModel(dump);
        f.delete();
        buffer.enterCriticalSection(Lock.WRITE);
        try {
            Dump.add(buffer);
            buffer.removeAll();
        } finally {
            buffer.leaveCriticalSection();
        }
    }
    try {
        out = new FileOutputStream(dump);
        Dump.write(out,"TTL");
        Dump.removeAll();
    } catch (FileNotFoundException ex) {
        logger.error(ex.toString());
    }
}
 
开发者ID:ebremer,项目名称:PipeLogger,代码行数:27,代码来源:Pipe.java

示例2: flushRDF2QuadStore

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public boolean flushRDF2QuadStore(Model z) {
    boolean success = false;
    StringWriter writer = new StringWriter();
    z.enterCriticalSection(Lock.WRITE);
    try {
        z.write(writer,"TTL");
        try {    
            ContentResponse response = httpClient.newRequest(uri).method(HttpMethod.POST).content(new BytesContentProvider(writer.toString().getBytes()),"text/turtle").send();
            if (response.getStatus()==200) {
                z.removeAll();
                success = true;
                flush = false;
            }               
        } finally {
            z.leaveCriticalSection();
        }
    } catch (InterruptedException | TimeoutException | ExecutionException ex) {
        logger.error(ex.toString());
    }
    return success;
}
 
开发者ID:ebremer,项目名称:PipeLogger,代码行数:22,代码来源:Pipe.java

示例3: termExists

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
private Boolean termExists(String ns, Node term){
   	if (termsExists.containsKey(term.getURI())){
   		return termsExists.get(term.getURI());
   	} else {
		Model m = (getModelForVocabulary(term).size() > 0) ? getModelForVocabulary(term) : null;
		if (m == null) return false;
		
		m.enterCriticalSection(Lock.READ);
		try{
			if ((term.getNameSpace().startsWith(RDF.getURI())) && (term.getURI().matches(RDF.getURI()+"_[0-9]+"))){
				termsExists.putIfAbsent(term.getURI(),true);
			} else if (term.isURI()) {
				termsExists.putIfAbsent(term.getURI(), m.containsResource(Commons.asRDFNode(term)));
			}
		} finally {
			m.leaveCriticalSection();
		}
		return (termsExists.get(term.getURI()) == null) ? false : termsExists.get(term.getURI());
   	}
}
 
开发者ID:diachron,项目名称:quality,代码行数:21,代码来源:VocabularyLoader.java

示例4: isDeprecatedTerm

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public boolean isDeprecatedTerm(Node term){
		if (checkedDeprecatedTerm.containsKey(term.getURI())) return checkedDeprecatedTerm.get(term.getURI());
		
//		String ns = term.getNameSpace();
		
		Model m = (getModelForVocabulary(term).size() > 0) ? getModelForVocabulary(term) : null;
		if (m == null) return false;
		
		m.enterCriticalSection(Lock.READ);
		try{ 
			Resource r = Commons.asRDFNode(term).asResource();
			boolean isDeprecated = m.listObjectsOfProperty(r, RDF.type).filterKeep(deprecatedfilter).hasNext();
			checkedDeprecatedTerm.putIfAbsent(term.getURI(), isDeprecated);
		} finally {
			m.leaveCriticalSection();
		}
		return checkedDeprecatedTerm.get(term.getURI());
	}
 
开发者ID:diachron,项目名称:quality,代码行数:19,代码来源:VocabularyLoader.java

示例5: inferChildClass

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public Set<RDFNode> inferChildClass(Node term){
		if (childNodes.containsKey(term.getURI())){
			return childNodes.get(term.getURI());
		} else {
//			String ns = term.getNameSpace();
			Set<RDFNode> set = new LinkedHashSet<RDFNode>();

			Model m = (getModelForVocabulary(term).size() > 0) ? getModelForVocabulary(term) : null;
			if (m == null) return new LinkedHashSet<RDFNode>();
						
			m.enterCriticalSection(Lock.READ);
			try{ 
				String query = "SELECT ?child { ?child <"+RDFS.subClassOf.getURI()+">* <"+term.getURI()+"> }";
				
				QueryExecution q = QueryExecutionFactory.create(query,m);
				ResultSet rs = q.execSelect();
				while(rs.hasNext()) set.add(rs.next().get("child"));

				childNodes.putIfAbsent(term.getURI(), set);
			} finally {
				m.leaveCriticalSection();
			}
			return childNodes.get(term.getURI());
		}
	}
 
开发者ID:diachron,项目名称:quality,代码行数:26,代码来源:VocabularyLoader.java

示例6: inferChildProperty

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public Set<RDFNode> inferChildProperty(Node term){
		if (childNodes.containsKey(term.getURI())){
			return childNodes.get(term.getURI());
		} else {
//			String ns = term.getNameSpace();
			Set<RDFNode> set = new LinkedHashSet<RDFNode>();

			Model m = (getModelForVocabulary(term).size() > 0) ?  getModelForVocabulary(term) : null;
			if (m == null) return new LinkedHashSet<RDFNode>();

			m.enterCriticalSection(Lock.READ);
			try{ 
				String query = "SELECT ?child { ?child <"+RDFS.subPropertyOf.getURI()+">* <"+term.getURI()+"> }";
				
				QueryExecution q = QueryExecutionFactory.create(query,m);
				ResultSet rs = q.execSelect();
				while(rs.hasNext()) set.add(rs.next().get("child"));
				
				childNodes.putIfAbsent(term.getURI(), set);
			} finally {
				m.leaveCriticalSection();
			}
			return childNodes.get(term.getURI());
		}
	}
 
开发者ID:diachron,项目名称:quality,代码行数:26,代码来源:VocabularyLoader.java

示例7: isInverseFunctionalProperty

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public boolean isInverseFunctionalProperty(Node term){
		
//		String ns = term.getNameSpace();
		
		if (!isIFPMap.containsKey(term.getURI())){
			Model m = (getModelForVocabulary(term).size() > 0) ? getModelForVocabulary(term) : null;
			if (m == null) return false;
			m.enterCriticalSection(Lock.READ);
			try{ 
				isIFPMap.putIfAbsent(term.getURI(), (m.contains(Commons.asRDFNode(term).asResource(), RDF.type, OWL.InverseFunctionalProperty)));
			} finally {
				m.leaveCriticalSection();
			}
		}
		
		return isIFPMap.get(term.getURI());
	}
 
开发者ID:diachron,项目名称:quality,代码行数:18,代码来源:VocabularyLoader.java

示例8: getDisjointWith

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public Set<RDFNode> getDisjointWith(Node term){
		if (disjointWith.containsKey(term.getURI())){
			return disjointWith.get(term.getURI());
		} else {
//			String ns = term.getNameSpace();
			Model m = (getModelForVocabulary(term).size() > 0) ? getModelForVocabulary(term) : null;
			if (m == null) return new LinkedHashSet<RDFNode>();
			m.enterCriticalSection(Lock.READ);
			try{ 
				Set<RDFNode> set = new LinkedHashSet<RDFNode>(m.listObjectsOfProperty(Commons.asRDFNode(term).asResource(), OWL.disjointWith).toSet());
				
				Set<RDFNode> parent = new LinkedHashSet<RDFNode>(inferParentClass(term));
				parent.remove(OWL.Thing);
				for(RDFNode n : parent){
					if (n.isAnon()) continue;
					set.addAll(getDisjointWith(n.asNode()));
				}
				
				disjointWith.putIfAbsent(term.getURI(), set);
			} finally {
				m.leaveCriticalSection();
			}
			return disjointWith.get(term.getURI());
		}
	}
 
开发者ID:diachron,项目名称:quality,代码行数:26,代码来源:VocabularyLoader.java

示例9: sparqlAsk

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
/**
 * Query execution
 */

public static boolean sparqlAsk(String q, Model m) {
	Query query = QueryFactory.create(q) ;
	m.enterCriticalSection(Lock.READ);
	QueryExecution qExec = QueryExecutionFactory.create(query, m);
	boolean rs =  qExec.execAsk();
	m.leaveCriticalSection();
	return rs;	
}
 
开发者ID:tetherless-world,项目名称:s2s,代码行数:13,代码来源:Queries.java

示例10: sparqlSelect

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public static ResultSet sparqlSelect(String q, Model m) {
	Query query = QueryFactory.create(q) ;
	m.enterCriticalSection(Lock.READ);
	QueryExecution qExec = QueryExecutionFactory.create(query, m);
	ResultSet rs =  qExec.execSelect();
	m.leaveCriticalSection();
	return rs;
}
 
开发者ID:tetherless-world,项目名称:s2s,代码行数:9,代码来源:Queries.java

示例11: run

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
/**
 * Add OWL rules and compute the forward chain.
 * 
 * @param base
 * @param datasetPaths
 */
public static void run(String base) {

	Reasoner reasoner = PelletReasonerFactory.theInstance().create();
	OntModel ontModel = ModelFactory
			.createOntologyModel(PelletReasonerFactory.THE_SPEC);
	InfModel infModel = ModelFactory.createInfModel(reasoner, ontModel);

	String path = System.getProperty("user.dir");
	RDFDataMgr.read(infModel, "file://" + path + "/" + base + "/model.nt");

	logger.info("Model size = " + ontModel.size());

	ValidityReport report = infModel.validate();
	printIterator(report.getReports(), "Validation Results");

	logger.info("Inferred model size = " + infModel.size());

	infModel.enterCriticalSection(Lock.READ);

	try {
		RDFDataMgr.write(new FileOutputStream(new File(base
				+ "/model-fwc.nt")), infModel, Lang.NT);
		logger.info("Model generated.");
	} catch (FileNotFoundException e) {
		logger.fatal(e.getMessage());
		throw new RuntimeException("Necessary file model-fwc.nt was not generated.");
	} finally {
		infModel.leaveCriticalSection();
	}

	new File(base + "/model.nt").delete();

}
 
开发者ID:mommi84,项目名称:Mandolin,代码行数:40,代码来源:PelletReasoner.java

示例12: closure

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public static void closure(String input, String output) {
	
	Reasoner reasoner = PelletReasonerFactory.theInstance().create();
	OntModel ontModel = ModelFactory
			.createOntologyModel(PelletReasonerFactory.THE_SPEC);
	InfModel infModel = ModelFactory.createInfModel(reasoner, ontModel);

	String path = System.getProperty("user.dir");
	RDFDataMgr.read(infModel, "file://" + path + "/" + input);

	logger.info("Model = "+input+", size = " + ontModel.size());

	ValidityReport report = infModel.validate();
	printIterator(report.getReports(), "Validation Results");

	logger.info("Inferred model size = " + infModel.size());

	infModel.enterCriticalSection(Lock.READ);

	try {
		RDFDataMgr.write(new FileOutputStream(new File(output)), 
				infModel, Lang.NT);
		logger.info("Model generated at "+output);
	} catch (FileNotFoundException e) {
		logger.fatal(e.getMessage());
		throw new RuntimeException("Necessary file "+output+" was not generated.");
	} finally {
		infModel.leaveCriticalSection();
	}
	
}
 
开发者ID:mommi84,项目名称:Mandolin,代码行数:32,代码来源:PelletReasoner.java

示例13: isObjectProperty

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public Boolean isObjectProperty(Node term, Boolean first){
//		String ns = term.getNameSpace();
		if (!objectProperties.containsKey(term.getURI())){
			Model m = (getModelForVocabulary(term).size() > 0) ? getModelForVocabulary(term) : null;
			if (m == null) return false;
						
			m.enterCriticalSection(Lock.READ);
			try{
				boolean isProperty = m.contains(Commons.asRDFNode(term).asResource(),  RDF.type, OWL.ObjectProperty);
				
				if (!isProperty){
					try{
						if (first){
							logger.debug("Trying to infer class");
							Node inferred = m.listObjectsOfProperty(Commons.asRDFNode(term).asResource(), RDF.type).next().asNode();
							
							if ((inferred.getURI().equals(OWL.Class.getURI())) || (inferred.getURI().equals(RDFS.Class.getURI())))
								isProperty = false;
							else
								isProperty = isObjectProperty(inferred,false);
						}
					} catch (Exception e){}
				}
				objectProperties.putIfAbsent(term.getURI(), isProperty);
			} finally {
				m.leaveCriticalSection();
			}
		}
		
		return objectProperties.get(term.getURI());
	}
 
开发者ID:diachron,项目名称:quality,代码行数:32,代码来源:VocabularyLoader.java

示例14: isDatatypeProperty

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public Boolean isDatatypeProperty(Node term, boolean first){
//		String ns = term.getNameSpace();
		if (!datatypeProperties.containsKey(term.getURI())){
			Model m = (getModelForVocabulary(term).size() > 0) ? getModelForVocabulary(term) : null;
			if (m == null) return false;
			
			m.enterCriticalSection(Lock.READ);
			try{
				boolean isProperty = m.contains(Commons.asRDFNode(term).asResource(),  RDF.type, OWL.DatatypeProperty);
				
				if (!isProperty){
					try{
						if (first){
							logger.debug("Trying to infer class");
							Node inferred = m.listObjectsOfProperty(Commons.asRDFNode(term).asResource(), RDF.type).next().asNode();
							
							if ((inferred.getURI().equals(OWL.Class.getURI())) || (inferred.getURI().equals(RDFS.Class.getURI())))
								isProperty = false;
							else
								isProperty = isDatatypeProperty(inferred,false);
						}
					} catch (Exception e){}
				}
				
				datatypeProperties.putIfAbsent(term.getURI(), isProperty);
			} finally {
				m.leaveCriticalSection();
			}
		}
		return datatypeProperties.get(term.getURI());
	}
 
开发者ID:diachron,项目名称:quality,代码行数:32,代码来源:VocabularyLoader.java

示例15: getPropertyDomain

import com.hp.hpl.jena.shared.Lock; //导入依赖的package包/类
public Set<RDFNode> getPropertyDomain(Node term){
		if (propertyDomains.containsKey(term.getURI())) return propertyDomains.get(term.getURI());
		
//		String ns = term.getNameSpace();
		
		Set<RDFNode> set = new HashSet<RDFNode>();

		Model m = (getModelForVocabulary(term).size() > 0) ? getModelForVocabulary(term) : null;
		if (m == null) return set;
		
		m.enterCriticalSection(Lock.READ);
		try{ 
			Set<RDFNode> _tmp = m.listObjectsOfProperty(Commons.asRDFNode(term).asResource(), RDFS.domain).toSet();
			for (RDFNode node : _tmp){
				if (m.contains(node.asResource(), OWL.unionOf)){
					set.addAll(m.listObjectsOfProperty(node.asResource(), OWL.unionOf).toSet());
				} else {
					set.add(node);
				}
			}
			propertyDomains.putIfAbsent(term.getURI(), set);
		} finally {
			m.leaveCriticalSection();
		}
		
		return propertyDomains.get(term.getURI());
	}
 
开发者ID:diachron,项目名称:quality,代码行数:28,代码来源:VocabularyLoader.java


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