Package org.jboss.windup.util
Class PathUtil
- java.lang.Object
-
- org.jboss.windup.util.PathUtil
-
public class PathUtil extends Object
Provides useful methods for manipulating filenames (eg, removing illegal chars from files).- Author:
- Jesse Sightler, Lincoln Baxter, III
-
-
Field Summary
Fields Modifier and Type Field Description static StringADDONS_DIRECTORY_NAMEstatic StringBINARY_DIRECTORY_NAMEstatic StringCACHE_DIRECTORY_NAMEstatic StringIGNORE_DIRECTORY_NAMEstatic StringLABELS_DIRECTORY_NAMEstatic StringLIBRARY_DIRECTORY_NAMEstatic StringRULES_DIRECTORY_NAMEstatic StringWINDUP_HOMEstatic StringWINDUP_LABELSETS_DIR_SYSPROPstatic StringWINDUP_RULESETS_DIR_SYSPROP
-
Constructor Summary
Constructors Constructor Description PathUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringclassFilePathToClassname(String relativePath)Converts a path to a class file (like "foo/bar/My.class" or "foo\\bar\\My.class") to a fully qualified class name (like "foo.bar.My").static StringcleanFileName(String badFileName)Conservative approach to insuring that a given filename only contains characters that are legal for use in filenames on the disk.static voidcreateDirectory(Path dir, String dirDesc)Creates the given directory.static PathgetRootFolderForSource(Path sourceFilePath, String packageName)Returns the root path for this source file, based upon the package name.static PathgetUserCacheDir()The path $USER_HOME/cachestatic PathgetUserIgnoreDir()The path $USER_HOME/ignorestatic PathgetUserLabelsDir()The path $USER_HOME/labelsstatic PathgetUserRulesDir()The path $USER_HOME/rulesstatic PathgetWindupAddonsDir()The path $WINDUP_HOME/addonsstatic PathgetWindupCacheDir()The path $WINDUP_HOME/cachestatic PathgetWindupHome()The path $WINDUP_HOME (where Windup is installed.)static PathgetWindupIgnoreDir()The path $WINDUP_HOME/ignorestatic PathgetWindupLabelsDir()The path $WINDUP_HOME/labelsstatic PathgetWindupRulesDir()The path $WINDUP_HOME/rulesstatic PathgetWindupUserDir()The path $USER_HOME/.windupstatic booleanisInSubDirectory(File dir, File file)Returns true if "file" is a subfile or subdirectory of "dir".static StringpathToPackageName(String relativePath)Attempts to convert a path name (possibly a path within an archive) to a package name.static voidsetWindupHome(Path windupHome)
-
-
-
Field Detail
-
WINDUP_HOME
public static final String WINDUP_HOME
- See Also:
- Constant Field Values
-
WINDUP_RULESETS_DIR_SYSPROP
public static final String WINDUP_RULESETS_DIR_SYSPROP
- See Also:
- Constant Field Values
-
WINDUP_LABELSETS_DIR_SYSPROP
public static final String WINDUP_LABELSETS_DIR_SYSPROP
- See Also:
- Constant Field Values
-
RULES_DIRECTORY_NAME
public static final String RULES_DIRECTORY_NAME
- See Also:
- Constant Field Values
-
LABELS_DIRECTORY_NAME
public static final String LABELS_DIRECTORY_NAME
- See Also:
- Constant Field Values
-
IGNORE_DIRECTORY_NAME
public static final String IGNORE_DIRECTORY_NAME
- See Also:
- Constant Field Values
-
CACHE_DIRECTORY_NAME
public static final String CACHE_DIRECTORY_NAME
- See Also:
- Constant Field Values
-
ADDONS_DIRECTORY_NAME
public static final String ADDONS_DIRECTORY_NAME
- See Also:
- Constant Field Values
-
LIBRARY_DIRECTORY_NAME
public static String LIBRARY_DIRECTORY_NAME
-
BINARY_DIRECTORY_NAME
public static String BINARY_DIRECTORY_NAME
-
-
Method Detail
-
getWindupUserDir
public static Path getWindupUserDir()
The path $USER_HOME/.windup
-
getWindupHome
public static Path getWindupHome()
The path $WINDUP_HOME (where Windup is installed.)
-
setWindupHome
public static void setWindupHome(Path windupHome)
-
getUserCacheDir
public static Path getUserCacheDir()
The path $USER_HOME/cache
-
getWindupCacheDir
public static Path getWindupCacheDir()
The path $WINDUP_HOME/cache
-
getUserIgnoreDir
public static Path getUserIgnoreDir()
The path $USER_HOME/ignore
-
getWindupIgnoreDir
public static Path getWindupIgnoreDir()
The path $WINDUP_HOME/ignore
-
getWindupAddonsDir
public static Path getWindupAddonsDir()
The path $WINDUP_HOME/addons
-
getUserRulesDir
public static Path getUserRulesDir()
The path $USER_HOME/rules
-
getUserLabelsDir
public static Path getUserLabelsDir()
The path $USER_HOME/labels
-
getWindupRulesDir
public static Path getWindupRulesDir()
The path $WINDUP_HOME/rules
-
getWindupLabelsDir
public static Path getWindupLabelsDir()
The path $WINDUP_HOME/labels
-
cleanFileName
public static String cleanFileName(String badFileName)
Conservative approach to insuring that a given filename only contains characters that are legal for use in filenames on the disk. Other characters are replaced with underscore _ . Note that this should only be used with the filename itself, not the entire path, because it removes the '/' characters as well.
-
classFilePathToClassname
public static String classFilePathToClassname(String relativePath)
Converts a path to a class file (like "foo/bar/My.class" or "foo\\bar\\My.class") to a fully qualified class name (like "foo.bar.My").
-
getRootFolderForSource
public static Path getRootFolderForSource(Path sourceFilePath, String packageName)
Returns the root path for this source file, based upon the package name.For example, if path is "/project/src/main/java/org/example/Foo.java" and the package is "org.example", then this should return "/project/src/main/java".
Returns null if the folder structure does not match the package name.
-
isInSubDirectory
public static boolean isInSubDirectory(File dir, File file)
Returns true if "file" is a subfile or subdirectory of "dir".For example with the directory /path/to/a, the following return values would occur:
/path/to/a/foo.txt - true /path/to/a/bar/zoo/boo/team.txt - true /path/to/b/foo.txt - false
-
pathToPackageName
public static String pathToPackageName(String relativePath)
Attempts to convert a path name (possibly a path within an archive) to a package name.
-
-