public JSONObject getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
private CursorIndexOutOfBoundsException cursorException() { return new CursorIndexOutOfBoundsException("Operation not permitted on an empty cursor."); } }
/** * Sets the next column value in this row. * * @throws CursorIndexOutOfBoundsException if you try to add too many * values * @return this builder to support chaining */ public RowBuilder add(Object columnValue) { if (index == endIndex) { throw new CursorIndexOutOfBoundsException( "No more columns left."); } data[index++] = columnValue; return this; }
/** * Sets the next column value in this row. * * @return this builder to support chaining * @throws CursorIndexOutOfBoundsException if you try to add too many values */ public RowBuilder add(Object columnValue) { if (index == endIndex) { throw new CursorIndexOutOfBoundsException( "No more columns left." ); } data[index++] = columnValue; return this; } }
/** * Gets value at the given column for the current row. */ private Object get(int column) { if (column < 0 || column >= columnCount) { throw new CursorIndexOutOfBoundsException("Requested column: " + column + ", # of columns: " + columnCount); } if (mPos < 0) { throw new CursorIndexOutOfBoundsException("Before first row."); } if (mPos >= rowCount) { throw new CursorIndexOutOfBoundsException("After last row."); } return data[mPos * columnCount + column]; }
private Object get(int column) { if (column < 0 || column >= columnNameArray.length) { throw new CursorIndexOutOfBoundsException(null); } if (currentRowNumber < 0) { throw new CursorIndexOutOfBoundsException("Before first row."); } if (currentRowNumber >= rowCount) { throw new CursorIndexOutOfBoundsException("After last row."); } return data.get(currentRowNumber)[column]; } }
/** * Gets value at the given column for the current row. */ public Object get(int column) { if (column < 0 || column >= columnCount) { throw new CursorIndexOutOfBoundsException( "Requested column: " + column + ", # of columns: " + columnCount ); } if (mPos < 0) { throw new CursorIndexOutOfBoundsException("Before first row."); } if (mPos >= rowCount) { throw new CursorIndexOutOfBoundsException("After last row."); } return data[mPos * columnCount + column]; }
@Override public T getGraphObject() { if (pos < 0) { throw new CursorIndexOutOfBoundsException("Before first object."); } if (pos >= graphObjects.size()) { throw new CursorIndexOutOfBoundsException("After last object."); } return graphObjects.get(pos); }
/*getSupervisor() will return he supervisor's object if id matches*/ public Supervisor getSupervisor(int supervisor_id) { SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.query(TABLE_SUPERVISOR, new String[]{KEY_ID, KEY_NAME, KEY_EMAIL, KEY_PHONE, KEY_LICENCE_NO, KEY_CREATE_DATE}, KEY_ID + "=?", new String[]{String.valueOf(supervisor_id)}, null, null, null, null); //if (cursor != null) <--Replace this. The query() method never returns a null Cursor if (!cursor.moveToFirst()) { //Cursor is empty... throw new CursorIndexOutOfBoundsException("Cursor should not be empty"); } Supervisor supervisor = new Supervisor(cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5)); return supervisor; }
/** * This function throws CursorIndexOutOfBoundsException if the cursor position is out of bounds. * Subclass implementations of the get functions should call this before attempting to * retrieve data. * * @throws CursorIndexOutOfBoundsException */ protected void checkPosition() { if (-1 == mPos || getCount() == mPos) { throw new CursorIndexOutOfBoundsException(mPos, getCount()); } }
throw new CursorIndexOutOfBoundsException("Requested column: " + column + ", # of columns: " + columnCount); throw new CursorIndexOutOfBoundsException("Before first row."); throw new CursorIndexOutOfBoundsException("After last row."); throw new CursorIndexOutOfBoundsException( "No more columns left.");
throw new CursorIndexOutOfBoundsException(mPos, getCount());