package net.sourceforge.phpeclipse.mover;


import java.io.File;

import net.sourceforge.phpeclipse.views.PHPConsole;

/**
 * Provides default mover implementation 
 *
 */
abstract public class DefaultMover
   implements IMover
{
   /**
    * Console for output 
    * */
   protected PHPConsole fConsole;

   /**
    * Creates a DefaultMover 
    * @param console Console to report errors to
    */
   public DefaultMover(PHPConsole console)
   {
      this.fConsole = console;
   }

   /**
    * compute a file extension
    * @param file file to compute the extension from
    * @return the file extension (excluding the .), "" if none
    */
   public static String getExtension(File file)
   {
      String filename = file.getName();
      int index = filename.lastIndexOf('.');
      return index != -1 ? filename.substring(index + 1) : "";
   }

   /**
    * compute the filename without the extension
    * @param file file to compute the extension from
    * @return the file name without the extension (excluding the .)
    */
   public static String getDisplayName(File file)
   {
      String filename = file.getName();
      int index = filename.lastIndexOf('.');
      return index != -1 ? filename.substring(0,index) : filename;
   }
}