|
Gridarta Editor
|
Utility class for converting relative map paths to absolute map paths and vice versa. More...
Collaboration diagram for net.sf.gridarta.model.io.PathManagerUtils:Static Public Member Functions | |
| static String | absoluteToRelative (@NotNull final String reference, @NotNull final String absolute) |
| Converts an absolute path to a relative path. More... | |
| static String | getAbsolutePath (@NotNull final CharSequence path) |
| Returns the given path in absolute form. More... | |
| static String | getMapPath (@NotNull final File file, @NotNull final File baseDir) |
| Returns a relative path path for a File. More... | |
| static boolean | isAbsolute (@NotNull final String path) |
| Check whether a path is absolute. More... | |
| static boolean | isRelative (@NotNull final String path) |
| Check whether a path is relative. More... | |
| static String | path (@NotNull final CharSequence str) |
| Create a reasonable path. More... | |
| static String | relativeToAbsolute (@NotNull final String reference, @NotNull final String relative) |
| Converts a relative path to an absolute path. More... | |
Private Member Functions | |
| PathManagerUtils () | |
| Private constructor to prevent instantiation. More... | |
Static Private Member Functions | |
| static int | findDifference (@NotNull final CharSequence s1, @NotNull final CharSequence s2) |
| Helper method that returns the first string index at which two strings denoting paths aren't identical. More... | |
| static int | findOccurrences (@NotNull final CharSequence s, final char c) |
| Counts the occurrences of a character within a string. More... | |
Static Private Attributes | |
| static final Pattern | PATTERN_REDUNDANT = Pattern.compile("[^/]+/\\.\\./") |
| A Pattern that matches redundant directory parts like "dir/../". More... | |
| static final Pattern | PATTERN_SLASHES = Pattern.compile("//*") |
| A Pattern that matches redundant directory separators. More... | |
Utility class for converting relative map paths to absolute map paths and vice versa.
Definition at line 32 of file PathManagerUtils.java.
|
private |
Private constructor to prevent instantiation.
Definition at line 49 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.model.io.PathManagerUtils.findDifference(), net.sf.gridarta.model.io.PathManagerUtils.findOccurrences(), and net.sf.gridarta.model.io.PathManagerUtils.isRelative().
Referenced by net.sf.gridarta.gui.map.maptilepane.TilePanel.RASwitch.actionPerformed(), and net.sf.gridarta.model.io.PathManagerUtilsTest.testAbsoluteToRelative().
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 164 of file PathManagerUtils.java.
Referenced by net.sf.gridarta.model.io.PathManagerUtils.absoluteToRelative().
Here is the caller graph for this function:
|
staticprivate |
Counts the occurrences of a character within a string.
| s | the string to count in |
| c | character to count |
Definition at line 188 of file PathManagerUtils.java.
Referenced by net.sf.gridarta.model.io.PathManagerUtils.absoluteToRelative().
Here is the caller graph for this function:
|
static |
Returns the given path in absolute form.
| path | the path to convert |
Definition at line 218 of file PathManagerUtils.java.
References net.sf.gridarta.model.io.PathManagerUtils.path(), and net.sf.gridarta.model.io.PathManagerUtils.relativeToAbsolute().
Referenced by net.sf.gridarta.model.io.PathManagerUtils.getMapPath().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Returns a relative path path for a File.
| file | the file |
| baseDir | the base directory to relativize against |
Definition at line 59 of file PathManagerUtils.java.
References net.sf.gridarta.model.io.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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 87 of file PathManagerUtils.java.
Referenced by net.sf.gridarta.model.io.PathManagerUtils.relativeToAbsolute(), and net.sf.gridarta.model.io.PathManagerUtilsTest.testIsAbsolute().
Here is the caller graph for this function:
|
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 98 of file PathManagerUtils.java.
Referenced by net.sf.gridarta.model.io.PathManagerUtils.absoluteToRelative(), net.sf.gridarta.model.io.PathManagerUtilsTest.testIsRelative(), and net.sf.gridarta.gui.map.maptilepane.TilePanel.RASwitch.updateRAState().
Here is the caller graph for this function:
|
static |
Create a reasonable path.
| str | the string to create path from |
Definition at line 204 of file PathManagerUtils.java.
References net.sf.gridarta.utils.StringUtils.PATTERN_BACKSLASH.
Referenced by net.sf.gridarta.model.io.PathManagerUtils.getAbsolutePath(), net.sf.gridarta.gui.dialog.prefs.AppPreferencesModel.setClient(), net.sf.gridarta.gui.dialog.prefs.AppPreferencesModel.setEditor(), net.sf.gridarta.gui.dialog.prefs.AppPreferencesModel.setServer(), and net.sf.gridarta.model.io.PathManagerUtilsTest.testPath().
Here is the caller graph for this function:
|
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 112 of file PathManagerUtils.java.
References net.sf.gridarta.model.io.PathManagerUtils.isAbsolute().
Referenced by net.sf.gridarta.gui.map.maptilepane.TilePanel.RASwitch.actionPerformed(), net.sf.gridarta.model.io.PathManagerUtils.getAbsolutePath(), and net.sf.gridarta.model.io.PathManagerUtilsTest.testRelativeToAbsolute().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
A Pattern that matches redundant directory parts like "dir/../".
Definition at line 38 of file PathManagerUtils.java.
|
staticprivate |
A Pattern that matches redundant directory separators.
Definition at line 44 of file PathManagerUtils.java.