new icons
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / mover / DefaultMover.java
1 package net.sourceforge.phpeclipse.mover;
2
3
4 import java.io.File;
5
6 import net.sourceforge.phpeclipse.views.PHPConsole;
7
8 /**
9  * Provides default mover implementation 
10  *
11  */
12 abstract public class DefaultMover
13    implements IMover
14 {
15    /**
16     * Console for output 
17     * */
18    protected PHPConsole fConsole;
19
20    /**
21     * Creates a DefaultMover 
22     * @param console Console to report errors to
23     */
24    public DefaultMover(PHPConsole console)
25    {
26       this.fConsole = console;
27    }
28
29    /**
30     * compute a file extension
31     * @param file file to compute the extension from
32     * @return the file extension (excluding the .), "" if none
33     */
34    public static String getExtension(File file)
35    {
36       String filename = file.getName();
37       int index = filename.lastIndexOf('.');
38       return index != -1 ? filename.substring(index + 1) : "";
39    }
40
41    /**
42     * compute the filename without the extension
43     * @param file file to compute the extension from
44     * @return the file name without the extension (excluding the .)
45     */
46    public static String getDisplayName(File file)
47    {
48       String filename = file.getName();
49       int index = filename.lastIndexOf('.');
50       return index != -1 ? filename.substring(0,index) : filename;
51    }
52 }