Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.pivot.table.context
Class DateColumnContext

java.lang.Object
  extended by com.citra.pivot.table.context.SingleColumnContext
      extended by com.citra.pivot.table.context.DateColumnContext
All Implemented Interfaces:
TableContext
Direct Known Subclasses:
DayContext, MonthContext, QuarterContext, WeekContext, YearContext

public abstract class DateColumnContext
extends SingleColumnContext

DateColumnContext is an abstract context for extracting date values. It contains a shared calendar instance, as well as a simple date format for extracting and formatting date values respectively.


Nested Class Summary
static class DateColumnContext.DateContext
          DateContext is a class that holds the fields of a Calendar object.
 
Field Summary
protected  Calendar calendar
          a shared calendar to use for extracting date values
protected  SimpleDateFormat format
          the date format
 
Fields inherited from class com.citra.pivot.table.context.SingleColumnContext
captionColumn, columnsByLocale, comparator, extractColumn, nameColumn
 
Constructor Summary
protected DateColumnContext(int extractColumn)
          Constructs a DateColumnContext.
 
Method Summary
 void applyFormat(DateColumnContext.DateContext di, List row, Locale locale)
          Changes the simple date format's pattern, if necessary.
 int compareMemberValues(Object memberValue1, Object memberValue2)
          Compares two values that have been previously extracted in the extractMemberValue method.
 Object extractMemberValue(List row)
          Extracts a member value from a row that corresponds to the underlying table model.
 String getCaption(Object memberValue, List row, Locale locale)
          Determines the caption that will be displayed for the given member value and locale.
 SimpleDateFormat getDateFormat()
          Retrieves the simple date format used to format the date values into strings.
 String getDescription(Object memberValue, List row, Locale locale)
          Determines the description that will be displayed for the given member value and locale.
 String getName(Object memberValue, List row)
          Determines the name that will be displayed for the given member value.
 boolean hasField(int field)
          Determines whether a calendar field's value will be stored.
 void setField(int field, boolean set)
          Assigns the calendar fields for which a value is stored.
 
Methods inherited from class com.citra.pivot.table.context.SingleColumnContext
getColumnForLocale, setColumnForLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

calendar

protected Calendar calendar
a shared calendar to use for extracting date values


format

protected SimpleDateFormat format
the date format

Constructor Detail

DateColumnContext

protected DateColumnContext(int extractColumn)
Constructs a DateColumnContext.

Method Detail

applyFormat

public void applyFormat(DateColumnContext.DateContext di,
                        List row,
                        Locale locale)
Changes the simple date format's pattern, if necessary.
You can override this method for most advanced configurations. Do not forget to call format.applyPattern(pattern); , when finished.

Parameters:
di - the date info object which is formatted
row - the row to the table model
locale - the locale in which the format is applied

compareMemberValues

public int compareMemberValues(Object memberValue1,
                               Object memberValue2)
Compares two values that have been previously extracted in the extractMemberValue method.

Specified by:
compareMemberValues in interface TableContext
Overrides:
compareMemberValues in class SingleColumnContext
Parameters:
memberValue1 - the first value to compare
memberValue2 - the second value to compare
Returns:
the comparison result

extractMemberValue

public Object extractMemberValue(List row)
Extracts a member value from a row that corresponds to the underlying table model.

Specified by:
extractMemberValue in interface TableContext
Overrides:
extractMemberValue in class SingleColumnContext
Parameters:
row - the row to the table model
Returns:
the extracted value that will be used as the member value

getCaption

public String getCaption(Object memberValue,
                         List row,
                         Locale locale)
Determines the caption that will be displayed for the given member value and locale.

Specified by:
getCaption in interface TableContext
Overrides:
getCaption in class SingleColumnContext
Parameters:
memberValue - the member value
row - the row to the table model
locale - the locale for which the caption is returned
Returns:
the member's caption

getDateFormat

public SimpleDateFormat getDateFormat()
Retrieves the simple date format used to format the date values into strings.

Returns:
the date format

getDescription

public String getDescription(Object memberValue,
                             List row,
                             Locale locale)
Determines the description that will be displayed for the given member value and locale.

Specified by:
getDescription in interface TableContext
Overrides:
getDescription in class SingleColumnContext
Parameters:
memberValue - the member value
row - the row to the table model
locale - the locale for which the description is returned
Returns:
the member's description

getName

public String getName(Object memberValue,
                      List row)
Determines the name that will be displayed for the given member value.

Specified by:
getName in interface TableContext
Overrides:
getName in class SingleColumnContext
Parameters:
memberValue - the member value
row - the row to the table model
Returns:
the member's name

hasField

public boolean hasField(int field)
Determines whether a calendar field's value will be stored.

Parameters:
field - the field's value to store/unstore
Returns:
true if the field value is stored, false otherwise

setField

public void setField(int field,
                     boolean set)
Assigns the calendar fields for which a value is stored. The comparison will be based upon the fields that are collected.

Parameters:
field - the field's value to store/unstore
set - true if the field value is stored, false otherwise

Copyright © 2011 Citra Technologies. All Rights Reserved.