本文整理匯總了Java中org.apache.jena.rdf.model.RDFNode.isURIResource方法的典型用法代碼示例。如果您正苦於以下問題:Java RDFNode.isURIResource方法的具體用法?Java RDFNode.isURIResource怎麽用?Java RDFNode.isURIResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jena.rdf.model.RDFNode
的用法示例。
在下文中一共展示了RDFNode.isURIResource方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: listStatements
import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public static void listStatements(Collection<Statement> result, Model model, RDFNode sourceVertex, RDFNode predicate, RDFNode targetVertex) {
if(sourceVertex != null && !sourceVertex.isURIResource()) {
result = Collections.emptySet();
} else if(predicate != null && predicate.canAs(Property.class)) {
result = Collections.emptySet();
} else {
Resource s = sourceVertex == null ? null : sourceVertex.asResource();
Property p = predicate == null ? null : predicate.as(Property.class);
result = model.listStatements(s, p, targetVertex).toSet();
}
}
示例2: getChallengeTasksFromUri
import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private List<ExperimentConfiguration> getChallengeTasksFromUri(String challengeUri) {
Model model = getChallengeFromUri(challengeUri);
if (model == null) {
LOGGER.error("Couldn't get model for challenge {} . Aborting.", challengeUri);
return null;
}
Resource challengeResource = model.getResource(challengeUri);
Calendar executionDate = RdfHelper.getDateValue(model, challengeResource, HOBBIT.executionDate);
ResIterator taskIterator = model.listSubjectsWithProperty(HOBBIT.isTaskOf, challengeResource);
List<ExperimentConfiguration> experiments = new ArrayList<>();
while (taskIterator.hasNext()) {
Resource challengeTask = taskIterator.next();
String challengeTaskUri = challengeTask.getURI();
// get benchmark information
String benchmarkUri = RdfHelper.getStringValue(model, challengeTask, HOBBIT.involvesBenchmark);
String experimentId, systemUri, serializedBenchParams;
// iterate participating system instances
NodeIterator systemInstanceIterator = model.listObjectsOfProperty(challengeTask,
HOBBIT.involvesSystemInstance);
RDFNode sysInstance;
while (systemInstanceIterator.hasNext()) {
sysInstance = systemInstanceIterator.next();
if (sysInstance.isURIResource()) {
systemUri = sysInstance.asResource().getURI();
experimentId = generateExperimentId();
serializedBenchParams = RabbitMQUtils
.writeModel2String(createExpModelForChallengeTask(model, challengeTaskUri, systemUri));
experiments.add(new ExperimentConfiguration(experimentId, benchmarkUri, serializedBenchParams,
systemUri, challengeUri, challengeTaskUri, executionDate));
} else {
LOGGER.error("Couldn't get the benchmark for challenge task \"{}\". This task will be ignored.",
challengeTaskUri);
}
}
}
return experiments;
}
示例3: deannotation
import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private static Map<String, Object> deannotation(Model model, RDFTemplate template) {
Map<String, Object> properties = new HashMap<>();
Query query = buildSPARQLQuery(template);
ResultSet resultSet = QueryExecutionFactory.create(query, model).execSelect();
if (resultSet.hasNext()) {
QuerySolution qs = resultSet.next();
Iterator<String> varNames = qs.varNames();
while (varNames.hasNext()) {
String name = varNames.next();
String tag = name.replaceAll("_", ".");
RDFNode node = qs.get(name);
if (node != null) {
if (node.isURIResource()) {
properties.put(tag, node.asResource().getURI());
} else {
properties.put(tag, node.asLiteral().getLexicalForm());
}
}
}
if (resultSet.hasNext()) {
throw new IllegalStateException("1");
}
} else {
throw new IllegalStateException("0");
}
return properties;
}
示例4: isSystemDatatype
import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
/**
* Checks if a given RDFNode represents a system XSD datatype such as xsd:int.
* Note: this will not return true on user-defined datatypes or rdfs:Literal.
* @param node the node to test
* @return true if node is a datatype
*/
public static boolean isSystemDatatype(RDFNode node) {
if (node instanceof Resource && node.isURIResource()) {
String uri = ((Resource)node).getURI();
return isNumeric(uri) || otherDatatypeURIs.contains(uri);
}
else {
return false;
}
}
示例5: printSPARQLStatement
import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
/**
* @param stmt
*/
public static void printSPARQLStatement(Statement stmt, OutputStreamWriter osw) {
if (logger.isDebugEnabled()) {
logger.debug("printSPARQLStatement: stmt: {}", stmt);
}
StringBuffer buf = new StringBuffer();
buf.append(" <");
buf.append(stmt.getSubject().getURI());
buf.append("> <");
buf.append(stmt.getPredicate().getURI());
buf.append("> ");
RDFNode objNode = stmt.getObject();
if (objNode.isURIResource())
buf.append("<").append(objNode.asResource().getURI()).append(">");
else {
RDFDatatype dt = objNode.asLiteral().getDatatype();
if ( logger.isDebugEnabled()) {
logger.debug("printSPARQLStatement: literal datatype URI: {}, java class: {}", dt.getURI(), dt.getJavaClass());
}
if (dt.getURI().equals(XSDDatatype.XSDstring.getURI())) {
buf.append("\"").append(sparqlEscape(objNode.asLiteral().getString())).append("\"");
if (StringUtils.isNotEmpty(objNode.asLiteral().getLanguage()))
buf.append("@").append(objNode.asLiteral().getLanguage());
} else if (dt.getURI().equals(RDF.langString.getURI())) {
buf.append("\"").append(sparqlEscape(objNode.asLiteral().getString())).append("\"");
if (StringUtils.isNotEmpty(objNode.asLiteral().getLanguage()))
buf.append("@").append(objNode.asLiteral().getLanguage());
} else if (dt.getURI().equals(XSDDatatype.XSDboolean.getURI())) {
buf.append(objNode.asLiteral().getBoolean());
} else if (dt.getURI().equals(XSDDatatype.XSDint.getURI()) ||
dt.getURI().equals(XSDDatatype.XSDinteger.getURI())) {
buf.append(objNode.asLiteral().getInt());
} else if (dt.getURI().equals(XSDDatatype.XSDlong.getURI())) {
buf.append(objNode.asLiteral().getLong());
} else if (dt.getURI().equals(XSDDatatype.XSDanyURI.getURI())) {
buf.append("\"").append(objNode.asLiteral().getString()).append("\"^^<").append(XSDDatatype.XSDanyURI.getURI()).append(">");
} else if (dt.getURI().equals(XSDDatatype.XSDdate.getURI())) {
buf.append("\"").append(objNode.asLiteral().getLexicalForm()).append("\"^^<").append(XSDDatatype.XSDdate.getURI()).append(">");
} else if (dt.getJavaClass() != null && dt.getJavaClass().getName() != null &&
dt.getJavaClass().getName().equals("java.util.Date")) {
buf.append("\"").append(dtfmt.format(objNode.asLiteral().getValue())).append("\"^^<").append(XSDDatatype.XSDdate.getURI()).append(">");
} else {
logger.warn("printSPARQLStatement: unrecognized literal datatype: {}", dt.getURI());
buf.append("\"").append(sparqlEscape(objNode.asLiteral().getString())).append("\"");
}
}
try {
osw.append(buf.toString() + " .").append("\n");
} catch (IOException ioe) {
logger.error("failed to write statement for SPARQL", ioe);
}
}
示例6: addProperty
import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public void addProperty(Property property, RDFNode value) {
if (value.isLiteral() || value.isURIResource()) {
properties.add(new CommandProperty(property, value));
}
}