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


Java RDFNode.isLiteral方法代码示例

本文整理汇总了Java中org.apache.jena.rdf.model.RDFNode.isLiteral方法的典型用法代码示例。如果您正苦于以下问题:Java RDFNode.isLiteral方法的具体用法?Java RDFNode.isLiteral怎么用?Java RDFNode.isLiteral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jena.rdf.model.RDFNode的用法示例。


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

示例1: getDisplayName

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
public static String getDisplayName(RDFNode node) {
	if (node == null)
		return "unknown";
	else if (node.isAnon())
		return "anon";
	else if (node.isLiteral())
		return node.asLiteral().getLexicalForm();
	else if (node.isResource()) {
		Resource resource = node.asResource();
		if (resource instanceof OntResource) {
			String label = ((OntResource) resource).getLabel(null);
			if (label != null)
				return label;
		}
		String localName = resource.getLocalName();
		if ((localName != null) && !localName.isEmpty())
			return localName;
		return resource.toString();
	} else
		return "unknown";
}
 
开发者ID:apache,项目名称:incubator-taverna-plugin-component,代码行数:22,代码来源:SemanticAnnotationUtils.java

示例2: mergeDescription

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
private void mergeDescription(Resource ir, Resource r, boolean flagOK, Map<RDFNode,RDFNode> visited) {
	for (StmtIterator si = r.listProperties(); si.hasNext(); ) {
		Statement stmt = si.nextStatement();
		Property p = stmt.getPredicate();
		RDFNode o = stmt.getObject();
		
		if (flagOK && r.hasProperty(RDF.type, OWL.Class))
			ir.addProperty(RDF.type, infModel.getResource(Gloze.OK));
		
		if (o.isLiteral()) 
			ir.addProperty(p,o);
		
		else if (!o.isAnon())
			ir.addProperty(p,infModel.createResource(((Resource)o).getURI()));
		
		else if (o.isAnon() && visited.containsKey(o))
			ir.addProperty(p,visited.get(o));

		else { // recursively merge anonymous objects
			Resource a = infModel.createResource();
			visited.put(o,a);
			ir.addProperty(p,a);
			mergeDescription(a, (Resource)o, false, visited);
		}
	}
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:27,代码来源:Context.java

示例3: mergeData

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
public void mergeData(Model mainConferenceModel) {
	StmtIterator stmtIterator = dataModel.listStatements();
	while (stmtIterator.hasNext()) {
		Statement stmt = stmtIterator.next();
		RDFNode object = stmt.getObject();
		if (object.isLiteral()) {
			if (!mainConferenceModel.contains(stmt.getSubject(),
					stmt.getPredicate(), (RDFNode) null)) {
				mainConferenceModel.add(stmt);
			}
		} else {
			if (!mainConferenceModel.contains(stmt))
				mainConferenceModel.add(stmt);
		}
	}
}
 
开发者ID:AnLiGentile,项目名称:cLODg,代码行数:17,代码来源:DataHandler.java

示例4: getNodeValue

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
private static String getNodeValue(RDFNode node) {
	if (node.isLiteral()) {
		Literal lit = node.asLiteral();
		return lit.getLexicalForm();
	}
	if (node.isResource()) {
		Resource res = node.asResource();
		return res.getURI();
	}
	throw new RuntimeException("RDF node " + node + " is neither a literal nor a resource!");
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:12,代码来源:RDFProjector.java

示例5: getVRankOfResource

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
static float getVRankOfResource(String uri) {
    uri = "<" + uri + ">";
    String var = "v";
    String queryString = Constants.PREFIX_VRANK +
            "SELECT ?" + var + "\n" +
            "FROM <http://dbpedia.org> \n" +
            "FROM <http://people.aifb.kit.edu/ath/#DBpedia_PageRank> \n" +
            "WHERE {\n" +
            uri + " vrank:hasRank/vrank:rankValue ?" + var + ".\n" +
            "}\n";

    try {
        ResultSet results = SPARQLClient.runSelectQuery(queryString, Constants.DBPEDIA_SPARQL_SERVICE);
        if (results != null) {
            while (results.hasNext()) {
                QuerySolution result = results.next();
                RDFNode vRank = result.get(var);
                if (vRank != null && vRank.isLiteral()) {
                    Literal literal = (Literal) vRank;
                    return (literal.getFloat());
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 0;
}
 
开发者ID:slidewiki,项目名称:auto-questions-service,代码行数:29,代码来源:QueryUtils.java

示例6: getStringLiteral

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
static String getStringLiteral(RDFNode node) {
    String literal = null;
    if (node != null && node.isLiteral()) {
        literal = ((Literal) node).getLexicalForm();
    }
    return literal;
}
 
开发者ID:slidewiki,项目名称:auto-questions-service,代码行数:8,代码来源:QueryUtils.java

示例7: getResultSetAsObjectList

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
static List<LinkSUMResultRow> getResultSetAsObjectList(ResultSet resultSet) {
    List<LinkSUMResultRow> rows = new ArrayList<>();
    String subject = "subject";
    String predicate = "pred";
    String object = "object";
    String subLabel = "sublabel";
    String predLabel = "predlabel";
    String obLabel = "oblabel";
    String vRank = "v";

    if (resultSet != null) {
        while (resultSet.hasNext()) {
            QuerySolution result = resultSet.next();
            LinkSUMResultRow.LinkSUMResultRowBuilder builder = LinkSUMResultRow.builder();
            if (result != null) {
                RDFNode subjectNode = result.get(subject);
                RDFNode predicateNode = result.get(predicate);
                RDFNode objectNode = result.get(object);
                builder
                        .subject(subjectNode != null ? subjectNode.toString() : null)
                        .predicate(predicateNode != null ? predicateNode.toString() : null)
                        .object(objectNode != null ? objectNode.toString() : null)
                        .subjectLabel(getStringLiteral(result.get(subLabel)))
                        .predicateLabel(getStringLiteral(result.get(predLabel)))
                        .objectLabel(getStringLiteral(result.get(obLabel)));
                RDFNode vRankNode = result.get(vRank);
                if (vRankNode != null && vRankNode.isLiteral()) {
                    Literal literal = (Literal) vRankNode;
                    builder.vRank(literal.getFloat());
                }
                rows.add(builder.build());
            }
        }
    }
    return rows;
}
 
开发者ID:slidewiki,项目名称:auto-questions-service,代码行数:37,代码来源:QueryUtils.java

示例8: addResultsToList

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
static void addResultsToList(ResultSet results, List<String> resources, String var) {
    if (results != null) {
        while (results.hasNext()) {
            QuerySolution result = results.next();
            if (result != null) {
                RDFNode n = result.get(var);
                String nameLiteral;
                if (n.isLiteral()) {
                    nameLiteral = ((Literal) n).getLexicalForm();
                    resources.add(nameLiteral);
                }
            }
        }
    }
}
 
开发者ID:slidewiki,项目名称:auto-questions-service,代码行数:16,代码来源:QueryUtils.java

示例9: getImageName

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
protected String getImageName(Model model, String subjUri) {
    if (model == null) {
        return null;
    }
    Resource subj = model.getResource(subjUri);
    NodeIterator iterator = model.listObjectsOfProperty(subj, HOBBIT.imageName);
    if (iterator.hasNext()) {
        RDFNode node = iterator.next();
        if (node.isLiteral()) {
            return node.asLiteral().getString();
        }
    }
    return null;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:15,代码来源:ImageManagerImpl.java

示例10: getImageName

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
protected static String getImageName(Model model, String subjUri) {
    if (model == null) {
        return null;
    }
    Resource subj = model.getResource(subjUri);
    NodeIterator iterator = model.listObjectsOfProperty(subj, HOBBIT.imageName);
    if (iterator.hasNext()) {
        RDFNode node = iterator.next();
        if (node.isLiteral()) {
            return node.asLiteral().getString();
        }
    }
    return null;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:15,代码来源:FileBasedImageManager.java

示例11: getNodeLabel

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
public String getNodeLabel(RDFNode node) {
	if(node.isLiteral()) {
		return node.asNode().getLiteralLexicalForm();
	}
	else {
		return getLabel((Resource)node);
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:9,代码来源:RDFLabels.java

示例12: parseGraph

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
private Graph parseGraph(RDFNode node) {
	Model model = JenaUtil.createDefaultModel();
	if(node.isLiteral()) {
		String str = node.asLiteral().getLexicalForm();
		model.read(new ByteArrayInputStream(str.getBytes()), "urn:x-dummy", FileUtils.langTurtle);
	}
	return model.getGraph();
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:9,代码来源:FunctionTestCaseType.java

示例13: getLanguages

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
protected List<Locale> getLanguages(Property property)
{
    if (property == null) throw new IllegalArgumentException("Property cannot be null");
    
    List<Locale> languages = new ArrayList<>();
    Resource langs = getPropertyResourceValue(property);
    if (langs != null)
    {
        if (!langs.canAs(RDFList.class))
        {
            if (log.isErrorEnabled()) log.error("ldt:lang value is not an rdf:List on template '{}'", getURI());
            throw new OntologyException("ldt:lang value is not an rdf:List on template  '" + getURI() +"'");
        }

        // could use list order as priority (quality value q=)
        RDFList list = langs.as(RDFList.class);
        ExtendedIterator<RDFNode> it = list.iterator();
        try
        {
            while (it.hasNext())
            {
                RDFNode langTag = it.next();
                if (!langTag.isLiteral())
                {
                    if (log.isErrorEnabled()) log.error("Non-literal language tag (ldt:lang member) on template '{}'", getURI());
                    throw new OntologyException("Non-literal language tag (ldt:lang member) on template '" + getURI() +"'");
                }

                languages.add(Locale.forLanguageTag(langTag.asLiteral().getString()));
            }
        }
        finally
        {
            it.close();
        }
    }
    
    return languages;
}
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:40,代码来源:TemplateImpl.java

示例14: getAgents

import org.apache.jena.rdf.model.RDFNode; //导入方法依赖的package包/类
private List<Agent> getAgents(URI base, Individual in,
		ObjectProperty property) {
	List<Agent> creators = new ArrayList<>();
	for (Individual agent : listObjectProperties(in, property)) {
		Agent a = new Agent();
		if (agent.getURI() != null)
			a.setUri(relativizeFromBase(agent.getURI(), base));

		RDFNode name = agent.getPropertyValue(foafName);
		if (name != null && name.isLiteral())
			a.setName(name.asLiteral().getLexicalForm());
		creators.add(a);
	}
	return creators;
}
 
开发者ID:apache,项目名称:incubator-taverna-language,代码行数:16,代码来源:RDFToManifest.java

示例15: 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));
  }
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:6,代码来源:CommandResult.java


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