本文整理汇总了Java中com.hp.hpl.jena.rdf.model.RDFNode.isURIResource方法的典型用法代码示例。如果您正苦于以下问题:Java RDFNode.isURIResource方法的具体用法?Java RDFNode.isURIResource怎么用?Java RDFNode.isURIResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.RDFNode
的用法示例。
在下文中一共展示了RDFNode.isURIResource方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nodeType
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
private String nodeType(RDFNode node) {
if (node.isURIResource()) {
return "IRI";
}
if (node.isAnon()) {
return "blank node";
}
if (!"".equals(node.asLiteral().getLanguage())) {
return "language-tagged string";
}
if (node.asLiteral().getDatatypeURI() == null) {
return "plain literal";
}
if (XSD.xstring.getURI().equals(node.asLiteral().getDatatypeURI())) {
return "string literal";
}
return "non-string typed literal";
}
示例2: toTurtle
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
private String toTurtle(RDFNode r) {
if (r.isURIResource()) {
return PrettyPrinter.qNameOrURI(relativize(r.asResource().getURI()), prefixes);
} else if (r.isLiteral()) {
StringBuffer result = new StringBuffer(quote(r.asLiteral().getLexicalForm()));
if (!"".equals(r.asLiteral().getLanguage())) {
result.append("@");
result.append(r.asLiteral().getLanguage());
} else if (r.asLiteral().getDatatype() != null) {
result.append("^^");
result.append(toTurtle(ResourceFactory.createResource(r.asLiteral().getDatatypeURI())));
}
return result.toString();
} else {
if (!blankNodeMap.containsKey(r)) {
blankNodeMap.put(r.asResource(), "_:b" + blankNodeCounter++);
}
return blankNodeMap.get(r);
}
}
示例3: compare
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
public int compare(RDFNode n1, RDFNode n2) {
if (n1.isURIResource()) {
if (!n2.isURIResource()) return -1;
return n1.asResource().getURI().compareTo(n2.asResource().getURI());
}
if (n1.isAnon()) {
if (n2.isURIResource()) return 1;
if (n2.isLiteral()) return -1;
return n1.asResource().getId().getLabelString().compareTo(n2.asResource().getId().getLabelString());
}
if (!n2.isLiteral()) return 1;
int cmpLex = n1.asLiteral().getLexicalForm().compareTo(n2.asLiteral().getLexicalForm());
if (cmpLex != 0) return cmpLex;
if (n1.asLiteral().getDatatypeURI() == null) {
if (n2.asLiteral().getDatatypeURI() != null) return -1;
return n1.asLiteral().getLanguage().compareTo(n2.asLiteral().getLanguage());
}
if (n2.asLiteral().getDatatypeURI() == null) return 1;
return n1.asLiteral().getDatatypeURI().compareTo(n2.asLiteral().getDatatypeURI());
}
示例4: toString
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
public static String toString(RDFNode n) {
if (n == null) return "null";
if (n.isURIResource()) {
Resource r = (Resource) n;
return toString(r.asNode(), r.getModel());
}
return toString(n.asNode());
}
示例5: coerce
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
RDFNode coerce(RDFNode in) {
if (in.isAnon()) return null;
if (in.isURIResource()) {
return ResourceFactory.createPlainLiteral(in.asResource().getURI());
}
return ResourceFactory.createPlainLiteral(in.asLiteral().getLexicalForm());
}
示例6: toString
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
public static String toString(RDFNode n) {
if (n.isURIResource()) {
Resource r = (Resource) n;
return toString(r.asNode(), r.getModel());
}
return toString(n.asNode());
}
示例7: nodeToString
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
private static String nodeToString(RDFNode node) {
if (node.isURIResource()) {
return node.asResource().getURI();
} else if (node.isLiteral()) {
return node.asLiteral().getLexicalForm();
} else {
return node.toString();
}
}
示例8: apply
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
@Override
public Optional<String> apply(final Statement input) {
final RDFNode object=input.getObject();
if(object.isURIResource()) {
return Optional.of(object.asResource().getURI());
}
this.report.warn("Discarding invalid value for property %s: not a URI (%s)",input.getPredicate().getURI(),object);
return Optional.absent();
}
示例9: filter
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
@Override
public boolean filter(Resource rsrc)
{
StmtIterator iter = rsrc.listProperties(rsrc.getModel().getProperty(_property));
while ( iter.hasNext() )
{
RDFNode obj = iter.next().getObject();
boolean res = false;
if ( obj.isLiteral() ) { res = filterLiteral(obj.asLiteral()); }
else if ( obj.isURIResource() ) { res = filterResource(obj.asResource()); }
if ( res ) { return true; }
}
return false;
}
示例10: extractInstances
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
public static List<String> extractInstances(String sparqlEndpoint, String clazz) throws IOException {
ArrayList<String> list = new ArrayList<>();
Map<String, String> litMap = new HashMap<>();
Map<String, String> iriMap = ImmutableMap.of("class", clazz);
String queryString = bindQueryString(isntancesQuery, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap));
List<RDFNode> nodeList = executeQueryForList(queryString, sparqlEndpoint, "s");
for (RDFNode clazzNode : nodeList) {
if (clazzNode.isURIResource()) {
list.add(clazzNode.asResource().getURI());
}
}
return list;
}
示例11: isTypeOf
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
boolean isTypeOf(RDFNode node) {
return (node.isURIResource());
}