Java Code Examples for com.hp.hpl.jena.rdf.model.RDFNode#canAs()

The following examples show how to use com.hp.hpl.jena.rdf.model.RDFNode#canAs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryHelper.java    From ldp4j with Apache License 2.0 5 votes vote down vote up
public final Literal literal(String binding) {
	if(!this.solution.contains(binding)) {
		return null;
	}
	RDFNode node = this.solution.get(binding);
	if(!node.canAs(Literal.class)) {
		throw new IllegalStateException("Binding '"+binding+"' is not a literal");
	}
	return node.asLiteral();
}
 
Example 2
Source File: QueryHelper.java    From ldp4j with Apache License 2.0 5 votes vote down vote up
public Resource resource(String binding) {
	if(!this.solution.contains(binding)) {
		return null;
	}
	RDFNode node = this.solution.get(binding);
	if(!node.canAs(Resource.class)) {
		throw new IllegalStateException("Binding '"+binding+"' is not a resource");
	}
	return node.asResource();
}
 
Example 3
Source File: ConceptImpl.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ObjectClass getParentConcept() {
	NodeIterator l = this.listPropertyValues(RDFS.subClassOf);

	while (l.hasNext()) {
		RDFNode res = l.nextNode();
		if (res.canAs(OntClass.class)) {
			OntClass ontClass = res.as(OntClass.class);
			if (ontClass.hasSuperClass(mdrDatabase.getVocabulary().Concept)) {
				return new ConceptImpl(res.asResource(), mdrDatabase);
			}
		}
	}
	return null;
}