public class CalendarLens<C extends java.util.Calendar> extends Lens<C> implements Refractor<C>
Calendar
objects.
The lens converts all dates into integer GMT timestamps for storage in the
DB, then recreates the Calendar
objects upon retrieval. This is
because integer timestamps are more reliably stored and are absolute (no
fretting about timezones).
For custom calendar implementations, extend this class with your own empty descendant templatized on your calendar:
public class CustomCalendarLens extends CalendarLens<CustomCalendar> implements Refractor<CustomCalendar> {}
Constructor and Description |
---|
CalendarLens() |
Modifier and Type | Method and Description |
---|---|
CalendarLens<C> |
addToBundle(android.os.Bundle bndl,
java.lang.String sKey,
C val)
Determines the correct method in
Bundle to be used to add the
specified value to an existing bundle. |
CalendarLens<C> |
addToContentValues(android.content.ContentValues vals,
java.lang.String sKey,
C val)
Determines the correct method in
ContentValues to be used to add
the specified value to a set of content values. |
C |
fromBundle(android.os.Bundle bndl,
java.lang.String sKey)
Determines the correct method in
Bundle to be used to fetch the
specified column, then returns that value. |
C |
fromCursor(android.database.Cursor crs,
java.lang.String sKey)
Determines the correct method in
Cursor to be used to fetch the
specified column, then returns that value. |
java.lang.String |
getSQLiteDataType()
Because
SQLiteHouse will manage all datetime data elements as
integer timestamps, the SQLite data type chosen here is the integer type. |
C |
getSQLiteDefaultValue()
When a date cannot be null, this class provides a default value at the
start of the epoch.
|
java.lang.String |
toSQLiteString(C o)
Converts a Java thing's value into a string to be used in a SQLite query,
for example, in a
WHERE clause filter. |
getSQLiteDefaultString, getValueFrom
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSQLiteDefaultString, getValueFrom
public java.lang.String getSQLiteDataType()
SQLiteHouse
will manage all datetime data elements as
integer timestamps, the SQLite data type chosen here is the integer type.getSQLiteDataType
in interface Refractor<C extends java.util.Calendar>
"INT"
public C getSQLiteDefaultValue()
getSQLiteDefaultValue
in interface Refractor<C extends java.util.Calendar>
getSQLiteDefaultValue
in class Lens<C extends java.util.Calendar>
Calendar
initialized at epoch time zeropublic java.lang.String toSQLiteString(C o)
Refractor
WHERE
clause filter.toSQLiteString
in interface Refractor<C extends java.util.Calendar>
toSQLiteString
in class Lens<C extends java.util.Calendar>
o
- the Java thing to be convertedpublic CalendarLens<C> addToContentValues(android.content.ContentValues vals, java.lang.String sKey, C val)
Refractor
ContentValues
to be used to add
the specified value to a set of content values.addToContentValues
in interface Refractor<C extends java.util.Calendar>
vals
- the set of content valuessKey
- the content value keyval
- the value to be storedpublic CalendarLens<C> addToBundle(android.os.Bundle bndl, java.lang.String sKey, C val)
Refractor
Bundle
to be used to add the
specified value to an existing bundle.addToBundle
in interface Refractor<C extends java.util.Calendar>
bndl
- the bundlesKey
- the field's keyval
- the value to be storedpublic C fromCursor(android.database.Cursor crs, java.lang.String sKey)
Refractor
Cursor
to be used to fetch the
specified column, then returns that value.fromCursor
in interface Refractor<C extends java.util.Calendar>
crs
- the cursor from which data should be fetchedsKey
- the data column namepublic C fromBundle(android.os.Bundle bndl, java.lang.String sKey)
Refractor
Bundle
to be used to fetch the
specified column, then returns that value.fromBundle
in interface Refractor<C extends java.util.Calendar>
bndl
- the bundle from which data should be fetchedsKey
- the data column name