FileDocCategorySizeDatePackage
TimeStatsAggregator.javaAPI DocAndroid 5.1 API6762Thu Mar 12 22:22:48 GMT 2015android.bordeaux.services

TimeStatsAggregator

public class TimeStatsAggregator extends Aggregator

Fields Summary
final String
TAG
public static final String
TIME_OF_WEEK
public static final String
DAY_OF_WEEK
public static final String
TIME_OF_DAY
public static final String
PERIOD_OF_DAY
static final String
WEEKEND
static final String
WEEKDAY
static final String
MONDAY
static final String
TUESDAY
static final String
WEDNESDAY
static final String
THURSDAY
static final String
FRIDAY
static final String
SATURDAY
static final String
SUNDAY
static final String
MORNING
static final String
NOON
static final String
AFTERNOON
static final String
EVENING
static final String
NIGHT
static final String
LATENIGHT
static final String
DAYTIME
static final String
NIGHTTIME
static String
mFakeTimeOfDay
static String
mFakeDayOfWeek
static final String[]
TIME_OF_DAY_VALUES
static final String[]
DAY_OF_WEEK_VALUES
static final String[]
DAYTIME_VALUES
Constructors Summary
Methods Summary
static java.util.HashMapgetAllTimeFeatures(long utcTime)

        HashMap<String, String> features = new HashMap<String, String>();
        Time time = new Time();
        time.set(utcTime);

        if (mFakeTimeOfDay != null && mFakeTimeOfDay.length() != 0) {
            List<String> day_list = Arrays.asList(DAYTIME_VALUES);

            if (day_list.contains(mFakeTimeOfDay)) {
                features.put(PERIOD_OF_DAY, DAYTIME);
            } else {
                features.put(PERIOD_OF_DAY, NIGHTTIME);
            }
            features.put(TIME_OF_DAY, mFakeTimeOfDay);
        } else {
            features.put(PERIOD_OF_DAY, getPeriodOfDay(time.hour));
            features.put(TIME_OF_DAY, getTimeOfDay(time.hour));
        }

        if (mFakeDayOfWeek != null && mFakeDayOfWeek.length() != 0) {
            features.put(DAY_OF_WEEK, mFakeDayOfWeek);
            if (mFakeDayOfWeek.equals(SUNDAY) ||
                mFakeDayOfWeek.equals(SATURDAY) ||
                mFakeDayOfWeek.equals(FRIDAY) &&
                    features.get(PERIOD_OF_DAY).equals(NIGHTTIME)) {
                features.put(TIME_OF_WEEK, WEEKEND);
            } else {
                features.put(TIME_OF_WEEK, WEEKDAY);
            }
        }
        else {
            features.put(DAY_OF_WEEK, getDayOfWeek(time.weekDay));
            if (time.weekDay == Time.SUNDAY || time.weekDay == Time.SATURDAY ||
                    (time.weekDay == Time.FRIDAY &&
                    features.get(PERIOD_OF_DAY).equals(NIGHTTIME))) {
                features.put(TIME_OF_WEEK, WEEKEND);
            } else {
                features.put(TIME_OF_WEEK, WEEKDAY);
            }
        }

        return features;
    
private static java.lang.StringgetDayOfWeek(int day)

        switch (day) {
            case Time.SATURDAY:
                return SATURDAY;
            case Time.SUNDAY:
                return SUNDAY;
            case Time.MONDAY:
                return MONDAY;
            case Time.TUESDAY:
                return TUESDAY;
            case Time.WEDNESDAY:
                return WEDNESDAY;
            case Time.THURSDAY:
                return THURSDAY;
            default:
                return FRIDAY;
        }
    
public static java.util.ListgetDayOfWeekValues()

        return Arrays.asList(DAY_OF_WEEK_VALUES);
    
public java.util.MapgetFeatureValue(java.lang.String featureName)

        HashMap<String,String> feature = new HashMap<String,String>();

        HashMap<String, String> features =
            getAllTimeFeatures(System.currentTimeMillis());
        if (features.containsKey(featureName)) {
            feature.put(featureName, features.get(featureName));
        } else {
            Log.e(TAG, "There is no Time feature called " + featureName);
        }
        return (Map)feature;
    
public java.lang.String[]getListOfFeatures()


      
        String [] list = new String[4];
        list[0] = TIME_OF_WEEK;
        list[1] = DAY_OF_WEEK;
        list[2] = TIME_OF_DAY;
        list[3] = PERIOD_OF_DAY;
        return list;
    
private static java.lang.StringgetPeriodOfDay(int hour)

        if (hour > 6 && hour < 19) {
            return DAYTIME;
        } else {
            return NIGHTTIME;
        }
    
private static java.lang.StringgetTimeOfDay(int hour)

        if (hour >= 5 && hour < 11) {
            return MORNING;
        } else if (hour >= 11 && hour < 14) {
            return NOON;
        } else if (hour >= 14 && hour < 18) {
            return AFTERNOON;
        } else if (hour >= 18 && hour < 21) {
            return EVENING;
        } else if ((hour >= 21 && hour < 24) ||
                   (hour >= 0 && hour < 1))  {
            return NIGHT;
        } else {
            return LATENIGHT;
        }
    
public static java.util.ListgetTimeOfDayValues()

        return Arrays.asList(TIME_OF_DAY_VALUES);
    
public static voidsetFakeDayOfWeek(java.lang.String day_of_week)

        mFakeDayOfWeek = day_of_week;
    
public static voidsetFakeTimeOfDay(java.lang.String time_of_day)

        mFakeTimeOfDay = time_of_day;