本文整理汇总了Java中com.hp.hpl.jena.rdf.model.RDFNode.isAnon方法的典型用法代码示例。如果您正苦于以下问题:Java RDFNode.isAnon方法的具体用法?Java RDFNode.isAnon怎么用?Java RDFNode.isAnon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.RDFNode
的用法示例。
在下文中一共展示了RDFNode.isAnon方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
示例3: getParents
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
/**
* Look up <code>uri</code> in the ontology and return a list of parent
* concepts (URIs). Synonyms are not considered. The list contains no
* duplicates. Never returns <code>null</code>.
*
* @param term
* term to be looked up
* @return a list of parent concepts URIs
*/
// TODO add all synonyms of the parents to the result
public List<String> getParents(String uri) {
Resource resource = model.getResource(uri);
if (resource == null)
return Collections.emptyList();
List<String> result = new ArrayList<String>();
StmtIterator parent = resource.listProperties(RDFS.subClassOf);
while(parent.hasNext()) {
RDFNode child = parent.nextStatement().getObject();
if (child.isResource() && !child.isAnon() /*&& !((Resource)child).hasLiteral(Jura.invisible, true)*/) {
result.add(((Resource)child).getURI());
}
}
return result;
}
示例4: object
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
private String object(RDFNode node) {
if (node.isLiteral()) {
Literal lit = node.asLiteral();
String text = lit.getString();
String lang = lit.getLanguage();
String type = lit.getDatatypeURI();
if (lang == null || "".equals(lang)) {
lang = "";
} else {
lang = " xml:lang='" + escapeXml(lang) + "'";
}
if ("".equals(lang)) {
if (type == null) {
type = "http://www.w3.org/2001/XMLSchema#string";
}
type = " datatype='" + escapeXml(type) + "'";
} else {
type = "";
}
return "<sem:object" + type + lang + ">" + escapeXml(text) + "</sem:object>";
} else if (node.isAnon()) {
return "<sem:object>http://marklogic.com/semantics/blank/" + Long.toHexString(
fuse(scramble((long)node.hashCode()),fuse(scramble(milliSecs),randomValue)))
+"</sem:object>";
} else {
return "<sem:object>" + escapeXml(node.toString()) + "</sem:object>";
}
}
示例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: toIdentifier
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
/**
* This ID may be either a URI or a literal.
*
* @param o
* @return
*/
private static String toIdentifier(RDFNode o) {
if (o.isResource())
return o.isAnon() ? "http://rocker.aksw.org/"
+ "blanknode/BN" + DigestUtils.shaHex(o.toString())
: ((Resource) o).getURI();
else
return o.as(Literal.class).getString();
}
示例7: copyFromTdb
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
private void copyFromTdb( Dataset dataset ) throws RepositoryException {
ValueFactory vf = rc.getValueFactory();
if ( dataset.supportsTransactions() ) {
dataset.begin( ReadWrite.READ );
}
// Get model inside the transaction
Model model = dataset.getDefaultModel();
StmtIterator si = model.listStatements();
try {
rc.begin();
while ( si.hasNext() ) {
Statement stmt = si.next();
com.hp.hpl.jena.rdf.model.Resource rsr = stmt.getSubject();
Property pred = stmt.getPredicate();
RDFNode val = stmt.getObject();
Node valnode = val.asNode();
Resource sub;
try {
sub = ( rsr.isAnon()
? vf.createBNode( valnode.getBlankNodeLabel() )
: vf.createURI( rsr.toString() ) );
}
catch ( UnsupportedOperationException uoo ) {
log.warn( uoo, uoo );
continue;
}
URI pred2 = vf.createURI( pred.toString() );
Value val2;
if ( val.isLiteral() ) {
Literal lit = val.asLiteral();
String dtstr = lit.getDatatypeURI();
URI dt = ( null == dtstr ? null : vf.createURI( dtstr ) );
String langstr = lit.getLanguage();
if ( null == dt ) {
if ( langstr.isEmpty() ) {
val2 = vf.createLiteral( lit.toString() );
}
else {
val2 = vf.createLiteral( lit.toString(), langstr );
}
}
else {
val2 = vf.createLiteral( lit.toString(), dt );
}
}
else {
if ( val.isAnon() ) {
val2 = vf.createBNode( valnode.getBlankNodeLabel() );
}
else {
val2 = vf.createURI( val.toString() );
}
}
rc.add( sub, pred2, val2 );
}
rc.commit();
}
catch ( RepositoryException re ) {
rc.rollback();
throw re;
}
finally {
if ( dataset.supportsTransactions() ) {
dataset.end();
}
}
}
示例8: isTypeOf
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
boolean isTypeOf(RDFNode node) {
return (node.isURIResource() || node.isAnon());
}
示例9: object
import com.hp.hpl.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
private void object(TreeWriter tree, RDFNode node) {
if (node.isLiteral()) {
Literal lit = node.asLiteral();
String text = lit.getString();
String lang = lit.getLanguage();
String type = lit.getDatatypeURI();
if (lang == null || "".equals(lang)) {
lang = null;
} else {
lang = escapeXml(lang);
}
if (lang == null) {
if (type == null) {
type = "http://www.w3.org/2001/XMLSchema#string";
}
type = escapeXml(type);
} else {
type = null;
}
tree.addStartElement(sem_object);
if (lang != null) {
tree.addAttribute(XProcConstants.xml_lang, lang);
}
if (type != null) {
tree.addAttribute(_datatype, type);
}
tree.startContent();
tree.addText(escapeXml(text));
tree.addEndElement();
} else if (node.isAnon()) {
String uri = "http://marklogic.com/semantics/blank/" + Long.toHexString(
fuse(scramble((long)node.hashCode()),fuse(scramble(milliSecs),randomValue)));
tree.addStartElement(sem_object);
tree.startContent();
tree.addText(uri);
tree.addEndElement();
} else {
tree.addStartElement(sem_object);
tree.startContent();
tree.addText(escapeXml(node.toString()));
tree.addEndElement();
}
}