Search in sources :

Example 11 with LiteralLabel

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;
}
Also used : LiteralLabel(org.apache.jena.graph.impl.LiteralLabel)

Example 12 with LiteralLabel

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;
}
Also used : LiteralLabel(org.apache.jena.graph.impl.LiteralLabel)

Example 13 with LiteralLabel

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());
}
Also used : LiteralLabel(org.apache.jena.graph.impl.LiteralLabel)

Example 14 with LiteralLabel

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));
}
Also used : LiteralLabel(org.apache.jena.graph.impl.LiteralLabel)

Example 15 with LiteralLabel

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());
}
Also used : LiteralLabel(org.apache.jena.graph.impl.LiteralLabel)

Aggregations

LiteralLabel (org.apache.jena.graph.impl.LiteralLabel)43 Node (org.apache.jena.graph.Node)8 RDFDatatype (org.apache.jena.datatypes.RDFDatatype)7 DatatypeFormatException (org.apache.jena.datatypes.DatatypeFormatException)5 NodeFactory.createLiteral (org.apache.jena.graph.NodeFactory.createLiteral)5 Test (org.junit.Test)5 RDFLangString (org.apache.jena.datatypes.xsd.impl.RDFLangString)4 BigDecimal (java.math.BigDecimal)3 BaseDatatype (org.apache.jena.datatypes.BaseDatatype)3 SpatialIndexException (org.apache.jena.query.spatial.SpatialIndexException)3 Var (org.apache.jena.sparql.core.Var)3 UUID (java.util.UUID)2 FrontsNode (org.apache.jena.graph.FrontsNode)2 Triple (org.apache.jena.graph.Triple)2 PrefixMapping (org.apache.jena.shared.PrefixMapping)2 ExprVar (org.apache.jena.sparql.expr.ExprVar)2 FileReader (java.io.FileReader)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 Duration (javax.xml.datatype.Duration)1