org.dspace.content
Class ItemComparator

java.lang.Object
  extended by org.dspace.content.ItemComparator
All Implemented Interfaces:
Comparator

public class ItemComparator
extends Object
implements Comparator

Compare two Items by their DCValues. The DCValues to be compared are specified by the element, qualifier and language parameters to the constructor. If the Item has more than one matching DCValue, then the max parameter to the constructor specifies whether the maximum or minimum lexicographic value will be used.

Version:
$Revision: 3761 $
Author:
Peter Breton

Constructor Summary
ItemComparator(String element, String qualifier, String language, boolean max)
          Constructor.
 
Method Summary
 int compare(Object first, Object second)
          Compare two Items by checking their DCValues for element, qualifier, and language.
 boolean equals(Object obj)
          Return true if the object is equal to this one, false otherwise.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItemComparator

public ItemComparator(String element,
                      String qualifier,
                      String language,
                      boolean max)
Constructor.

Parameters:
element - The Dublin Core element
qualifier - The Dublin Core qualifier
language - The language for the DCValues
max - If true, and there is more than one DCValue for element, qualifier and language, then use the maximum value lexicographically; otherwise use the minimum value.
Method Detail

compare

public int compare(Object first,
                   Object second)
Compare two Items by checking their DCValues for element, qualifier, and language.

Return >= 1 if the first is lexicographically greater than the second; <= -1 if the second is lexicographically greater than the first, and 0 otherwise.

Specified by:
compare in interface Comparator
Parameters:
first - The first object to compare. Must be an object of type org.dspace.content.Item.
second - The second object to compare. Must be an object of type org.dspace.content.Item.
Returns:
>= 1 if the first is lexicographically greater than the second; <= -1 if the second is lexicographically greater than the first, and 0 otherwise.

equals

public boolean equals(Object obj)
Return true if the object is equal to this one, false otherwise. Another object is equal to this one if it is also an ItemComparator, and has the same values for element, qualifier, language, and max.

Specified by:
equals in interface Comparator
Overrides:
equals in class Object
Parameters:
obj - The object to compare to.
Returns:
True if the other object is equal to this one, false otherwise.


Copyright © 2010 DuraSpace. All Rights Reserved.