Package org.apache.clerezza.rdf.core

Examples of org.apache.clerezza.rdf.core.TypedLiteral


    SimpleLiteralFactory simpleLiteralFactory = new SimpleLiteralFactory();

    @Test
    public void longToXsdIntegerAndBackToMany() {
        long value = 14l;
        TypedLiteral tl = simpleLiteralFactory.createTypedLiteral(value);
        Assert.assertEquals(xsdLong, tl.getDataType());
        long longValue = simpleLiteralFactory.createObject(Long.class, tl);
        Assert.assertEquals(value, longValue);
        int intValue = simpleLiteralFactory.createObject(Integer.class, tl);
        Assert.assertEquals(value, intValue);
    }
View Full Code Here


    }

    @Test
    public void intToXsdIntAndBackToMany() {
        int value = 14;
        TypedLiteral tl = simpleLiteralFactory.createTypedLiteral(value);
        Assert.assertEquals(xsdInt, tl.getDataType());
        long longValue = simpleLiteralFactory.createObject(Long.class, tl);
        Assert.assertEquals(value, longValue);
        int intValue = simpleLiteralFactory.createObject(Integer.class, tl);
        Assert.assertEquals(value, intValue);
    }
View Full Code Here

   
   
    @Test public void typedLiteralEquality() {
        String stringValue = "some text";
        UriRef uriRef = new UriRef("http://example.org/datatypes/magic");
        TypedLiteral literal1 = new TypedLiteralImpl(stringValue, uriRef);
        TypedLiteral literal2 = new TypedLiteralImpl(stringValue, uriRef);       
        Assert.assertEquals(literal1, literal2);
        Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
        TypedLiteral literal3 = new TypedLiteralImpl("something else", uriRef);
        Assert.assertFalse(literal1.equals(literal3));
        UriRef uriRef2 = new UriRef("http://example.org/datatypes/other");
        TypedLiteral literal4 = new TypedLiteralImpl(stringValue, uriRef2);
        Assert.assertFalse(literal1.equals(literal4));
    }
View Full Code Here

     * The hascode is equals to the hascode of the lexical form plus the hashcode of the dataTyp
     */
    @Test public void checkHashCode() {
        String stringValue = "some text";
        UriRef uriRef = new UriRef("http://example.org/datatypes/magic");
        TypedLiteral literal =  new TypedLiteralImpl(stringValue, uriRef);
        Assert.assertEquals(stringValue.hashCode() + uriRef.hashCode(), literal.hashCode());
    }
View Full Code Here

                            jldValue.setLanguage(plain.getLanguage().toString());
                        }
                        strValue = plain.getLexicalForm();
                    }
                    else if (currentTriple.getObject() instanceof TypedLiteral) {
                        TypedLiteral typedObject = (TypedLiteral) currentTriple.getObject();
                        String type = typedObject.getDataType().getUnicodeString();
                        jldValue.setType(type);
                        strValue = typedObject.getLexicalForm();
                    }
                    else if (currentTriple.getObject() instanceof UriRef) {
                        UriRef uriRef = (UriRef) currentTriple.getObject();
                        jldValue.setType(JsonLdCommon.IRI);
                        strValue = uriRef.getUnicodeString();
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.TypedLiteral

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.