View Javadoc
1   /*
2    * Created on 2003-jun-12
3    */
4   package net.sourceforge.jsh3modtool.gui.imagetable.cellsorters;
5   
6   import java.io.File;
7   import java.util.Comparator;
8   
9   import net.sourceforge.jsh3modtool.gui.imagetable.FolderCell;
10  import net.sourceforge.jsh3modtool.gui.imagetable.ImageCell;
11  
12  
13  /***
14   * A skeleton class for cell sorters to extend for easier sorting.
15   * 
16   * @author erma
17   */
18  public abstract class AbstractCellSorter implements Comparator
19  {        
20      /***
21       * Returns the objects name.
22       * @param obj an AbstractCell.
23       * @return the name of the object. (filename)
24       */
25      protected final String getFileName(Object obj)
26      {
27          String name;
28          if ( obj.getClass().equals(FolderCell.class))
29          {
30              name = ((FolderCell) obj).getName();
31          } 
32          else
33          {
34              name = ((ImageCell) obj).getName();
35          }
36          return name;
37      }  
38      
39      /***
40       * Returns the objects name.
41       * @param obj an AbstractCell.
42       * @return the name of the object. (filename)
43       */
44     /* protected final long getFileLastModified(Object obj)
45      {
46          File file;
47          if ( obj.getClass().equals(FolderCell.class))
48          {
49              file = new File( ((FolderCell) obj).getTargetPath() );
50          } 
51          else
52          {
53              file = new File( ((ImageCell) obj).getImageProperties().getFilename() );
54          }
55          return file.lastModified();
56      }*/
57      
58      /***
59       * Returns true if the object is a folder cell.
60       * @param obj the object to test.
61       * @return true if the object is a folder cell; false otherwise.
62       */
63      protected boolean isFolderCell( Object obj )
64      {
65          return obj.getClass().equals(FolderCell.class);
66      }
67      
68      /***
69       * Returns true if the object is an image cell.
70       * @param obj the object to test.
71       * @return true if the object is an image cell; false otherwise.
72       */
73      protected boolean isImageCell( Object obj )
74      {
75          return obj.getClass().equals(ImageCell.class);
76      }
77  }