home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / Source.bin / CompareTextAndImageCells.java < prev    next >
Encoding:
Java Source  |  1998-09-14  |  1.9 KB  |  79 lines

  1. package symantec.itools.awt.multiList;
  2.  
  3. import java.util.BitSet;
  4. import symantec.itools.awt.CompareCells;
  5. import java.util.ResourceBundle;
  6.  
  7. // 07/14/97    LAB    Separeated from Multilist.java. Made public to accommodate future
  8. //                extendibility of the MultiList class.
  9.  
  10. /**
  11.  * This is a helper class to the MultiList class.
  12.  * It is used to compare Cells of the MultiList.
  13.  * @version 1.1, July 14, 1997
  14.  * @author Symantec
  15.  */
  16. public class CompareTextAndImageCells
  17.     extends CompareCells
  18. {
  19.     /**
  20.      * Constructs a CompareTextAndImageCells object.
  21.      */
  22.     public CompareTextAndImageCells()
  23.     {        
  24.         try
  25.         {
  26.             errors = ResourceBundle.getBundle("symantec.itools.resources.ErrorsBundle");
  27.         }
  28.         catch(Throwable ex)
  29.         {
  30.             errors = new symantec.itools.resources.ErrorsBundle();
  31.         }
  32.     }
  33.  
  34.     /**
  35.      * Compares the value of two objects.
  36.      * @param o1 the first object
  37.      * @param o2 the second object
  38.      * @return 0 if the object's values are equal, less than 0 if the first
  39.      * object's value is less than the second object's value, and greater
  40.      * than 0 if the first object's value is greater than the second
  41.      * object's value
  42.      * @param o1 the first object
  43.      * @param o2 the second object
  44.      */
  45.     public int compareObjects(Object o1, Object o2)
  46.     {
  47.         TextAndImageCell c1;
  48.         TextAndImageCell c2;
  49.  
  50.         c1 = null;
  51.         c2 = null;
  52.  
  53.         if(o1 instanceof TextAndImageCell)
  54.         {
  55.             c1 = (TextAndImageCell)o1;
  56.         }
  57.         else
  58.         {
  59.             throw new IllegalArgumentException(errors.getString("NotCellObject"));
  60.         }
  61.  
  62.         if(o2 instanceof TextAndImageCell)
  63.         {
  64.             c2 = (TextAndImageCell)o2;
  65.         }
  66.         else
  67.         {
  68.             throw new IllegalArgumentException(errors.getString("NotCellObject"));
  69.         }
  70.  
  71.         String o1Text = (c1 != null) ? c1.getText() : "";
  72.         String o2Text = (c2 != null) ? c2.getText() : "";
  73.  
  74.         return o1Text.compareTo(o2Text);
  75.     }
  76.  
  77.     transient protected ResourceBundle errors;
  78. }
  79.