Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.pivot.table.context
Class SingleColumnContext

java.lang.Object
  extended by com.citra.pivot.table.context.SingleColumnContext
All Implemented Interfaces:
TableContext
Direct Known Subclasses:
DateColumnContext

public class SingleColumnContext
extends Object
implements TableContext

SingleColumnContext is a context that extracts member values, based on a single column of the rows of a table model.
It uses a Comparator in order to compare the two extracted values. The displayed values are taken from a single column, which is specified in the constructor, for the default locale. Other locales can use different columns, assigned with the setColumnForLocale method.


Field Summary
protected  int captionColumn
          the default column to use for the displayed member captions
protected  Map columnsByLocale
          a map containing column indeces vs locales
protected  Comparator comparator
          a comparator to use for comparing two extracted member values
protected  int extractColumn
          the column in the table model that is used to extract the member value
protected  int nameColumn
          the column in the table model that is used to extract the member's name
 
Constructor Summary
SingleColumnContext(int extractColumn)
          Constructs a SingleColumnContext with extractColumn as the column holding the member name, caption and extract value.
SingleColumnContext(int extractColumn, Comparator comparator)
          Constructs a SingleColumnContext with extractColumn as the column holding the member name, caption and extract value.
SingleColumnContext(int extractColumn, int nameColumn)
          Constructs a SingleColumnContext with extractColumn as the column holding the extract value and nameColumn the member's name and caption.
SingleColumnContext(int extractColumn, int nameColumn, int captionColumn)
          Constructs a SingleColumnContext with extractColumn as the column holding the extract value, nameColumn the member's name and captionColumn the member's caption.
SingleColumnContext(int extractColumn, int nameColumn, int captionColumn, Comparator comparator)
          Constructs a SingleColumnContext with extractColumn as the column holding the extract value, nameColumn the member's name and captionColumn the member's caption.
 
Method Summary
 int compareMemberValues(Object o1, Object o2)
          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.
 int getColumnForLocale(Locale locale)
          Retrieves the column that holds the member's caption for a given locale.
 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.
 void setColumnForLocale(Locale locale, int column)
          Assigns the column that holds the member's caption for a given locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extractColumn

protected int extractColumn
the column in the table model that is used to extract the member value


nameColumn

protected int nameColumn
the column in the table model that is used to extract the member's name


captionColumn

protected int captionColumn
the default column to use for the displayed member captions


comparator

protected Comparator comparator
a comparator to use for comparing two extracted member values


columnsByLocale

protected Map columnsByLocale
a map containing column indeces vs locales

Constructor Detail

SingleColumnContext

public SingleColumnContext(int extractColumn)
Constructs a SingleColumnContext with extractColumn as the column holding the member name, caption and extract value.


SingleColumnContext

public SingleColumnContext(int extractColumn,
                           int nameColumn)
Constructs a SingleColumnContext with extractColumn as the column holding the extract value and nameColumn the member's name and caption.


SingleColumnContext

public SingleColumnContext(int extractColumn,
                           int nameColumn,
                           int captionColumn)
Constructs a SingleColumnContext with extractColumn as the column holding the extract value, nameColumn the member's name and captionColumn the member's caption.


SingleColumnContext

public SingleColumnContext(int extractColumn,
                           int nameColumn,
                           int captionColumn,
                           Comparator comparator)
Constructs a SingleColumnContext with extractColumn as the column holding the extract value, nameColumn the member's name and captionColumn the member's caption. The comparator to use is also passed as an argument.


SingleColumnContext

public SingleColumnContext(int extractColumn,
                           Comparator comparator)
Constructs a SingleColumnContext with extractColumn as the column holding the member name, caption and extract value. The comparator to use is also passed as an argument.

Method Detail

compareMemberValues

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

Specified by:
compareMemberValues in interface TableContext
Parameters:
o1 - the first value to compare
o2 - 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
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
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

getColumnForLocale

public int getColumnForLocale(Locale locale)
Retrieves the column that holds the member's caption for a given locale.

Parameters:
locale - the locale to which a column is assigned
Returns:
the column index

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
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
Parameters:
memberValue - the member value
row - the row to the table model
Returns:
the member's name

setColumnForLocale

public void setColumnForLocale(Locale locale,
                               int column)
Assigns the column that holds the member's caption for a given locale.

Parameters:
locale - the locale to which a column is assigned
column - the column index

Copyright © 2011 Citra Technologies. All Rights Reserved.