com.hp.hpl.jena.rdf.model.Resource.isLiteral()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中com.hp.hpl.jena.rdf.model.Resource.isLiteral方法的一些代码示例,展示了Resource.isLiteral的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.isLiteral方法的具体详情如下:
包路径:com.hp.hpl.jena.rdf.model.Resource
类名称:Resource
方法名:isLiteral

Resource.isLiteral介绍

暂无

代码示例

代码示例来源:origin: uk.ac.open.kmi.iserve/iserve-semantic-discovery

/**
 * Given a query result from a SPARQL query, obtain the number value at the
 * given variable
 *
 * @param resultRow    the result from a SPARQL query
 * @param variableName the name of the variable to obtain
 * @return the Integer value, or null otherwise
 */
public static Integer getIntegerValue(QuerySolution resultRow, String variableName) {
  if (resultRow != null) {
    Resource res = resultRow.getResource(variableName);
    if (res != null && res.isLiteral()) {
      Literal val = res.asLiteral();
      if (val != null) {
        return Integer.valueOf(val.getInt());
      }
    }
  }
  return null;
}

代码示例来源:origin: uk.ac.open.kmi.iserve/iserve-semantic-discovery

/**
 * Given a query result from a SPARQL query, obtain the given variable value
 * as a String
 *
 * @param resultRow    the result from a SPARQL query
 * @param variableName the name of the variable to obtain
 * @return the value or null if it could not be found
 */
private static String getStringValueFromRow(QuerySolution resultRow, String variableName) {
  // Check the input and exit immediately if null
  if (resultRow == null) {
    return null;
  }
  String result = null;
  Resource res = resultRow.getResource(variableName);
  if (res != null && res.isLiteral()) {
    result = res.asLiteral().getString();
  }
  return result;
}

代码示例来源:origin: de.unibonn.iai.eis/luzzu-semantics

public static String toSPARQL(Resource n){
  if (n != null && (n.isResource() || n.isLiteral())){
    if (n.isURIResource()) 
      return "<" + n.getURI() + ">";
    else if (n.isLiteral()) {
      String sparql = "'''" + sparqlEncode(n.asLiteral().toString()) + "'''";
      //does it have a Datatype Literal?
      if (n.asLiteral().getDatatypeURI() != null){
        sparql = sparql + "'''^^<" + n.asLiteral().getDatatypeURI().toString() + ">";
      }
      
      if (n.asLiteral().getLanguage() != ""){
        sparql = sparql + "'''@" + n.asLiteral().getLanguage();
      }
      return sparql;
    }
    else return null; //TODO: throws exception
  } else
    return null; //TODO: throws exception
}

代码示例来源:origin: nkons/r2rml-parser

if (r.isLiteral()) {
  this.literal = Boolean.TRUE;

代码示例来源:origin: nkons/r2rml-parser

while (iter2.hasNext()) {
  Resource r = iter2.nextResource();
  if (r.isLiteral()) {
    log.info("Found literal with a table name: <" + r.asLiteral().toString() + ">");
  } else {

相关文章