Package com.hp.hpl.jena.datatypes

Examples of com.hp.hpl.jena.datatypes.RDFDatatype


                sink.consume( item );
                }
           
            private Node encodeSetAsLiteral( Set<Node> elements )
                {
                RDFDatatype dt = new FakeSetLiteralType();              
                LiteralLabel ll = new LiteralLabel( elements, "", dt );
                return Node.createLiteral( ll );
                }

            @Override public void consume( Node[] item )
View Full Code Here


    /**
     * Tests the base functioning of a user defined datatype
     */
    public void testUserDef() {
        // Register the user defined type for rationals
        RDFDatatype rtype = RationalType.theRationalType;
        TypeMapper.getInstance().registerDatatype(rtype);


        Literal l1 = m.createTypedLiteral("3/5", rtype);
        Literal l3 = m.createTypedLiteral("7/5", rtype);
View Full Code Here

    /**
     * Test case for a bug in retrieving a value like 3.00 from
     * a probe like 3.0
     */
    public void testDecimalFind() {
        RDFDatatype dt = XSDDatatype.XSDdecimal;
        Node ns = NodeFactory.createURI("x") ;
        Node np = NodeFactory.createURI("p") ;
        Node nx1 = NodeFactory.createLiteral("0.50", null, dt) ;
        Node nx2 = NodeFactory.createLiteral("0.500", null, dt) ;
        Graph graph = Factory.createDefaultGraph() ;
View Full Code Here

     */
    public void testDateTimeBug() {
        // Bug in serialization
        String XSDDateURI = XSD.date.getURI();
        TypeMapper typeMapper=TypeMapper.getInstance();
        RDFDatatype dt = typeMapper.getSafeTypeByName(XSDDateURI);
        Object obj = dt.parse("2003-05-21");
        Literal literal = m.createTypedLiteral(obj, dt);       
        literal.toString();    
        Object value2 = dt.parse(obj.toString());
        assertEquals(obj, value2);
       
        // Check alternative form doesn't provoke exceptions
        RDFDatatype dateType = XSDDatatype.XSDdate;
        m.createTypedLiteral("2003-05-21", dateType);
       
        // Check alt time times
        checkSerialization("2003-05-21", XSDDatatype.XSDdate);
        checkSerialization("2003-05-21T12:56:10Z", XSDDatatype.XSDdateTime);
View Full Code Here

                        String langTag = parser.getAttributeValue(XML_NS, "lang") ;
                       
                        // Works for XML literals (returning them as a string)
                        String text = parser.getElementText() ;
                       
                        RDFDatatype dType = null ;
                        if ( datatype != null )
                            dType = TypeMapper.getInstance().getSafeTypeByName(datatype);
                       
                        Node n = NodeFactory.createLiteral(text,  langTag, dType) ;
                        if ( varName == null )
View Full Code Here

        }
       
    public void testDataMatches()
        {
        TypeMapper tm = TypeMapper.getInstance();
        RDFDatatype dt1 = tm.getTypeByValue( new Integer( 10 ) );
        RDFDatatype dt2 = tm.getTypeByValue( new Short( (short) 10 ) );
        Node a = NodeFactory.createLiteral( "10", "", dt1 );
        Node b = NodeFactory.createLiteral( "10", "", dt2 );
        assertDiffer( "types must make a difference", a, b );
        assertTrue( "A and B must express the same value", a.sameValueAs( b ) );
        assertTrue( "matching literals must respect sameValueAs", a.matches( b ) );
View Full Code Here

        }
       
    public void testLiteralToString()
        {
        TypeMapper tm = TypeMapper.getInstance();
        RDFDatatype dtInt = tm.getTypeByValue( new Integer( 10 ) );
        Node plain = NodeFactory.createLiteral( "rhubarb", "", false );   
        Node english = NodeFactory.createLiteral( "eccentric", "en_UK", false );
        Node typed = NodeFactory.createLiteral( "10", "", dtInt );
        assertEquals( "\"rhubarb\"", plain.toString() );
        assertEquals( "rhubarb", plain.toString( false ) );
View Full Code Here

        {
            String lang = stringOrNull(term, kXmlLang) ;
            String dtStr = stringOrNull(term, kDatatype) ;
            if ( lang != null && dtStr != null )
                throw new ResultSetException("Both language and datatype defined: "+term) ;
            RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName(dtStr) ;
            return NodeFactory.createLiteral(v, lang, dt;
        }
       
        if ( kBnode.equals(type) )
            return labelMap.get(null, v) ;
View Full Code Here

    {
        Node n = null ;
        // Can't have type and lang tag.
        if ( datatypeURI != null)
        {
            RDFDatatype dType = TypeMapper.getInstance().getSafeTypeByName(datatypeURI) ;
            n = NodeFactory.createLiteral(lexicalForm, null, dType) ;
        }
        else
            n = NodeFactory.createLiteral(lexicalForm, langTag, null) ;
        return n ;
View Full Code Here

                    // Must be able to resolve the datattype else we can't find it's datatype.
                    throw new RiotException("Invalid token: "+this) ;
                Node n = dtToken.asNode(pmap);
                if ( ! n.isURI() )
                    throw new RiotException("Invalid token: "+this) ;
                RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName(n.getURI()) ;
                return NodeFactory.createLiteral(lexToken.getImage(), null, dt;
            }
            case LITERAL_LANG : return NodeFactory.createLiteral(tokenImage, tokenImage2, null;
            case STRING:
            case STRING1:
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.datatypes.RDFDatatype

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.