FileDocCategorySizeDatePackage
TrackerEntry.javaAPI DocAndroid 5.1 API8677Thu Mar 12 22:22:44 GMT 2015com.android.locationtracker.data

TrackerEntry

public class TrackerEntry extends Object
Class that holds a tracker entry. An entry can be either a valid location, or a simple log msg It provides a concrete data structure to represent data stored in the TrackerProvider

Fields Summary
static final String
TIMESTAMP
static final String
TAG
static final String
ENTRY_TYPE
private android.location.Location
mLocation
private float
mDistFromNetLocation
private String
mLogMsg
static final String
ID_COL
static final String
ACCURACY
static final String
LATITUDE
static final String
LONGITUDE
static final String
ALTITUDE
static final String
SPEED
static final String
BEARING
static final String
DIST_NET_LOCATION
static final String
LOC_TIME
static final String
DEBUG_INFO
static final String
STRING_DATA
static final String
INT_DATA
static final String
REAL_DATA
static final String
BLOB_DATA
static final String[]
ATTRIBUTES
static final String[]
ATTRIBUTES_DATA_TYPE
private static final String
NETWORK_LOCATION_SOURCE_KEY
private static final String
NETWORK_LOCATION_TYPE_KEY
private static final String[]
LOCATION_DEBUG_KEYS
private String
mTimestamp
private String
mTag
private EntryType
mType
Constructors Summary
private TrackerEntry(String tag, EntryType type)


         
        mType = type;
        mTag = tag;
        mLocation = null;
    
private TrackerEntry(android.location.Location loc)

        this(loc.getProvider(), EntryType.LOCATION_TYPE);
        mLocation = new Location(loc);
    
Methods Summary
static voidbuildCreationString(java.lang.StringBuilder builder)

        if (ATTRIBUTES.length != ATTRIBUTES_DATA_TYPE.length) {
            throw new IllegalArgumentException(
                    "Attribute length does not match data type length");
        }
        for (int i = 0; i < ATTRIBUTES_DATA_TYPE.length; i++) {
            if (i != 0) {
                builder.append(", ");
            }
            builder.append(String.format("%s %s", ATTRIBUTES[i],
                    ATTRIBUTES_DATA_TYPE[i]));
        }
    
static com.android.locationtracker.data.TrackerEntrycreateEntry(android.database.Cursor cursor)

        String timestamp = cursor.getString(cursor.getColumnIndex(TIMESTAMP));
        String tag = cursor.getString(cursor.getColumnIndex(TAG));
        String sType = cursor.getString(cursor.getColumnIndex(ENTRY_TYPE));
        TrackerEntry entry = new TrackerEntry(tag, EntryType.valueOf(sType));
        entry.setTimestamp(timestamp);
        if (entry.getType() == EntryType.LOCATION_TYPE) {
            Location location = new Location(tag);
            location.setLatitude(cursor.getFloat(cursor
                    .getColumnIndexOrThrow(LATITUDE)));
            location.setLongitude(cursor.getFloat(cursor
                    .getColumnIndexOrThrow(LONGITUDE)));

            Float accuracy = getNullableFloat(cursor, ACCURACY);
            if (accuracy != null) {
                location.setAccuracy(accuracy);
            }
            Float altitude = getNullableFloat(cursor, ALTITUDE);
            if (altitude != null) {
                location.setAltitude(altitude);
            }
            Float bearing = getNullableFloat(cursor, BEARING);
            if (bearing != null) {
                location.setBearing(bearing);
            }
            Float speed = getNullableFloat(cursor, SPEED);
            if (speed != null) {
                location.setSpeed(speed);
            }
            location.setTime(cursor.getLong(cursor.getColumnIndex(LOC_TIME)));
            entry.setLocation(location);
        }
        entry.setLogMsg(cursor.getString(cursor.getColumnIndex(DEBUG_INFO)));

        return entry;
    
static com.android.locationtracker.data.TrackerEntrycreateEntry(android.location.Location loc, float distFromNetLocation)
Creates a TrackerEntry from a Location

        TrackerEntry entry = new TrackerEntry(loc);

        String timestampVal = DateUtils.getCurrentKMLTimestamp();
        entry.setTimestamp(timestampVal);
        entry.setDistFromNetLocation(distFromNetLocation);
        return entry;
    
static com.android.locationtracker.data.TrackerEntrycreateEntry(java.lang.String tag, java.lang.String msg)
Creates a TrackerEntry from a log msg

        TrackerEntry entry = new TrackerEntry(tag, EntryType.LOG_TYPE);
        String timestampVal = DateUtils.getCurrentKMLTimestamp();
        entry.setTimestamp(timestampVal);
        entry.setLogMsg(msg);
        return entry;
    
android.content.ContentValuesgetAsContentValues()

        ContentValues cValues = new ContentValues(ATTRIBUTES.length);
        cValues.put(TIMESTAMP, mTimestamp);
        cValues.put(TAG, mTag);
        cValues.put(ENTRY_TYPE, mType.toString());
        if (mType == EntryType.LOCATION_TYPE) {
            cValues.put(LATITUDE, mLocation.getLatitude());
            cValues.put(LONGITUDE, mLocation.getLongitude());
            if (mLocation.hasAccuracy()) {
                cValues.put(ACCURACY, mLocation.getAccuracy());
            }
            if (mLocation.hasAltitude()) {
                cValues.put(ALTITUDE, mLocation.getAltitude());
            }
            if (mLocation.hasSpeed()) {
                cValues.put(SPEED, mLocation.getSpeed());
            }
            if (mLocation.hasBearing()) {
                cValues.put(BEARING, mLocation.getBearing());
            }
            cValues.put(DIST_NET_LOCATION, mDistFromNetLocation);
            cValues.put(LOC_TIME, mLocation.getTime());
            StringBuilder debugBuilder = new StringBuilder("");
            if (mLocation.getExtras() != null) {
                for (String key : LOCATION_DEBUG_KEYS) {
                    Object val = mLocation.getExtras().get(key);
                    if (val != null) {
                        debugBuilder.append(String.format("%s=%s; ", key, val
                                .toString()));
                    }
                }
            }
            cValues.put(DEBUG_INFO, debugBuilder.toString());
        } else {
            cValues.put(DEBUG_INFO, mLogMsg);
        }
        return cValues;
    
floatgetDistFromNetLocation()

        return mDistFromNetLocation;
    
android.location.LocationgetLocation()

        return mLocation;
    
java.lang.StringgetLogMsg()

        return mLogMsg;
    
private static java.lang.FloatgetNullableFloat(android.database.Cursor cursor, java.lang.String colName)

        Float retValue = null;
        int colIndex = cursor.getColumnIndexOrThrow(colName);
        if (!cursor.isNull(colIndex)) {
            retValue = cursor.getFloat(colIndex);
        }
        return retValue;
    
java.lang.StringgetTag()

        return mTag;
    
java.lang.StringgetTimestamp()

        return mTimestamp;
    
com.android.locationtracker.data.TrackerEntry$EntryTypegetType()

        return mType;
    
private voidsetDistFromNetLocation(float distFromNetLocation)

        mDistFromNetLocation = distFromNetLocation;
    
private voidsetLocation(android.location.Location location)

        mLocation = location;
    
private voidsetLogMsg(java.lang.String msg)

        mLogMsg = msg;
    
private voidsetTimestamp(java.lang.String timestamp)

        mTimestamp = timestamp;