hardening the timeline facet

git-svn-id: http://google-refine.googlecode.com/svn/trunk@1353 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-09-27 21:59:17 +00:00
parent e5ddfa6fdc
commit 86f810a324

View File

@ -1,6 +1,7 @@
package com.google.refine.browsing.util;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@ -46,11 +47,11 @@ abstract public class TimeBinIndex {
1000*60*60, // hour
1000*60*60*24, // day
1000*60*60*24*7, // week
1000*2629746, // month (average Gregorian year / 12)
1000*31556952, // year (average Gregorian year)
1000*31556952*10, // decade
1000*31556952*100, // century
1000*31556952*1000, // millennium
1000l*2629746l, // month (average Gregorian year / 12)
1000l*31556952l, // year (average Gregorian year)
1000l*31556952l*10l, // decade
1000l*31556952l*100l, // century
1000l*31556952l*1000l, // millennium
};
abstract protected void iterate(Project project, RowEvaluable rowEvaluable, List<Long> allValues);
@ -145,6 +146,10 @@ abstract public class TimeBinIndex {
if (ExpressionUtils.isError(v)) {
_hasError = true;
} else if (ExpressionUtils.isNonBlankData(v)) {
if (v instanceof Calendar) {
v = ((Calendar) v).getTime();
}
if (v instanceof Date) {
_hasTime = true;
processValue(((Date) v).getTime(), allValues);
@ -162,6 +167,10 @@ abstract public class TimeBinIndex {
if (ExpressionUtils.isError(v)) {
_hasError = true;
} else if (ExpressionUtils.isNonBlankData(v)) {
if (v instanceof Calendar) {
v = ((Calendar) v).getTime();
}
if (v instanceof Date) {
_hasTime = true;
processValue(((Date) v).getTime(), allValues);
@ -175,6 +184,10 @@ abstract public class TimeBinIndex {
} else {
_totalValueCount++;
if (value instanceof Calendar) {
value = ((Calendar) value).getTime();
}
if (value instanceof Date) {
_hasTime = true;
processValue(((Date) value).getTime(), allValues);