代码之家  ›  专栏  ›  技术社区  ›  Mark Miller

用于将文字拆分为值和数据类型的RDF4J方法

  •  2
  • Mark Miller  · 技术社区  · 8 年前

    cxn 对着一个空的三重音符,我说:

    val CheckSparql = "select (count(?s) as ?scount) where { ?s ?p ?o . }"
    
    val PreparedSparql = cxn.prepareTupleQuery(QueryLanguage.SPARQL, CheckSparql)
    val Result = PreparedSparql.evaluate()
    val ResBindSet = Result.next()
    val TripleCount = ResBindSet.getValue("scount")
    
    println(TripleCount.toString())
    

    我明白了

    "0"^^<http://www.w3.org/2001/XMLSchema#integer>
    

    是否有RDF4J方法仅用于检索该文字的值?

    我只需要0或“0”,不需要数据类型

    我想如果可能的话,我应该尽量不使用字符串操作/正则表达式。

    1 回复  |  直到 8 年前
        1
  •  2
  •   Jeen Broekstra    8 年前

    这个 Literals util class

    int scount = Literals.getIntValue(ResBindSet.getValue("scount"))
    

    或者,如果您喜欢字符串:

    String scount =  Literals.getLabel(ResBindSet.getValue("scount"))