private void setBindings(Query query, Resource subj, URI pred, Value obj, Resource... contexts)
            throws RepositoryException {
        if (subj != null) {
            query.setBinding("s", subj);
        }
        if (pred != null && pred instanceof URI) {
            query.setBinding("p", pred);
        }
        if (obj != null) {
            query.setBinding("o", obj);
        }
        if (contexts != null && contexts.length > 0) {
            DatasetImpl dataset = new DatasetImpl();
            if(notNull(contexts)){
            for (int i = 0; i < contexts.length; i++) {
                if (notNull(contexts[i]) || contexts[i] instanceof URI) {
                    dataset.addDefaultGraph((URI) contexts[i]);
                } else {
                    dataset.addDefaultGraph(getValueFactory().createURI(DEFAULT_GRAPH_URI));
                }
            }
            }else{
                dataset.addDefaultGraph(getValueFactory().createURI(DEFAULT_GRAPH_URI));
            }
            query.setDataset(dataset);
        }
    }
private void setBindings ( Query query , Resource subj , URI pred , Value obj , Resource ... contexts ) throws RepositoryException { if ( subj != null ) { query . setBinding ( "s" , subj ) ; } if ( pred != null && pred instanceof URI ) { query . setBinding ( "p" , pred ) ; } if ( obj != null ) { query . setBinding ( "o" , obj ) ; } if ( contexts != null && contexts . length > 0 ) { DatasetImpl dataset = new DatasetImpl ( ) ; if ( notNull ( contexts ) ) { for ( int i = 0 ; i < contexts . length ; i ++ ) { if ( notNull ( contexts [ i ] ) || contexts [ i ] instanceof URI ) { dataset . addDefaultGraph ( ( URI ) contexts [ i ] ) ; } else { dataset . addDefaultGraph ( getValueFactory ( ) . createURI ( DEFAULT_GRAPH_URI ) ) ; } } } else { dataset . addDefaultGraph ( getValueFactory ( ) . createURI ( DEFAULT_GRAPH_URI ) ) ; } query . setDataset ( dataset ) ; } }
set bindings ?s, ?p and special handling of Value ?o (and ?ctx)

@param query
@param subj
@param pred
@param obj
@param contexts
@throws RepositoryException