Package org.jf.util

Class ClassFileNameHandler

java.lang.Object
org.jf.util.ClassFileNameHandler

public class ClassFileNameHandler extends Object
This class handles the complexities of translating a class name into a file name. i.e. dealing with case insensitive file systems, windows reserved filenames, class names with extremely long package/class elements, etc. The types of transformations this class does include: - append a '#123' style numeric suffix if 2 physical representations collide - replace some number of characters in the middle with a '#' character name if an individual path element is too long - append a '#' if an individual path element would otherwise be considered a reserved filename
  • Field Details

  • Constructor Details

    • ClassFileNameHandler

      public ClassFileNameHandler(File path, String fileExtension)
    • ClassFileNameHandler

      public ClassFileNameHandler(File path, String fileExtension, boolean caseSensitive, boolean modifyWindowsReservedFilenames)
  • Method Details

    • getMaxFilenameLength

      private int getMaxFilenameLength()
    • getUniqueFilenameForClass

      public File getUniqueFilenameForClass(String className) throws IOException
      Throws:
      IOException
    • addUniqueChild

      @Nonnull private File addUniqueChild(@Nonnull ClassFileNameHandler.DirectoryEntry parent, @Nonnull String[] packageElements, int packageElementIndex) throws IOException
      Throws:
      IOException
    • utf8Length

      private static int utf8Length(String str)
    • utf8Length

      private static int utf8Length(int codePoint)
    • shortenPathComponent

      @Nonnull static String shortenPathComponent(@Nonnull String pathComponent, int bytesToRemove)
      Shortens an individual file/directory name, removing the necessary number of code points from the middle of the string such that the utf-8 encoding of the string is at least bytesToRemove bytes shorter than the original. The removed codePoints in the middle of the string will be replaced with a # character.
    • isWindows

      private static boolean isWindows()
    • isReservedFileName

      private static boolean isReservedFileName(String className)
    • addSuffixBeforeExtension

      private static String addSuffixBeforeExtension(String pathElement, String suffix)