Class FileTrans

java.lang.Object
org.cdlib.mrt.utility.FileTrans

public class FileTrans extends Object
This routine is used to normalize file names using a provided translation Map If the map is not provided then a default normalization translation is used Default translation is made on x'80' - x'9F' Example: default FileTrans fileTrans = new FileTrans(sourceFile); try { fileTrans.translate(); ... } catch (Exception ex) { ... } Example: provided translation FileTrans fileTrans = new FileTrans(sourceFile, tranTable); try { fileTrans.translate(); ... } catch (Exception ex) { ... }
Author:
dloy
  • Field Details

  • Constructor Details

    • FileTrans

      public FileTrans(File sourceFile) throws TException
      File name normalization using default translation Map
      Parameters:
      sourceFile - top level directory entry to begin translation
      Throws:
      TException
    • FileTrans

      public FileTrans(File sourceFile, Map<Character,Character> tranTable) throws TException
      File name normalization using provided translation Map
      Parameters:
      sourceFile - top level directory entry to begin translation
      tranTable - translation Map
      Throws:
      TException
  • Method Details

    • translate

      public void translate() throws TException
      Throws:
      TException
    • main

      public static void main(String[] args) throws TException
      Throws:
      TException
    • deleteEmpty

      public static void deleteEmpty(File testFile, File stopDir) throws TException
      Remove empty directories
      Parameters:
      testFile - top directory
      stopDir - top directory
      Throws:
      TException
    • tran

      public static String tran(String inName, Map<Character,Character> tranTable) throws Exception
      Translate directory name using translation Map
      Parameters:
      inName - file name to be translated
      tranTable - translation Map
      Returns:
      null = no translation required !null = tranlated name
      Throws:
      Exception
    • normExtension

      public static String normExtension(String inName) throws Exception
      Lower case extension if present Note extension is defined here as characters following trailing period with 5 or less characters This test is only performed on files that contain a translation
      Parameters:
      inName -
      Returns:
      inName with lower case extension
      Throws:
      Exception