/** * Returns the next object in the iteration, i.e. returns the element in front of the iterator and advances the iterator by one position. * * @return the next object. * @throws java.util.NoSuchElementException if there are no more elements. * @see android.content.EntityIterator#hasNext() */ @Override public final Entity next() { if (mIsClosed) { throw new IllegalStateException("calling next() when the iterator is closed"); } if (!hasNext()) { throw new IllegalStateException("you may only call next() if hasNext() is true"); } try { return getEntityAndIncrementCursor(mCursor); } catch (RemoteException e) { throw new RuntimeException("caught a remote exception, this process will die soon", e); } }
public static RawContact createFrom(Entity entity) { final ContentValues values = entity.getEntityValues(); final ArrayList<Entity.NamedContentValues> subValues = entity.getSubValues(); RawContact rawContact = new RawContact(null, values); for (Entity.NamedContentValues subValue : subValues) { rawContact.addNamedDataItemValues(subValue.uri, subValue.values); } return rawContact; }
/** * Create an {@link RawContactDeltaList} that contains the entities of the Iterator as before * values. This function can be passed an iterator of Entity objects or an iterator of * RawContact objects. */ public static RawContactDeltaList fromIterator(Iterator<?> iterator) { final RawContactDeltaList state = new RawContactDeltaList(); // Perform background query to pull contact details while (iterator.hasNext()) { // Read all contacts into local deltas to prepare for edits Object nextObject = iterator.next(); final RawContact before = nextObject instanceof Entity ? RawContact.createFrom((Entity) nextObject) : (RawContact) nextObject; final RawContactDelta rawContactDelta = RawContactDelta.fromBefore(before); state.add(rawContactDelta); } return state; }
protected PersistentEntity(Entity instance) { this(instance.getEntityValues()); }
protected PersistentEntity(ContentValues contentValues) { INSTANCE = new Entity(new ContentValues()); }
/** * Returns the entity that the cursor is currently pointing to. This must take care to advance the cursor past this entity. This will never be called if the cursor is at the end. * * @param cursor the cursor that contains the entity rows * * @return the entity that the cursor is currently pointing to * @throws android.os.RemoteException if a RemoteException is caught while attempting to build the Entity */ public abstract Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException;