本文整理匯總了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;
}