1
2
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
45
46
47
48
49
50
51
52
53
54
55
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 }