Gridarta Editor
|
Static Public Member Functions | |
static String | absoluteToRelative (@NotNull final String reference, @NotNull final String absolute) |
static String | getAbsolutePath (@NotNull final CharSequence path) |
static String | getMapPath (@NotNull final File file, @NotNull final File baseDir) |
static boolean | isAbsolute (@NotNull final String path) |
static boolean | isRelative (@NotNull final String path) |
static String | path (@NotNull final CharSequence str) |
static String | relativeToAbsolute (@NotNull final String reference, @NotNull final String relative) |
Private Member Functions | |
PathManagerUtils () | |
Static Private Member Functions | |
static int | findDifference (@NotNull final CharSequence s1, @NotNull final CharSequence s2) |
static int | findOccurrences (@NotNull final CharSequence s, final char c) |
Static Private Attributes | |
static final Pattern | PATTERN_REDUNDANT = Pattern.compile("[^/]+/\\.\\./") |
static final Pattern | PATTERN_SLASHES = Pattern.compile("//*") |
Utility class for converting relative map paths to absolute map paths and vice versa.
Definition at line 31 of file PathManagerUtils.java.
|
private |
Private constructor to prevent instantiation.
Definition at line 48 of file PathManagerUtils.java.
|
static |
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.
reference | the reference file the relative path works on |
absolute | destination file with relative path |
Definition at line 137 of file PathManagerUtils.java.
References net.sf.gridarta.utils.PathManagerUtils.findDifference(), net.sf.gridarta.utils.PathManagerUtils.findOccurrences(), and net.sf.gridarta.utils.PathManagerUtils.isRelative().
Referenced by net.sf.gridarta.gui.map.maptilepane.TilePanel.RASwitch.actionPerformed(), and net.sf.gridarta.utils.PathManagerUtilsTest.testAbsoluteToRelative().
|
staticprivate |
Helper method that returns the first string index at which two strings denoting paths aren't identical. That is, the index always points at the beginning or a '/'-character. The return value of this method is in every case good for a String.substring() invocation start index.
s1 | first string to compare |
s2 | second string to compare |
Definition at line 165 of file PathManagerUtils.java.
Referenced by net.sf.gridarta.utils.PathManagerUtils.absoluteToRelative().
|
staticprivate |
Counts the occurrences of a character within a string.
s | the string to count in |
c | character to count |
Definition at line 189 of file PathManagerUtils.java.
Referenced by net.sf.gridarta.utils.PathManagerUtils.absoluteToRelative().
|
static |
Returns the given path in absolute form.
path | the path to convert |
Definition at line 219 of file PathManagerUtils.java.
References net.sf.gridarta.utils.PathManagerUtils.path(), and net.sf.gridarta.utils.PathManagerUtils.relativeToAbsolute().
Referenced by net.sf.gridarta.utils.PathManagerUtils.getMapPath().
|
static |
Returns a relative path path for a File.
file | the file |
baseDir | the base directory to relativize against |
Definition at line 58 of file PathManagerUtils.java.
References net.sf.gridarta.utils.PathManagerUtils.getAbsolutePath().
Referenced by net.sf.gridarta.model.io.PathManager.getMapPath(), net.sf.gridarta.gui.utils.JFileField.getRelativeFile(), and net.sf.gridarta.plugin.parameter.AbstractPathParameter< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setFile().
|
static |
Check whether a path is absolute. Paths starting with "/" are absolute, paths starting with other characters are relative. Empty paths are relative.
path | the path to check |
Definition at line 86 of file PathManagerUtils.java.
References net.sf.gridarta.utils.PathManagerUtils.path().
Referenced by net.sf.gridarta.utils.PathManagerUtils.relativeToAbsolute(), and net.sf.gridarta.utils.PathManagerUtilsTest.testIsAbsolute().
|
static |
Check whether a path is relative. Paths not starting with "/" are relative, paths starting with are absolute. Empty paths are relative.
path | the path to check |
Definition at line 97 of file PathManagerUtils.java.
References net.sf.gridarta.utils.PathManagerUtils.path().
Referenced by net.sf.gridarta.utils.PathManagerUtils.absoluteToRelative(), net.sf.gridarta.utils.PathManagerUtilsTest.testIsRelative(), and net.sf.gridarta.gui.map.maptilepane.TilePanel.RASwitch.updateRAState().
|
static |
Creates a reasonable path.
str | the string to create path from |
Definition at line 205 of file PathManagerUtils.java.
References net.sf.gridarta.utils.StringUtils.PATTERN_BACKSLASH, and net.sf.gridarta.utils.PathManagerUtils.PATTERN_SLASHES.
Referenced by net.sf.gridarta.utils.PathManagerUtils.getAbsolutePath(), net.sf.gridarta.utils.PathManagerUtils.isAbsolute(), net.sf.gridarta.utils.PathManagerUtils.isRelative(), net.sf.gridarta.utils.AppPreferencesModel.setClient(), net.sf.gridarta.utils.AppPreferencesModel.setEditor(), net.sf.gridarta.utils.AppPreferencesModel.setServer(), and net.sf.gridarta.utils.PathManagerUtilsTest.testPath().
|
static |
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.
reference | the reference file the relative path works on |
relative | destination file with relative path |
Definition at line 111 of file PathManagerUtils.java.
References net.sf.gridarta.utils.PathManagerUtils.isAbsolute(), and net.sf.gridarta.utils.PathManagerUtils.PATTERN_REDUNDANT.
Referenced by net.sf.gridarta.gui.map.maptilepane.TilePanel.RASwitch.actionPerformed(), net.sf.gridarta.utils.PathManagerUtils.getAbsolutePath(), and net.sf.gridarta.utils.PathManagerUtilsTest.testRelativeToAbsolute().
|
staticprivate |
A Pattern that matches redundant directory parts like "dir/../".
Definition at line 37 of file PathManagerUtils.java.
Referenced by net.sf.gridarta.utils.PathManagerUtils.relativeToAbsolute().
|
staticprivate |
A Pattern that matches redundant directory separators.
Definition at line 43 of file PathManagerUtils.java.
Referenced by net.sf.gridarta.utils.PathManagerUtils.path().