@ Override public RepositoryResult < Statement > getStatements ( Resource subj , URI pred , Value obj , boolean includeInferred , Resource ... contexts ) throws RepositoryException { if ( contexts == null ) { contexts = new Resource [ ] { null } ; } try { if ( isQuadMode ( ) ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "SELECT * WHERE { GRAPH ?ctx { ?s ?p ?o } filter (?ctx = (" ) ; boolean first = true ; for ( Resource context : contexts ) { if ( first ) { first = ! first ; } else { sb . append ( "," ) ; } if ( notNull ( context ) ) { sb . append ( "IRI(\"" + context . toString ( ) + "\")" ) ; } else { sb . append ( "IRI(\"" + DEFAULT_GRAPH_URI + "\")" ) ; } } sb . append ( ") ) }" ) ; TupleQuery tupleQuery = prepareTupleQuery ( sb . toString ( ) ) ; tupleQuery . setIncludeInferred ( includeInferred ) ; setBindings ( tupleQuery , subj , pred , obj , ( Resource ) null ) ; TupleQueryResult qRes = tupleQuery . evaluate ( ) ; return new RepositoryResult < Statement > ( new ExceptionConvertingIteration < Statement , RepositoryException > ( toStatementIteration ( qRes , subj , pred , obj ) ) { @ Override protected RepositoryException convert ( Exception e ) { return new RepositoryException ( e ) ; } } ) ; } else if ( subj != null && pred != null && obj != null ) { if ( hasStatement ( subj , pred , obj , includeInferred , contexts ) ) { Statement st = new StatementImpl ( subj , pred , obj ) ; CloseableIteration < Statement , RepositoryException > cursor ; cursor = new SingletonIteration < Statement , RepositoryException > ( st ) ; return new RepositoryResult < Statement > ( cursor ) ; } else { return new RepositoryResult < Statement > ( new EmptyIteration < Statement , RepositoryException > ( ) ) ; } } else { MarkLogicGraphQuery query = prepareGraphQuery ( EVERYTHING ) ; setBindings ( query , subj , pred , obj , contexts ) ; GraphQueryResult result = query . evaluate ( ) ; return new RepositoryResult < Statement > ( new ExceptionConvertingIteration < Statement , RepositoryException > ( result ) { @ Override protected RepositoryException convert ( Exception e ) { return new RepositoryException ( e ) ; } } ) ; } } catch ( MalformedQueryException e ) { throw new RepositoryException ( e ) ; } catch ( QueryEvaluationException e ) { throw new RepositoryException ( e ) ; } }
returns statements from supplied context