Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.pivot.table.context
Class SingleGroupContext

java.lang.Object
  extended by com.citra.pivot.table.context.SingleGroupContext
All Implemented Interfaces:
TableContext

public class SingleGroupContext
extends Object
implements TableContext

SingleGroupContext is a context that will extract a single value from a table model. The value for the default locale is passed in the constructor, while values for more locales can be added with the setValueForLocale method.


Field Summary
protected  String singleValue
          the default value to use as the single member's value
protected  Map valuesByLocale
          a map containing values vs locales
 
Constructor Summary
SingleGroupContext(String singleValue)
          Constructs a SingleGroupContext.
 
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.
 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.
 String getValueForLocale(Locale locale)
          Determines the value for the single member for a given locale.
 void setValueForLocale(Locale locale, String value)
          Assigns the value for the single member for a given locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleValue

protected String singleValue
the default value to use as the single member's value


valuesByLocale

protected Map valuesByLocale
a map containing values vs locales

Constructor Detail

SingleGroupContext

public SingleGroupContext(String singleValue)
Constructs a SingleGroupContext.

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

setValueForLocale

public void setValueForLocale(Locale locale,
                              String value)
Assigns the value for the single member for a given locale.

Parameters:
locale - the locale to which a value is assigned
value - the value to assign

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

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

getValueForLocale

public String getValueForLocale(Locale locale)
Determines the value for the single member for a given locale.

Parameters:
locale - the locale to which a value is assigned
Returns:
the string value that was assigned to the locale, or null if no value had been assigned

Copyright © 2011 Citra Technologies. All Rights Reserved.