gov.nih.nlm.util
Class StringFieldComparator

java.lang.Object
  extended bygov.nih.nlm.util.StringFieldComparator
All Implemented Interfaces:
Comparator

public class StringFieldComparator
extends Object
implements Comparator

Used to compare string field objects.

Author:
MEME Group

Constructor Summary
StringFieldComparator(String delim, int field_num)
          Instantiates a comparator for the specified parameters.
StringFieldComparator(String delim, int field_num, boolean ascending)
          Instantiates a comparator for the specified parameters.
 
Method Summary
 int compare(Object o1, Object o2)
          Compares the specified field of each String object.
 void setNumeric(boolean b)
          Causes sort to be numeric
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

StringFieldComparator

public StringFieldComparator(String delim,
                             int field_num)
Instantiates a comparator for the specified parameters.

Parameters:
delim - a String containing delimiter characters
field_num - an int representation of field numbers

StringFieldComparator

public StringFieldComparator(String delim,
                             int field_num,
                             boolean ascending)
Instantiates a comparator for the specified parameters.

Parameters:
delim - a String containing delimiter characters
field_num - an int representation of field numbers
ascending - true if compare in ascending order; false otherwise
Method Detail

setNumeric

public void setNumeric(boolean b)
Causes sort to be numeric

Parameters:
b - boolean

compare

public int compare(Object o1,
                   Object o2)
Compares the specified field of each String object.

Specified by:
compare in interface Comparator
Parameters:
o1 - the first Object to be compared.
o2 - the second Object to be compared.
Returns:
An int which might be negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.


Copyright ©2005