de.mguennewig.pobjsearch
Class SearchColumn

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

public abstract class SearchColumn
extends java.lang.Object
implements SearchFilter

Abstract base class for search result columns.

Author:
Michael Günnewig

Method Summary
 void addOrderBy(Query q, boolean ascending)
          Adds the sorting directives to the query for this column.
abstract  java.lang.String formatValue(java.lang.Object value)
          Formats the "raw" value got from getValue(Record[]) for the UI.
 java.lang.String getIdentifier()
          Returns the identifier of this column.
 java.lang.String getLabel()
          Returns the default label of this column.
 SearchModel getSearchModel()
          Returns the search model to which this column belongs.
abstract  int getTableIndex()
           
abstract  java.lang.Object getValue(Record[] row)
          Returns the "raw" value for this column in the given row.
abstract  java.lang.Class<?> getValueClass()
          Returns the class instance of all values for this column.
 boolean isEditable()
          Returns whether this column is editable.
 boolean isFilterable()
          Returns whether the content of this column is filterable.
 boolean isLocalized()
          Returns whether the content of this column should be localized.
 boolean isRightAligned()
          Returns whether the content of this column should be right aligned.
 boolean isSortable()
          Returns whether the content of this column is sortable.
static Predicate matcher(PClassSearchForm.Condition condition, Type type, Term filter)
          Returns a matcher Predicate which can be used for SearchFilter#addFilter(SearchForm.Condition,Query).
static java.lang.String matchPattern(java.lang.String mode, java.lang.String pattern)
          Returns an SQL match pattern for LIKE.
 void pullInReferences(Query q)
          Pulls in references that will be required for display.
 void setFilterable(boolean filterable)
          Sets whether the content of this column is filterable.
 void setLocalized(boolean localized)
          Sets whether the content of this column should be localized.
 void setRightAligned(boolean rightAligned)
          Sets whether the content of this column should be right aligned.
 void setSortable(boolean sortable)
          Sets whether the content of this columns is sortable.
abstract  void setValue(Record[] row, java.lang.Object value)
          Sets the "raw" value for this column in the given row.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.mguennewig.pobjsearch.SearchFilter
addFilter
 

Method Detail

getIdentifier

public final java.lang.String getIdentifier()
Returns the identifier of this column.

Specified by:
getIdentifier in interface SearchFilter

getLabel

public final java.lang.String getLabel()
Returns the default label of this column.

Specified by:
getLabel in interface SearchFilter

getSearchModel

public final SearchModel getSearchModel()
Returns the search model to which this column belongs.


getTableIndex

public abstract int getTableIndex()

isFilterable

public final boolean isFilterable()
Returns whether the content of this column is filterable.


setFilterable

public void setFilterable(boolean filterable)
Sets whether the content of this column is filterable.


isLocalized

public final boolean isLocalized()
Returns whether the content of this column should be localized.


setLocalized

public void setLocalized(boolean localized)
Sets whether the content of this column should be localized.


isRightAligned

public final boolean isRightAligned()
Returns whether the content of this column should be right aligned.


setRightAligned

public void setRightAligned(boolean rightAligned)
Sets whether the content of this column should be right aligned.


isSortable

public final boolean isSortable()
Returns whether the content of this column is sortable.


setSortable

public void setSortable(boolean sortable)
Sets whether the content of this columns is sortable.


addOrderBy

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

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

The default implementation always throws an exception.

Throws:
java.lang.UnsupportedOperationException - if called.

getValueClass

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

See Also:
TableModel.getColumnClass(int)

getValue

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

See Also:
formatValue(Object)

isEditable

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

See Also:
setValue(Record[],Object)

setValue

public abstract 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 isEditable() returns true.

Throws:
PObjConstraintException - if a database constraint will be violated.
PObjSQLException - if any other database error occurs.
See Also:
isEditable(), Record.set(int,Object)

formatValue

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


pullInReferences

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


matcher

public static Predicate matcher(PClassSearchForm.Condition condition,
                                Type type,
                                Term filter)
Returns a matcher Predicate which can be used for SearchFilter#addFilter(SearchForm.Condition,Query).

Parameters:
condition - The search form.
type - The type declaration of the searched column.
filter - The term expression that specifies the filter condition.
Throws:
java.lang.IllegalArgumentException - if the search mode is unknown.

matchPattern

public static java.lang.String matchPattern(java.lang.String mode,
                                            java.lang.String pattern)
Returns an SQL match pattern for LIKE.

See Also:
PClassSearchForm.MODE_CONTAINS, PClassSearchForm.MODE_STARTS_WITH, PClassSearchForm.MODE_ENDS_WITH