Package net.sf.gridarta.utils
Class PathManagerUtils
- java.lang.Object
-
- net.sf.gridarta.utils.PathManagerUtils
-
public class PathManagerUtils extends java.lang.ObjectUtility class for converting relative map paths to absolute map paths and vice versa.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @NotNull java.lang.StringabsoluteToRelative(@NotNull java.lang.String reference, @NotNull java.lang.String absolute)Converts an absolute path to a relative path.static @NotNull java.lang.StringgetAbsolutePath(@NotNull java.lang.CharSequence path)Returns the given path in absolute form.static @NotNull java.lang.StringgetMapPath(@NotNull java.io.File file, @NotNull java.io.File baseDir)Returns a relative path path for aFile.static booleanisAbsolute(@NotNull java.lang.String path)Check whether a path is absolute.static booleanisRelative(@NotNull java.lang.String path)Check whether a path is relative.static @NotNull java.lang.Stringpath(@NotNull java.lang.CharSequence str)Creates a reasonable path.static @NotNull java.lang.StringrelativeToAbsolute(@NotNull java.lang.String reference, @NotNull java.lang.String relative)Converts a relative path to an absolute path.
-
-
-
Method Detail
-
getMapPath
@NotNull public static @NotNull java.lang.String getMapPath(@NotNull @NotNull java.io.File file, @NotNull @NotNull java.io.File baseDir)Returns a relative path path for aFile.- Parameters:
file- the filebaseDir- the base directory to relativize against- Returns:
- the relative path
-
isAbsolute
public static boolean isAbsolute(@NotNull @NotNull java.lang.String path)Check whether a path is absolute. Paths starting with "/" are absolute, paths starting with other characters are relative. Empty paths are relative.- Parameters:
path- the path to check- Returns:
trueifpathis absolute,falseotherwise- See Also:
which nearly is the opposite of this method
-
isRelative
public static boolean isRelative(@NotNull @NotNull java.lang.String path)Check whether a path is relative. Paths not starting with "/" are relative, paths starting with are absolute. Empty paths are relative.- Parameters:
path- the path to check- Returns:
trueifpathis relative,falseotherwise- See Also:
which nearly is the opposite of this method
-
relativeToAbsolute
@NotNull public static @NotNull java.lang.String relativeToAbsolute(@NotNull @NotNull java.lang.String reference, @NotNull @NotNull java.lang.String relative)Converts a relative path to an absolute path. If the path already is absolute, this method simply returns the path. If the reference ends on "/", it is treated as being a base directory, otherwise a file that's directory is taken as base.- Parameters:
reference- the reference file the relative path works onrelative- destination file with relative path- Returns:
- absolute path from the base directory
-
absoluteToRelative
@NotNull public static @NotNull java.lang.String absoluteToRelative(@NotNull @NotNull java.lang.String reference, @NotNull @NotNull java.lang.String absolute)Converts an absolute path to a relative path. If the path already is relative, this method simply returns the path. If the reference ends on "/", it is treated as being a base directory, otherwise a file that's directory is taken as base.- Parameters:
reference- the reference file the relative path works onabsolute- destination file with relative path- Returns:
- absolute path from the base directory
-
path
@NotNull public static @NotNull java.lang.String path(@NotNull @NotNull java.lang.CharSequence str)Creates a reasonable path.- Parameters:
str- the string to create path from- Returns:
- path
-
getAbsolutePath
@NotNull public static @NotNull java.lang.String getAbsolutePath(@NotNull @NotNull java.lang.CharSequence path)Returns the given path in absolute form.- Parameters:
path- the path to convert- Returns:
- the absolute path
-
-