Examples of BindingMap


Examples of com.hp.hpl.jena.sparql.engine.binding.BindingMap

    }
   
    @Override
    protected Binding assembleBinding(ResultSetJDBC rsHolder, Binding parent)
    {
        BindingMap b = BindingFactory.create(parent) ;
        ResultSet rs = rsHolder.get() ;
        for ( Var v : super.getProject() )
        {
            if ( ! v.isNamedVar() )
                // Skip bNodes and system variables
                continue ;

            String codename = super.getSqlName(v) ;
            if ( codename == null )
                // Not mentioned in query.
                continue ;
            try {
                int type        = rs.getInt(SQLUtils.gen(codename,"type")) ;
                // returns 0 on null : type 0 is not allocated
                // Test with "wasNull()" for safety
                if ( rs.wasNull() )
                    continue ;

                String lexColName = SQLUtils.gen(codename,"lex") ;
                // Get lexical - overriden by Oracle-specific code.
                String lex = getLexFromResultSet(rs, codename);
//                String lex = rs.getString(lexColName) ;
                if ( lex == null )
                    lex = "" ;
                String datatype = rs.getString(SQLUtils.gen(codename,"datatype")) ;
                String lang     = rs.getString(SQLUtils.gen(codename,"lang")) ;
                ValueType vType = ValueType.lookup(type) ;
                Node r          = makeNode(lex, datatype, lang, vType) ;
                b.add(v, r) ;
            } catch (SQLException ex)
            { // Unknown variable?
                //log.warn("Not reconstructed: "+n) ;
            }
        }
View Full Code Here

Examples of com.hp.hpl.jena.sparql.engine.binding.BindingMap

        if ( true )
            return new BindingTDB(bindingNodeIds, nodeTable) ;
        else
        {
            // Makes nodes immediately.  Causing unnecessary NodeTable accesses (e.g. project)
            BindingMap b = BindingFactory.create() ;
            for ( Var v : bindingNodeIds )
            {
                NodeId id = bindingNodeIds.get(v) ;
                Node n = nodeTable.getNodeForNodeId(id) ;
                b.add(v, n) ;
            }
            return b ;
        }
    }
View Full Code Here

