org.positronicnet

content

package content

The org.positronicnet.content package provides common infrastructure, and a common fluid interface, for accessing both SQLite Databases (via the Database class) and Android ContentProviders (via org.positronicnet.content.PositronicContentResolver). This interface is also used by the orm package, which provides a common higher-level structure for accessing the same resources, where it proves convenient.

The user-visible facilities of the infrastructure consist largely of the fluid interface for queries. A brief example: Suppose you have a Database declared as follows:

    class TodoDatabase( filename: String )
      extends Database( filename = filename, logTag = "todo" )
    {
      def schemaUpdates =
        List(""" create table todo_items (
                   _id int identity,
                   todo_list_name varchar(100),
                   description varchar(100),
                   is_done integer
                 )
             """)
    }

Then TodoDatabase("todo_items") will yield a ContentQuery object which can be used to manipulate the rows of the todo_items table in the following ways:

    // get query for "all the items"

    val qry = TodoDatabase("todo_items")

    // From that, get a query for "all items on one list"

    val bigListItems = qry.whereEq( "todo_list_name" -> "big list" )

    // Do a few things with that.  Note that on insert, the
    // column values are *not* defaulted from the conditions.

    val newId = bigListItems.insert( "todo_list_name" -> "big list",
                                     "description" -> "write docs",
                                     "is_done" -> false )
    bigListItems.where( "_id < ?", 50 ).update( "is_done" -> true )
    bigListItems.whereEq( "is_done" -> true ).delete

org.positronicnet.content.PositronicContentResolver can be used to deal with Android ContentProviders in a similar style.

Visibility
  1. Public
  2. All

Type Members

  1. class BatchAction extends ContentResolverAction

    Action on ContentResolvers that applies a batch of android.content.ContentProviderOperations.

  2. class ContentProviderQuery [IdType] extends ContentQuery[Uri, IdType]

    Queries on ContentProviders.

  3. class ContentQuery [SourceType, IdType] extends AnyRef

    Query on an arbitrary content source.

  4. trait ContentRepository [SourceType, IdType] extends AnyRef

    Generic interface to "content repositories", including databases and ContentResolvers.

  5. class ContentResolverAction extends AnyRef

    Action on the content resolver, considered as an actor

  6. class ContentValue extends AnyRef

    Abstract wrapper for any value that can be stored in a field of a data source in a ContentRepository --- currently, a SQLite database or Android ContentProvider.

  7. class CursorWrapper extends Cursor

    Wrapper around standard Android cursors, available as a base class for extensions.

  8. case class CvBoolean (value: Boolean) extends ContentValue with Product with Serializable

    Booleans as ContentValues.

  9. case class CvDouble (value: Double) extends ContentValue with Product with Serializable

    Doubles as ContentValues

  10. case class CvFloat (value: Float) extends ContentValue with Product with Serializable

    Floats as ContentValues

  11. case class CvInt (value: Int) extends ContentValue with Product with Serializable

    Ints as ContentValues

  12. case class CvLong (value: Long) extends ContentValue with Product with Serializable

    Longs as ContentValues

  13. case class CvString (value: String) extends ContentValue with Product with Serializable

    Strings as ContentValues

  14. class LongIdContentResolverRepository extends BaseContentResolverRepo[Long]

  15. class PositronicCursor extends CursorWrapper

    Wrapper around cursors to support foreach and map, so you can do, e.

  16. class UriIdContentResolverRepository extends BaseContentResolverRepo[Uri]

Value Members

  1. object ContentValue extends AnyRef

    Companion object for the org.positronicnet.org.ContentValue class.

  2. object PositronicContentResolver extends AppFacility with WorkerThread

    Simple AppFacility for interacting with Android ContentProviders using the Positronic Net ContentQuery convenience shorthands, or the orm.