Android Open Source - android-calendar-drafts Get Value Facade






From Project

Back to project page android-calendar-drafts.

License

The source code is released under:

Apache License

If you think the Android project android-calendar-drafts 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 com.touchableheroes.drafts.calendar.cursor;
/*  w  w w  .  j a v a2s  .c o  m*/
import java.util.List;

import com.touchableheroes.drafts.calendar.dao.Event;
import com.touchableheroes.drafts.calendar.dao.EventId;

import android.database.Cursor;
import android.net.Uri;

/**
 * 
 * @author A. Siebert, ask@touchableheroes.com
 */
public class GetValueFacade {

  private final Cursor cursor;
  private final List<Event> buffer;
  private Event current;

  public GetValueFacade(Cursor cursor, final List<Event> buffer) {
    this.cursor = cursor;

    if (buffer != null)
      this.buffer = buffer;
    else
      this.buffer = null;

    this.current = new Event();
  }

  /**
   * pushs current event to buffer and creates new one for the next push()
   * call. if buffer is not assigned, this method will skip the push()
   * handling.
   * 
   * @return current is a current event
   */
  public Event push() {
    if (this.buffer == null)
      return current;

    this.buffer.add(current);
    final Event rval = current;
    current = new Event();

    return rval;

  }

  public String string(final String key, final String cursorKey) {
    final int idx = this.cursor.getColumnIndex(cursorKey);
    final String val = this.cursor.getString(idx);
    current.setString(key, val);

    return null;
  }

  public long longVal(final String key, final String cursorKey) {
    final int idx = this.cursor.getColumnIndex(cursorKey);
    final long val = this.cursor.getLong(idx);
    current.setLong(key, val);

    return val;
  }

  /**
   * assign id to current event.
   * 
   * @param id internal event id, used by calendar-content-provider (@see Events._ID)
   * @return instance of EventId or null.
   */
  public EventId id(final String cursorKey) {
    final int idx = this.cursor.getColumnIndex(cursorKey);
    final long id = this.cursor.getLong(idx);
    
    return current.setId( id );
  }

}




Java Source Code List

com.touchableheroes.drafts.calendar.Start.java
com.touchableheroes.drafts.calendar.cmd.ContextCmd.java
com.touchableheroes.drafts.calendar.cmd.DeleteEventByHeaderCmd.java
com.touchableheroes.drafts.calendar.cmd.DeleteEventCmd.java
com.touchableheroes.drafts.calendar.cmd.ExistsEventCmd.java
com.touchableheroes.drafts.calendar.cmd.InsertDaylyRepeatableEventCmd.java
com.touchableheroes.drafts.calendar.cmd.InsertEventCmd.java
com.touchableheroes.drafts.calendar.cmd.InsertReminderCmd.java
com.touchableheroes.drafts.calendar.cmd.InsertRepeatableEventCmd.java
com.touchableheroes.drafts.calendar.cmd.LoadEventByIdCmd.java
com.touchableheroes.drafts.calendar.cmd.LoadEventsCmd.java
com.touchableheroes.drafts.calendar.cmd.ModifyEventCmd.java
com.touchableheroes.drafts.calendar.cmd.UpdateEventByHeaderCmd.java
com.touchableheroes.drafts.calendar.cursor.GetValueFacade.java
com.touchableheroes.drafts.calendar.dao.EventId.java
com.touchableheroes.drafts.calendar.dao.Event.java
com.touchableheroes.drafts.calendar.dao.EventsDAO.java
com.touchableheroes.drafts.calendar.util.WherePart.java
com.touchableheroes.drafts.calendar.util.WhereQueryPartBuilder.java