Package com.hp.hpl.jena.sparql.sse

Examples of com.hp.hpl.jena.sparql.sse.ItemList


{
    public static TransGraphNode build(Item item)
    {
        TransGraphNode tg = new TransGraphNode() ;
        checkList(item) ;
        ItemList list = item.getList() ;
        list = list.cdr() ;
       
        Iter<Item> xIter = Iter.iter(list.iterator()) ;
       
        for ( Item x : xIter)
        {
            checkList(item) ;
            ItemList pair = x.getList() ;
            checkLength(2, pair, "Not a pair: "+pair.shortString()) ;
            Item a = pair.get(0) ;
            Item b = pair.get(1) ;
            checkNode(a) ;
            checkNode(b) ;
            tg.add(a.getNode(), b.getNode()) ;
        }
        return tg ;
View Full Code Here


     */
   
    private static Item format(Map<Node, Integer> predicates, long count)
    {
        Item stats = Item.createList() ;
        ItemList statsList = stats.getList() ;
        statsList.add("stats") ;

//        System.out.printf("Triples  %d\n", count) ;
//        System.out.println("NodeIds") ;
//        for ( NodeId p : predicateIds.keySet() )
//            System.out.printf("%s : %d\n",p, predicateIds.get(p) ) ;

//        System.out.println("Nodes") ;
       
        Item meta = createTagged(StatsMatcher.META) ;
        addPair(meta.getList(), "timestamp", NodeFactory.nowAsDateTime()) ;
        addPair(meta.getList(), "run@",  Utils.nowAsString()) ;
        if ( count >= 0 )
            addPair(meta.getList(), StatsMatcher.COUNT, NodeFactory.intToNode((int)count)) ;
        statsList.add(meta) ;
       
        for ( Entry<Node, Integer> entry : predicates.entrySet() )
        {
            Node node = entry.getKey() ;
            // Skip these - they just clog things up!
View Full Code Here

{
      
    public static ResultSet build(Item item)
    {
        BuilderLib.checkTagged(item, Tags.tagResultSet, "Not a (resultset ...)") ;
        ItemList list = item.getList() ;
       
        List<Var> vars = BuilderNode.buildVarList(list.get(1)) ;
        // skip tag, skip vars.
        int start = 2 ;

        List<Binding> bindings = new ArrayList<Binding>() ;
        for ( int i = start ; i < list.size() ; i++ )
        {
            Item itemRow = list.get(i) ;
            Binding b = BuilderBinding.build(itemRow) ;
            bindings.add(b) ;
        }
       
        QueryIterator qIter = new QueryIterPlainWrapper(bindings.listIterator()) ;
View Full Code Here

    public static void build(PrefixMapping newMappings, Item elt)
    {
        if ( ! elt.isList() )
            BuilderLib.broken(elt, "Prefix mapping requires a list of pairs", elt) ;

        ItemList prefixes = elt.getList() ;
       
        // Strip (prefixmapping  ...)
        if ( elt.isTaggedIgnoreCase(Tags.tagPrefixMap) || elt.isTaggedIgnoreCase(Tags.tagPrefixMapping) )
        {
            BuilderLib.checkLength(2, elt.getList(), "Not of length 2"+elt.shortString()) ;
            // drop the tag
            prefixes = prefixes.cdr();
        }
       
        for (Item pair : prefixes)
        {
            if ( !pair.isList() || pair.getList().size() != 2 )
View Full Code Here

{
    public static Table build(Item item)
    {
        BuilderLib.checkTagged(item, Tags.tagTable, "Not a (table ...)") ;

        ItemList list = item.getList() ;
        int start = 1 ;
        if ( list.size() == 1 )
            // Null table;
            return TableFactory.createEmpty() ;

        // Maybe vars.
        List<Var> vars = null ;
        if ( list.size() > 1 )
        {
            Item item0 = list.get(1) ;
            if ( item0.isTagged(Tags.tagVars) )
            {
                vars = BuilderNode.buildVarList(item0) ;
                list = list.cdr() ;
            }
        }
       
        if ( list.size() == 2 && list.get(1).isSymbol() )
        {
            //  Short hand for well known tables
            String symbol = list.get(1).getSymbol() ;
            if ( symbol.equals("unit") )
                return TableFactory.createUnit() ;
            if ( symbol.equals("empty") )
                return TableFactory.createEmpty() ;
            BuilderLib.broken(list, "Don't recognized table symbol") ;
        }
       
        Table table = TableFactory.create(vars) ;
       
        int count = 0 ;
        Binding lastBinding = null ;
        for ( int i = start ; i < list.size() ; i++ )
        {
            Item itemRow = list.get(i) ;
            Binding b = BuilderBinding.build(itemRow) ;
            table.addBinding(b) ;
            lastBinding = b ;
            count++ ;
        }
View Full Code Here

    public static ExprList buildExprList(Item item)
    {
        if ( ! item.isTagged(Tags.tagExprList) )
            BuilderLib.broken(item, "Not tagged exprlist") ;
       
        ItemList list = item.getList() ;
        return buildExprListUntagged(list, 1) ;
    }
View Full Code Here

    public static VarExprList buildNamedExprOrExprList(Item item)
    {
        if ( ! item.isList() )
            BuilderLib.broken(item, "Not a var expr list") ;
       
        ItemList list = item.getList() ;
       
        if ( list.isEmpty() )
            return new VarExprList() ;
       
        if ( list.car().isList() )
            // List of lists
            return buildNamedExprList(list) ;
        // One item
        return buildNamedExpr(item) ;
    }
View Full Code Here

            return ;
        }
        if ( !item.isList() || item.getList().size() != 2 )
            BuilderLib.broken(item, "Not a var or var/expression pair") ;

        ItemList list = item.getList() ;

        if ( list.size() == 1 )
        {
            Var v = BuilderNode.buildVar(list.car()) ;
            varExprList.add(v) ;
            return ;
        }
       
        if ( list.size() != 2 )
            BuilderLib.broken(list, "Not a var or var/expression pair") ;
        Var var = BuilderNode.buildVar(list.get(0)) ;
        Expr expr = BuilderExpr.buildExpr(list.get(1)) ;
        varExprList.add(var, expr)
    }
View Full Code Here

        {
            Log.warn(this, "Attempt to use OpFetch - need to enable first with a call to OpFetch.enable()") ;
            return OpLabel.create("fetch/"+serviceNode, OpTable.unit()) ;
        }
        Item item = Item.createNode(elt.getFetchNode()) ;
        ItemList args = new ItemList() ;
        args.add(item) ;
        return builder.make(args) ;
    }
View Full Code Here

    {
        Expr expr = null ;
   
        if ( item.isList() )
        {
            ItemList list = item.getList() ;
           
            if ( list.size() == 0 )
                BuilderLib.broken(item, "Empty list for expression") ;
           
            Item head = list.get(0) ;
           
            if ( head.isNode() )
            {
                if ( head.getNode().isVariable() && list.size() == 1 )
                {
                    // The case of (?z)
                    return new ExprVar(Var.alloc(head.getNode())) ;
                }
                return buildFunctionCall(list) ;
            }
            else if ( head.isList() )
                BuilderLib.broken(item, "Head is a list") ;
            else if ( head.isSymbol() )
            {
                if ( item.isTagged(Tags.tagExpr) )
                {
                    BuilderLib.checkLength(2, list, "Wrong length: "+item.shortString()) ;
                    item = list.get(1) ;
                    return buildItem(item) ;
                }
               
                return buildKnownFunction(list) ;               
            }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.sse.ItemList

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.