Class FileCollectionFormatter


  • public class FileCollectionFormatter
    extends java.lang.Object
    Groups a set of file names by directory. Provides a list of directories in the file set, and lumps directories with only one file together with its parent directory.
    Version:
    $Id: FileCollectionFormatter.java,v 1.9 2008/04/02 11:22:15 benoitx Exp $
    Author:
    Richard Cyganiak
    • Constructor Summary

      Constructors 
      Constructor Description
      FileCollectionFormatter​(java.util.Collection files)
      Creates a new instance from a Collection of file names.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected static int getDepth​(java.lang.String directory)
      Returns the depth of the directory
      java.util.List getDirectories()
      Gets a list of Strings containing the directories in the file set, ordered by name.
      protected static java.lang.String getDirectory​(java.lang.String filename)
      Returns directory name of specified file
      java.util.List getFiles​(java.lang.String directory)
      Gets the names of all files which reside in a given directory.
      protected static java.lang.String getParent​(java.lang.String directory)
      Returns name of parent directory to specified directory
      protected static java.lang.String getRelativeFilename​(java.lang.String filename, java.lang.String dir)
      Returns relative filename for specified file and directory
      protected static boolean isInDirectory​(java.lang.String filename, java.lang.String directory)
      Returns TRUE if file is in specified directroy, FALSE otherwise
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileCollectionFormatter

        public FileCollectionFormatter​(java.util.Collection files)
        Creates a new instance from a Collection of file names.
        Parameters:
        files - Collection containing the String representations of files
    • Method Detail

      • getDirectories

        public java.util.List getDirectories()
        Gets a list of Strings containing the directories in the file set, ordered by name.
        Returns:
        a list of Strings containing the directories in the file set, ordered by name.
      • getFiles

        public java.util.List getFiles​(java.lang.String directory)
        Gets the names of all files which reside in a given directory. The directory must be one from the getDirectories() list. Files will be relative to the directory. They will be ordered by name.
        Parameters:
        directory - to process
        Returns:
        the names of all files which reside in a given directory. The directory must be one from the getDirectories() list. Files will be relative to the directory. They will be ordered by name.
      • isInDirectory

        protected static boolean isInDirectory​(java.lang.String filename,
                                               java.lang.String directory)
        Returns TRUE if file is in specified directroy, FALSE otherwise
        Parameters:
        filename - File to test
        directory - Directory to test
        Returns:
        boolean TRUE if file is in specified directroy, FALSE otherwise
      • getRelativeFilename

        protected static java.lang.String getRelativeFilename​(java.lang.String filename,
                                                              java.lang.String dir)
        Returns relative filename for specified file and directory
        Parameters:
        filename - file
        dir - directory
        Returns:
        String relative filename for specified file and directory
      • getDirectory

        protected static java.lang.String getDirectory​(java.lang.String filename)
        Returns directory name of specified file
        Parameters:
        filename - file to compute
        Returns:
        String directory name of specified file
      • getParent

        protected static java.lang.String getParent​(java.lang.String directory)
        Returns name of parent directory to specified directory
        Parameters:
        directory - to use
        Returns:
        String name of parent directory to specified directory
      • getDepth

        protected static int getDepth​(java.lang.String directory)
        Returns the depth of the directory
        Parameters:
        directory - to be analysed
        Returns:
        int the depth of the directory