de.mguennewig.pobjsearch
Class DefaultSearchColumn

java.lang.Object
  extended by de.mguennewig.pobjsearch.SearchColumn
      extended by de.mguennewig.pobjsearch.DefaultSearchColumn
All Implemented Interfaces:
SearchFilter

public class DefaultSearchColumn
extends SearchColumn

A search column implementation that uses the persistent object columns directly.

Author:
Michael Günnewig

Constructor Summary
DefaultSearchColumn(java.lang.String identifier, java.lang.String label, int tableIndex, Column... selectors)
          Creates a new instance of DefaultSearchColumn
 
Method Summary
 void addFilter(PClassSearchForm.Condition condition, Query q)
          Adds this filter to the query.
 void addOrderBy(Query q, boolean ascending)
          Adds the sorting directives to the query for this column.
 java.lang.String formatValue(java.lang.Object value)
          Formats the "raw" value got from SearchColumn.getValue(Record[]) for the UI.
 int getNumSelectors()
           
 Column getSelector(int n)
           
 int getTableIndex()
          
 java.lang.Object getValue(Record[] row)
          Returns the "raw" value for this column in the given row.
 java.lang.Class<?> getValueClass()
          Returns the class instance of all values for this column.
 boolean isEditable()
          Returns whether this column is editable.
 void pullInReferences(Query q)
          Pulls in references that will be required for display.
 void setValue(Record[] row, java.lang.Object value)
          Sets the "raw" value for this column in the given row.
 
Methods inherited from class de.mguennewig.pobjsearch.SearchColumn
getIdentifier, getLabel, getSearchModel, isFilterable, isLocalized, isRightAligned, isSortable, matcher, matchPattern, setFilterable, setLocalized, setRightAligned, setSortable
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSearchColumn

public DefaultSearchColumn(java.lang.String identifier,
                           java.lang.String label,
                           int tableIndex,
                           Column... selectors)
Creates a new instance of DefaultSearchColumn

Parameters:
identifier -
label -
Method Detail

getTableIndex

public final int getTableIndex()

Specified by:
getTableIndex in class SearchColumn

getNumSelectors

public final int getNumSelectors()

getSelector

public final Column getSelector(int n)

addFilter

public void addFilter(PClassSearchForm.Condition condition,
                      Query q)
Adds this filter to the query.


addOrderBy

public void addOrderBy(Query q,
                       boolean ascending)
Adds the sorting directives to the query for this column.

This method is only called if SearchColumn.isSortable() yields true.

The default implementation always throws an exception.

Overrides:
addOrderBy in class SearchColumn

getValueClass

public java.lang.Class<?> getValueClass()
Returns the class instance of all values for this column.

Specified by:
getValueClass in class SearchColumn
See Also:
TableModel.getColumnClass(int)

getValue

public java.lang.Object getValue(Record[] row)
Returns the "raw" value for this column in the given row.

Specified by:
getValue in class SearchColumn
See Also:
Record.get(Column), PObject.loadIfReference()

isEditable

public boolean isEditable()
Returns whether this column is editable.

Overrides:
isEditable in class SearchColumn
See Also:
SearchColumn.setValue(Record[],Object)

setValue

public void setValue(Record[] row,
                     java.lang.Object value)
              throws PObjConstraintException,
                     PObjSQLException
Sets the "raw" value for this column in the given row.

Note that this method must only be called if SearchColumn.isEditable() returns true.

Specified by:
setValue in class SearchColumn
Throws:
java.lang.UnsupportedOperationException - if the corresponding record in the row is not a PObject.
PObjConstraintException - if a database constraint will be violated.
PObjSQLException - if any other database error occurs.
See Also:
SearchColumn.isEditable(), Record.set(int,Object)

formatValue

public java.lang.String formatValue(java.lang.Object value)
Formats the "raw" value got from SearchColumn.getValue(Record[]) for the UI.

Specified by:
formatValue in class SearchColumn
See Also:
Type.format(Object)

pullInReferences

public void pullInReferences(Query q)
Pulls in references that will be required for display.

Overrides:
pullInReferences in class SearchColumn