de.smartics.maven.exceptions.util
Class FileNameUtils

Package class diagram package FileNameUtils
java.lang.Object
  extended by de.smartics.maven.exceptions.util.FileNameUtils

public final class FileNameUtils
     
     
extends Object

Utilities to work on file names and files.


Method Summary
static String createPackageName(String dirName)
          Creates the package name for the given directory.
static String createPackageNames(org.apache.commons.logging.Log log, String rootDir, de.smartics.exceptions.report.scan.ScannerFactory scannerFactory)
          Creates package names from directory files found by the given scanner.
static boolean isArchive(String root)
          Checks if the given root refers to an archive or not.
static boolean isRootAccessible(String root)
          Checks if root points to a directory of file that is existing and readable.
static String normalizePath(String path)
          Returns the normalized path where duplicate slashes are removed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isArchive

public static boolean isArchive(String root)
                         throws NullPointerException
Checks if the given root refers to an archive or not. Simply the file extension is checked. Accessibility et al. is not considered.

Parameters:
root - the root to check.
Returns:
true if root refers to an archive file, false otherwise.
Throws:
NullPointerException - if root is null.

createPackageNames

public static String createPackageNames(org.apache.commons.logging.Log log,
                                        String rootDir,
                                        de.smartics.exceptions.report.scan.ScannerFactory scannerFactory)
                                 throws NullPointerException
Creates package names from directory files found by the given scanner.

Parameters:
log - the logger to log at debug level. No logging if log is null.
rootDir - the root directory to create a scanner on.
scannerFactory - the factory to create the scanner with the given rootDir.
Returns:
the package list. Package names are separated by a colon ( :) or the empty string if the root directory is not accessible (will be logged at debug level if log is not null.
Throws:
NullPointerException - if the rootDir or scannerFactory is null.

createPackageName

public static String createPackageName(String dirName)
                                throws IllegalArgumentException,
                                       NullPointerException
Creates the package name for the given directory.

Parameters:
dirName - the name of the directory that contains classes of a package. It is expected that the directory is relative to the source root directory.
Returns:
the package name for the directory.
Throws:
NullPointerException - if dirName is null.
IllegalArgumentException - if the directory is not valid as a package directory or if dirName is blank.

normalizePath

public static String normalizePath(String path)
Returns the normalized path where duplicate slashes are removed. If there is a slash (or backslash) in front, it is removed, too.

Parameters:
path - the path to normalize.
Returns:
the normalized path.

isRootAccessible

public static boolean isRootAccessible(String root)
                                throws NullPointerException
Checks if root points to a directory of file that is existing and readable.

Parameters:
root - the directory or file name to check.
Returns:
true if the directory of file exists, false otherwise.
Throws:
NullPointerException - if the root argument is null.


Copyright © 2007-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.