Package com.hp.hpl.jena.sparql.expr

Examples of com.hp.hpl.jena.sparql.expr.NodeValue


        String sep = iter.next().asString() ;

        List<String> x = new ArrayList<String>() ;
        for ( ; iter.hasNext() ; )
        {
            NodeValue arg = iter.next();
            x.add( arg.asString() ) ;
        }
       
        return NodeValue.makeString(StrUtils.strjoin(sep, x)) ;
    }
View Full Code Here


            if ( ! first )
                s.append(sep) ;
            // Values are printed withquoting.
            if ( ex instanceof NodeValue )
            {
                NodeValue nv =(NodeValue)ex ;
                s.append(nv.asQuotedString()) ;
            }
            else
                s.append(ex.toString()) ;
            first = false ;
        }
View Full Code Here

    }

    public static NodeValue parseNodeValue(String s)
    {
        Node n = NodeFactoryExtra.parseNode(s) ;
        NodeValue nv = NodeValue.makeNode(n) ;
        return nv ;
    }
View Full Code Here

    }

    public static void evalPrint(Expr expr, Binding binding)
    {
        try {
            NodeValue r = eval(expr, binding) ;
            //System.out.println(r.asQuotedString()) ;
            Node n = r.asNode() ;
            String s = FmtUtils.stringForNode(n) ;
            System.out.println(s) ;
        } catch (ExprEvalException ex)
        {
            System.out.println("Exception: "+ex.getMessage()) ;
View Full Code Here

    public static NodeValue eval(Expr expr, Binding binding)
    {
        Context context = ARQ.getContext().copy() ;
        context.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()) ;
        FunctionEnv env = new ExecutionContext(context, null, null, null) ;
        NodeValue r = expr.eval(binding, env) ;
        return r ;
    }
View Full Code Here

        DatasetGraph dsg = TDBFactory.createDatasetGraph(loc) ;
       
        if ( root.hasProperty(pUnionDefaultGraph) )
        {
            Node b = root.getProperty(pUnionDefaultGraph).getObject().asNode() ;
            NodeValue nv = NodeValue.makeNode(b) ;
            if ( nv.isBoolean() )
                dsg.getContext().set(TDB.symUnionDefaultGraph, nv.getBoolean()) ;
            else
                Log.warn(DatasetAssemblerTDB.class,
                         "Failed to recognize value for union graph setting (ignored): "+b) ;
        }
       
View Full Code Here

                    else
                    {
                        // Default action
                        ARQ.getContext().set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()) ;
                        FunctionEnv env = new ExecutionContext(ARQ.getContext(), null, null, null) ;
                        NodeValue r = expr.eval(null, env) ;
                        //System.out.println(r.asQuotedString()) ;
                        Node n = r.asNode() ;
                        String s = FmtUtils.stringForNode(n) ;
                        System.out.println(s) ;
                    }
                } catch (ExprEvalException ex)
                {
View Full Code Here

        // Loose style. Add any duration to any date or time value.
        if ( vs1.equals(VSPACE_DATETIME) && vs2.equals(VSPACE_DURATION) )
        {
            XMLGregorianCalendar cal = nv1.getDateTime() ;
            XMLGregorianCalendar result = xsd_add(cal, nv2.getDuration()) ;
            NodeValue r = NodeValue.makeDateTime(result) ;
            return r ;
        }
        // Loose style. Add any duration to any date or time value.
        if ( vs1.equals(VSPACE_DATE) && vs2.equals(VSPACE_DURATION) )
        {
            XMLGregorianCalendar cal = nv1.getDateTime() ;
            XMLGregorianCalendar result = xsd_add(cal, nv2.getDuration()) ;
            NodeValue r = NodeValue.makeDate(result) ;
            return r ;
        }
        // Loose style. Add any duration to any date or time value.
        if ( vs1.equals(VSPACE_TIME) && vs2.equals(VSPACE_DURATION) )
        {
            // ONLY dayTime.
            XMLGregorianCalendar cal = nv1.getDateTime() ;
            XMLGregorianCalendar result = xsd_add(cal, nv2.getDuration()) ;
            NodeValue r = NodeValue.makeNode(result.toXMLFormat(), XSDDatatype.XSDtime) ;
            return r ;
        }
       
        if ( isDT(vs2) && vs1.equals(VSPACE_DURATION) )
            // Carefully ...
View Full Code Here

        if ( vs1.equals(VSPACE_DATETIME) && vs2.equals(VSPACE_DURATION) )
        {
            XMLGregorianCalendar cal = nv1.getDateTime() ;
            // add-negation
            XMLGregorianCalendar result = xsd_subtract(cal, nv2.getDuration()) ;
            NodeValue r = NodeValue.makeDateTime(result) ;
            return r ;
        }
        if ( vs1.equals(VSPACE_DATE) && vs2.equals(VSPACE_DURATION) )
        {
            XMLGregorianCalendar cal = nv1.getDateTime() ;
            // add-negation
            XMLGregorianCalendar result = xsd_subtract(cal, nv2.getDuration()) ;
            NodeValue r = NodeValue.makeDate(result) ;
            return r ;
        }
        if ( vs1.equals(VSPACE_TIME) && vs2.equals(VSPACE_DURATION) )
        {
            XMLGregorianCalendar cal = nv1.getDateTime() ;
            // add-negation
            XMLGregorianCalendar result = xsd_subtract(cal, nv2.getDuration()) ;
            NodeValue r = NodeValue.makeNode(result.toXMLFormat(), XSDDatatype.XSDtime) ;
            return r ;
        }
       
        throw new ExprEvalTypeException("Operator '-' : Undefined subtraction: "+nv1+" and "+nv2) ;
    }
View Full Code Here

    private static PrefixMapping pmap = ARQConstants.getGlobalPrefixMap() ;
   
    private static void test(String string, String result)
    {
        Expr expr = ExprUtils.parse(string, pmap) ;
        NodeValue nv = expr.eval(null, new FunctionEnvBase()) ;
        Node r = NodeFactoryExtra.parseNode(result) ;
        NodeValue nvr = NodeValue.makeNode(r) ;
       
        assertTrue("Not same value: Expected: "+nvr+" : Actual = "+nv, NodeValue.sameAs(nvr, nv))
        // test result must be lexical form exact.
        assertEquals(r, nv.asNode()) ;
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.expr.NodeValue

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.