Android Open Source - ormada Full Result Set Cursor






From Project

Back to project page ormada.

License

The source code is released under:

Copyright (c) 2012 Jesse Rosalia Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Sof...

If you think the Android project ormada 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 org.ormada.dialect;
/*  w w  w . j  ava  2s . c  o m*/
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;

/**
 * A generic QueryCursor implementation for JDBC ResultSet objects.
 * 
 * NOTE: several of the cursor position methods will return to indicate no data on exception.  While
 * this may lose a bit of information, it is because in these cases, the caller is just looking for
 * an answer about whether there is data/more data.
 * 
 * @author Jesse Rosalia
 *
 */
public class FullResultSetCursor implements QueryCursor {

    private ResultSet         resultSet;
    private ResultSetMetaData rsMetaData;

    public FullResultSetCursor(ResultSet resultSet) throws SQLException {
        this.resultSet  = resultSet;
        this.rsMetaData = resultSet.getMetaData();
    }

    @Override
  public void close() {
        try {
            this.resultSet.close();
        } catch (SQLException e) {
            //we're closing...nothing to do
        }
  }

  @Override
  public boolean isEmpty() {
      return !moveToFirst();
  }

  @Override
  public boolean moveToFirst() {
        try {
            return this.resultSet.first();
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
  }

  @Override
  public boolean isAfterLast() {
        try {
            return this.resultSet.isAfterLast();
        } catch (SQLException e) {
            e.printStackTrace();
            return true;
        }
  }

  @Override
  public boolean moveToNext() {
        try {
            return this.resultSet.next();
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
  }

  @Override
  public int getColumnCount() throws SQLException {
      return this.rsMetaData.getColumnCount();
  }

  @Override
  public String getColumnName(int col) throws SQLException {
      return this.rsMetaData.getColumnLabel(col);
  }

  @Override
  public long getLong(int col) throws SQLException {
    return this.resultSet.getLong(col);
  }

  @Override
  public int getInt(int col) throws SQLException {
    return this.resultSet.getInt(col);
  }

  @Override
  public short getShort(int col) throws SQLException {
    return this.resultSet.getShort(col);
  }

  @Override
  public float getFloat(int col) throws SQLException {
    return this.resultSet.getFloat(col);
  }

  @Override
  public double getDouble(int col) throws SQLException {
    return this.resultSet.getDouble(col);
  }

  @Override
  public byte[] getBlob(int col) throws SQLException {
    return this.resultSet.getBytes(col);
  }

  @Override
  public String getString(int col) throws SQLException {
    return this.resultSet.getString(col);
  }
}




Java Source Code List

org.andrormeda.dialect.SQLiteCursor.java
org.andrormeda.dialect.SQLiteDialect.java
org.andrormeda.dialect.SQLiteValueSet.java
org.andrormeda.example.AppDataSource.java
org.andrormeda.example.ExampleActivity.java
org.andrormeda.example.model.Cat.java
org.andrormeda.example.model.Kitten.java
org.ormada.ORMDataSource.java
org.ormada.annotations.OneToMany.java
org.ormada.annotations.Owner.java
org.ormada.annotations.Reference.java
org.ormada.annotations.Text.java
org.ormada.annotations.Transient.java
org.ormada.dialect.AStandardSQLDialect.java
org.ormada.dialect.DefaultValueSet.java
org.ormada.dialect.Dialect.java
org.ormada.dialect.ForwardOnlyResultSetCursor.java
org.ormada.dialect.FullResultSetCursor.java
org.ormada.dialect.QueryCursor.java
org.ormada.dialect.ValueSet.java
org.ormada.entity.EntityBuilder.java
org.ormada.entity.EntityCache.java
org.ormada.entity.EntityMetaData.java
org.ormada.entity.Entity.java
org.ormada.exception.MixedCollectionException.java
org.ormada.exception.UnableToOpenException.java
org.ormada.exception.UnsavedReferenceException.java
org.ormada.hsql.dialect.HSQLDialect.java
org.ormada.hsql.example.AppDataSource.java
org.ormada.hsql.example.ExampleMain.java
org.ormada.hsql.example.model.Cat.java
org.ormada.hsql.example.model.Kitten.java
org.ormada.model.ORMeta.java
org.ormada.reflect.DefaultReflector.java
org.ormada.reflect.Reflector.java
org.ormada.util.Profiler.java