use of org.apache.jena.graph.impl.LiteralLabel in project jena by apache.
the class NodeFactoryExtra method nodeToFloat.
/**
* Node to float
*
* @param node
* @return The float value or Float.NaN
*/
public static float nodeToFloat(Node node) {
LiteralLabel lit = node.getLiteral();
if (!XSDDatatype.XSDfloat.isValidLiteral(lit))
return Float.NaN;
float f = ((Number) lit.getValue()).floatValue();
return f;
}
use of org.apache.jena.graph.impl.LiteralLabel in project jena by apache.
the class NodeFactoryExtra method nodeToLong.
/**
* Node to long
*
* @param node
* @return The long value or Long.MIN_VALUE.
*/
public static long nodeToLong(Node node) {
LiteralLabel lit = node.getLiteral();
if (!XSDDatatype.XSDlong.isValidLiteral(lit))
return Long.MIN_VALUE;
long i = ((Number) lit.getValue()).longValue();
return i;
}
use of org.apache.jena.graph.impl.LiteralLabel in project jena by apache.
the class TestLiteralLabels method testHashCodesForHexBinary_2.
public void testHashCodesForHexBinary_2() {
LiteralLabel A = node("'illegal'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral();
LiteralLabel B = node("'illegal'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral();
assertEquals(A.hashCode(), B.hashCode());
}
use of org.apache.jena.graph.impl.LiteralLabel in project jena by apache.
the class TestLiteralLabels method testEquality3.
public void testEquality3() {
LiteralLabel A = LiteralLabelFactory.create("xyz", "en-us");
LiteralLabel B = LiteralLabelFactory.create("xyz", "en-uk");
assertFalse(A.equals(B));
assertFalse(A.sameValueAs(B));
}
use of org.apache.jena.graph.impl.LiteralLabel in project jena by apache.
the class TestLiteralLabels method testEquality1.
public void testEquality1() {
LiteralLabel A = LiteralLabelFactory.createTypedLiteral("xyz");
LiteralLabel B = LiteralLabelFactory.createTypedLiteral("xyz");
assertTrue(A.equals(B));
assertTrue(A.sameValueAs(B));
assertEquals(A.hashCode(), B.hashCode());
}
Aggregations