Android Open Source - sqldb Sequential Cursor Processor






From Project

Back to project page sqldb.

License

The source code is released under:

MIT License

If you think the Android project sqldb listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package prj.sqldb;
/*ww  w  . ja  va2 s  .c o  m*/
import android.database.Cursor;

import java.util.Iterator;
import java.util.List;

public class SequentialCursorProcessor implements Iterator<QueryResult>
{
    private final Iterator<QueryParams> _queryParams;
    private final SqlDb.IQueryProcessor _queryProcessor;
    private Cursor _currentCursor;

    public SequentialCursorProcessor(SqlDb.IQueryProcessor processor,
                                     List<QueryParams> params)
    {
        _queryParams = params.iterator();
        _queryProcessor = processor;
    }

    @Override
    public boolean hasNext()
    {
        return _queryParams.hasNext();
    }

    @Override
    public QueryResult next()
    {
        closeCursor();
        QueryParams p = _queryParams.next();
        _currentCursor = _queryProcessor.process(p);
        return new QueryResult(p, _currentCursor);
    }

    @Override
    public void remove()
    {
        closeCursor();
        _queryParams.remove();
    }

    private void closeCursor()
    {
        if (_currentCursor != null && !_currentCursor.isClosed())
        {
            _currentCursor.close();
        }
    }
}




Java Source Code List

prj.sqldb.CursorHandler.java
prj.sqldb.DBCallback.java
prj.sqldb.MultipleCursorHandler.java
prj.sqldb.QueryParams.java
prj.sqldb.QueryResult.java
prj.sqldb.SequentialCursorProcessor.java
prj.sqldb.SqlDb.java
prj.sqldb.threading.ExceptionThrowingFutureTask.java
prj.sqldb.threading.Later.java
prj.sqldb.threading.SqlDBThreads.java