fr.cnes.sitools.common.model
Class ResourceComparator<T>

java.lang.Object
  extended by fr.cnes.sitools.common.model.ResourceComparator<T>
Type Parameters:
T - class of SITools resources to be sorted
All Implemented Interfaces:
java.util.Comparator<T>

public class ResourceComparator<T>
extends java.lang.Object
implements java.util.Comparator<T>

Generic class for sorting SITools objects based on ResourceCollectionFilter definition.

Author:
jp.boignard (AKKA Technologies)

Field Summary
static java.lang.String ASC
          Ascending comparison
static java.lang.String DESC
          Decreasing comparison
static java.lang.String FIELD_DESCRIPTION
          Description of the field
static java.lang.String FIELD_ID
          ID of the field
static java.lang.String FIELD_NAME
          Name of the field
 
Constructor Summary
ResourceComparator(ResourceCollectionFilter filter)
          Constructor with ResourceFilter
 
Method Summary
 int compare(IResource o1, IResource o2)
          Compare two resources
 int compare(java.lang.String o1, java.lang.String o2)
          Compare two String objects according to filter parameters
 int compare(T o1, T o2)
           
 ResourceCollectionFilter getFilter()
          Gets the filter value
 void setFilter(ResourceCollectionFilter filter)
          Sets the value of filter
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

DESC

public static final java.lang.String DESC
Decreasing comparison

See Also:
Constant Field Values

ASC

public static final java.lang.String ASC
Ascending comparison

See Also:
Constant Field Values

FIELD_ID

public static final java.lang.String FIELD_ID
ID of the field

See Also:
Constant Field Values

FIELD_NAME

public static final java.lang.String FIELD_NAME
Name of the field

See Also:
Constant Field Values

FIELD_DESCRIPTION

public static final java.lang.String FIELD_DESCRIPTION
Description of the field

See Also:
Constant Field Values
Constructor Detail

ResourceComparator

public ResourceComparator(ResourceCollectionFilter filter)
Constructor with ResourceFilter

Parameters:
filter - ResourceFilter
Method Detail

getFilter

public final ResourceCollectionFilter getFilter()
Gets the filter value

Returns:
the filter

setFilter

public final void setFilter(ResourceCollectionFilter filter)
Sets the value of filter

Parameters:
filter - the filter to set

compare

public int compare(T o1,
                   T o2)
Specified by:
compare in interface java.util.Comparator<T>

compare

public final int compare(IResource o1,
                         IResource o2)
Compare two resources

Parameters:
o1 - resource 1
o2 - resource 2
Returns:
1 of r1 > r2, 0 if r1 = r2, -1 if r1 < r2

compare

public final int compare(java.lang.String o1,
                         java.lang.String o2)
Compare two String objects according to filter parameters

Parameters:
o1 - String
o2 - String
Returns:
int


Copyright © 2010-2013 CNES. All Rights Reserved.