Examples of com.hp.hpl.jena.sparql.engine.binding.BindingMap

    }

    private Binding buildBinding(Resource soln)
    {
        // foreach row
        BindingMap rb = BindingFactory.create() ;
       
        StmtIterator bindingIter = soln.listProperties(ResultSetGraphVocab.binding) ;
        for ( ; bindingIter.hasNext() ; )
        {
            Resource binding = bindingIter.nextStatement().getResource() ;
           
            String var = binding.getRequiredProperty(ResultSetGraphVocab.variable).getString() ;
            try {
                RDFNode val = binding.getRequiredProperty(ResultSetGraphVocab.value).getObject() ;
                rb.add(Var.alloc(var), val.asNode()) ;
            } catch (PropertyNotFoundException ex)
            {
                Log.warn(this, "Failed to get value for ?"+var) ;
            }
           
View Full Code Here

Examples of com.hp.hpl.jena.sparql.engine.binding.BindingMap

    { return ; }
   
    private Binding getOneSolution() throws XMLStreamException
    {
        // At the start of <result>
        BindingMap binding = BindingFactory.create() ;
        String varName = null ;
       
        while(parser.hasNext())
        {
            int event = parser.next();
View Full Code Here

Examples of com.hp.hpl.jena.sparql.engine.binding.BindingMap

  }
     
     
    private BindingMap parseLine(List<Var> vars, String line)
    {
        BindingMap binding = BindingFactory.create() ;
        List<String> terms = new ArrayList<String>() ;
        int idx = 0 ;
       
        while(idx < line.length())
        {
            char ch = line.charAt(idx) ;
           
            StringBuilder s = new StringBuilder() ;
            if ( ch == '\"' || ch == '\'' )
            {
                char qCh = ch ;
                idx++ ;
                while(idx < line.length() )
                {
                    ch = line.charAt(idx) ;
                    idx++ ;
                    if ( ch == qCh )
                        break ;
                    // escapes??
                    s.append(ch) ;
                }
                if ( ch != qCh )
                    throw new QueryException(String.format("Error Parsing CSV results at Line %d  - Unterminated quoted string", this.lineNum));
                if ( idx < line.length() )
                {
                    ch = line.charAt(idx) ;
                    if ( ch != ',' )
                        throw new QueryException(String.format("Error Parsing CSV results at Line %d - Expected comma after quote", this.lineNum)) ;
                }
            }
            else
            {
                while(idx < line.length() )
                {
                    ch = line.charAt(idx) ;
                    if ( ch == ',' )
                        break ;
                    idx++ ;
                    // escapes
                    s.append(ch) ;
                }
            }
           
            terms.add(s.toString()) ;
            // At end of per-term processing, we are looking at "," or EOL. 

            // Looking at , or EOL.
            if ( ch == ',' && idx==line.length()-1 )
            {
                //EOL
                terms.add("") ;
                break ;
            }
            // Skip ","
            idx++ ;
        }
       
        if ( terms.size() != vars.size() )
            throw new QueryException(String.format("Error Parsing CSV results at Line %d - The result row '%s' has %d items when %d was expected", this.lineNum, line, terms.size(), vars.size())) ;
        for ( int i = 0 ; i < vars.size() ; i++ )
            binding.add(vars.get(i), NodeFactory.createLiteral(terms.get(i))) ;
        return binding ;
    }
View Full Code Here

Examples of com.hp.hpl.jena.sparql.engine.binding.BindingMap

        JsonArray array = results.get(kBindings).getAsArray() ;
        Iterator<JsonValue> iter = array.iterator() ;
       
        for ( ; iter.hasNext() ; )
        {
            BindingMap b = BindingFactory.create() ;
            JsonValue v = iter.next() ;
            if ( ! v.isObject() )
                throw new ResultSetException("Entry in 'bindings' array must be an object {}";
            JsonObject x = v.getAsObject() ;
            Set<String> varNames = x.keys() ;
            for ( String vn : varNames )
            {
                if ( ! vars.contains(vn) )
                    ; // Warning
                JsonValue vt = x.get(vn) ;
                if ( ! vt.isObject() )
                    throw new ResultSetException("Binding for variable '"+vn+"' is not a JSON object: "+vt;
                Node n = parseOneTerm(vt.getAsObject()) ;
                b.add(Var.alloc(vn), n) ;
            }
            rows.add(b) ;
        }
    }
View Full Code Here

Examples of com.hp.hpl.jena.sparql.engine.binding.BindingMap

 
  private boolean parseNextBinding() {
    if (lookingAt(TokenType.LBRACE))
    {
      nextToken();
      BindingMap b = BindingFactory.create();
      do
      {
        if (isPropertyName())
        {
          Token t = nextToken();
          String var = t.getImage();
          checkColon();
                   
          Node n = parseNode();
          b.add(Var.alloc(var), n);
         
          checkComma(TokenType.RBRACE);
        }
        else if (lookingAt(TokenType.RBRACE))
        {
View Full Code Here

Examples of com.hp.hpl.jena.sparql.engine.binding.BindingMap

        if ( true )
            return new BindingTDB(bindingNodeIds, nodeTable) ;
        else
        {
            // Makes nodes immediately.  Causing unnecessary NodeTable accesses (e.g. project)
            BindingMap b = BindingFactory.create() ;
            for ( Var v : bindingNodeIds )
            {
                NodeId id = bindingNodeIds.get(v) ;
                Node n = nodeTable.getNodeForNodeId(id) ;
                b.add(v, n) ;
            }
            return b ;
        }
    }
View Full Code Here

Examples of com.hp.hpl.jena.sparql.engine.binding.BindingMap

        if ( ! node.isURI() ) return ;
        Node localname = NodeFactory.createLiteral(node.getLocalName()) ;
        if ( nodeLocalname.isVariable() )
        {
            // Object is an unbound variable.
            BindingMap b = BindingFactory.create(input) ;
            // Bind a pair for subject and object variables
            b.add(Var.alloc(subjVar), node) ;
            b.add(Var.alloc(nodeLocalname), localname) ;
            bindings.add(b) ;
            return ;
        }
       
        // Object is a value / bound variable.
View Full Code Here

Examples of com.hp.hpl.jena.sparql.engine.binding.BindingMap

    { return ; }
   
    private Binding getOneSolution() throws XMLStreamException
    {
        // At the start of <result>
        BindingMap binding = BindingFactory.create() ;
        String varName = null ;
       
        while(parser.hasNext())
        {
            int event = parser.next();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.