Spring Framework

org.springframework.beans.support
Class MutableSortDefinition

java.lang.Object
  extended by org.springframework.beans.support.MutableSortDefinition
All Implemented Interfaces:
java.io.Serializable, SortDefinition

public class MutableSortDefinition
extends java.lang.Object
implements SortDefinition, java.io.Serializable

Mutable implementation of the SortDefinition interface. Supports toggling the ascending value on setting the same property again.

Since:
26.05.2003
Author:
Juergen Hoeller, Jean-Pierre Pawlak
See Also:
setToggleAscendingOnProperty(boolean), Serialized Form

Constructor Summary
MutableSortDefinition()
          Create an empty MutableSortDefinition, to be populated via its bean properties.
MutableSortDefinition(boolean toggleAscendingOnSameProperty)
          Create a new MutableSortDefinition.
MutableSortDefinition(SortDefinition source)
          Copy constructor: create a new MutableSortDefinition that mirrors the given sort definition.
MutableSortDefinition(java.lang.String property, boolean ignoreCase, boolean ascending)
          Create a MutableSortDefinition for the given settings.
 
Method Summary
 boolean equals(java.lang.Object other)
           
 java.lang.String getProperty()
          Return the name of the bean property to compare.
 int hashCode()
           
 boolean isAscending()
          Return whether to sort ascending (true) or descending (false).
 boolean isIgnoreCase()
          Return whether upper and lower case in String values should be ignored.
 boolean isToggleAscendingOnProperty()
          Return whether to toggle the ascending flag if the same property gets set again (that is, setProperty(java.lang.String) gets called with already set property name again).
 void setAscending(boolean ascending)
          Set whether to sort ascending (true) or descending (false).
 void setIgnoreCase(boolean ignoreCase)
          Set whether upper and lower case in String values should be ignored.
 void setProperty(java.lang.String property)
          Set the property to compare.
 void setToggleAscendingOnProperty(boolean toggleAscendingOnProperty)
          Set whether to toggle the ascending flag if the same property gets set again (that is, setProperty(java.lang.String) gets called with already set property name again).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MutableSortDefinition

public MutableSortDefinition()
Create an empty MutableSortDefinition, to be populated via its bean properties.

See Also:
setProperty(java.lang.String), setIgnoreCase(boolean), setAscending(boolean)

MutableSortDefinition

public MutableSortDefinition(SortDefinition source)
Copy constructor: create a new MutableSortDefinition that mirrors the given sort definition.

Parameters:
source - the original sort definition

MutableSortDefinition

public MutableSortDefinition(java.lang.String property,
                             boolean ignoreCase,
                             boolean ascending)
Create a MutableSortDefinition for the given settings.

Parameters:
property - the property to compare
ignoreCase - whether upper and lower case in String values should be ignored
ascending - whether to sort ascending (true) or descending (false)

MutableSortDefinition

public MutableSortDefinition(boolean toggleAscendingOnSameProperty)
Create a new MutableSortDefinition.

Parameters:
toggleAscendingOnSameProperty - whether to toggle the ascending flag if the same property gets set again (that is, setProperty gets called with already set property name again).
Method Detail

setProperty

public void setProperty(java.lang.String property)
Set the property to compare.

If the property was the same as the current, the sort is reversed if "toggleAscendingOnProperty" is activated, else simply ignored.

See Also:
setToggleAscendingOnProperty(boolean)

getProperty

public java.lang.String getProperty()
Description copied from interface: SortDefinition
Return the name of the bean property to compare. Can also be a nested bean property path.

Specified by:
getProperty in interface SortDefinition

setIgnoreCase

public void setIgnoreCase(boolean ignoreCase)
Set whether upper and lower case in String values should be ignored.


isIgnoreCase

public boolean isIgnoreCase()
Description copied from interface: SortDefinition
Return whether upper and lower case in String values should be ignored.

Specified by:
isIgnoreCase in interface SortDefinition

setAscending

public void setAscending(boolean ascending)
Set whether to sort ascending (true) or descending (false).


isAscending

public boolean isAscending()
Description copied from interface: SortDefinition
Return whether to sort ascending (true) or descending (false).

Specified by:
isAscending in interface SortDefinition

setToggleAscendingOnProperty

public void setToggleAscendingOnProperty(boolean toggleAscendingOnProperty)
Set whether to toggle the ascending flag if the same property gets set again (that is, setProperty(java.lang.String) gets called with already set property name again).

This is particularly useful for parameter binding through a web request, where clicking on the field header again might be supposed to trigger a resort for the same field but opposite order.


isToggleAscendingOnProperty

public boolean isToggleAscendingOnProperty()
Return whether to toggle the ascending flag if the same property gets set again (that is, setProperty(java.lang.String) gets called with already set property name again).


equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

Spring Framework