本文整理汇总了Java中com.hp.hpl.jena.rdf.model.Literal.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Literal.getValue方法的具体用法?Java Literal.getValue怎么用?Java Literal.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.Literal
的用法示例。
在下文中一共展示了Literal.getValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLiteralType
import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private Resource getLiteralType(Node lit_obj){
RDFNode n = Commons.asRDFNode(lit_obj);
Literal lt = (Literal) n;
if (((Literal)n).getDatatype() != null){
return ModelFactory.createDefaultModel().createResource(lt.getDatatype().getURI());
} else {
if (lt.getValue() instanceof Byte) return XSD.xbyte;
else if (lt.getValue() instanceof Boolean) return XSD.xboolean;
else if (lt.getValue() instanceof Short) return XSD.xshort;
else if (lt.getValue() instanceof Integer) return XSD.xint;
else if (lt.getValue() instanceof Long) return XSD.xlong;
else if (lt.getValue() instanceof Float) return XSD.xfloat;
else if (lt.getValue() instanceof Double) return XSD.xdouble;
else if (lt.getValue() instanceof String) return XSD.xstring;
else return RDFS.Literal;
}
}
示例2: getLiteralType
import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private Resource getLiteralType(Node lit_obj){
RDFNode n = Commons.asRDFNode(lit_obj);
if (((Literal)n).getDatatype() != null){
return ModelFactory.createDefaultModel().createResource(lit_obj.getLiteralDatatype().getURI());
} else {
Literal lt = (Literal) n;
if (lt.getValue() instanceof Double) return XSD.xdouble;
else if (lt.getValue() instanceof Integer) return XSD.xint;
else if (lt.getValue() instanceof Boolean) return XSD.xboolean;
else if (lt.getValue() instanceof String) return XSD.xstring;
else if (lt.getValue() instanceof Float) return XSD.xfloat;
else if (lt.getValue() instanceof Short) return XSD.xshort;
else if (lt.getValue() instanceof Long) return XSD.xlong;
else if (lt.getValue() instanceof Byte) return XSD.xbyte;
else return RDFS.Literal;
}
}
示例3: compareObjects
import com.hp.hpl.jena.rdf.model.Literal; //导入方法依赖的package包/类
private boolean compareObjects(Object lval, Object objVal,
OntResource rngrsrc) {
if ((lval instanceof KnownNode && objVal != null)
|| (objVal instanceof KnownNode && lval != null)) {
return true;
}
if (lval instanceof String && objVal instanceof String
&& lval.equals(objVal)) {
return true;
} else if (lval instanceof Boolean && objVal instanceof Boolean) {
if (lval.equals(objVal)) {
return true;
} else {
return false;
}
} else if (lval instanceof Number && objVal instanceof Number) {
if (lval.equals(objVal)) {
return true;
} else {
double d1 = ((Number) lval).doubleValue();
double d2 = ((Number) objVal).doubleValue();
// double diff = d1 - d2;
// if (Math.abs((double)diff / Math.max(Math.max(d1, d2),
// .0000001)) < .0000001) {
return ResultSet.areDoublesEqual(d1, d2); // true;
// }
}
} else if (lval != null && objVal != null && lval.equals(objVal)) {
return true;
} else if (rngrsrc != null) {
// we know the range so let's try to convert each value to the
// desired value type and compare
Literal v1 = getJenaModel().createTypedLiteral(lval,
rngrsrc.getURI());
Literal v2 = getJenaModel().createTypedLiteral(objVal,
rngrsrc.getURI());
if (v1 != null && v2 != null && v1.equals(v2)) {
return true;
}
if (rngrsrc.equals(XSD.date)
&& v1.getDatatypeURI().equals(XSD.date.getURI())
&& v2.getDatatypeURI().equals(XSD.date.getURI())) {
Object v1obj = v1.getValue();
Object v2obj = v2.getValue();
if (v1obj instanceof XSDDateTime
&& v2obj instanceof XSDDateTime
&& ((XSDDateTime) v1obj).getYears() == ((XSDDateTime) v2obj)
.getYears()
&& ((XSDDateTime) v1obj).getMonths() == ((XSDDateTime) v2obj)
.getMonths()
&& ((XSDDateTime) v1obj).getDays() == ((XSDDateTime) v2obj)
.getDays()) {
return true;
}
}
}
return false;
}