dev.dirs
public final class ProjectDirectories extends java.lang.Object
ProjectDirectories computes the location of cache, config or data directories for a specific application,
which are derived from the standard directories and the name of the project/organization.
ProjectDirectories instance created with the following information:
ProjectDirectories.from("com", "Foo Corp", "Bar App")
Example of configDir value in different operating systems:
/home/alice/.config/barapp/Users/Alice/Library/Preferences/com.Foo-Corp.Bar-AppC:\Users\Alice\AppData\Roaming\Foo Corp\Bar App| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
cacheDir
Returns the path to the project's cache directory,
in which
<project_path> is the value of projectPath. |
java.lang.String |
configDir
Returns the path to the project's configuration directory,
in which
<project_path> is the value of projectPath. |
java.lang.String |
dataDir
Returns the path to the project's data directory,
in which
<project_path> is the value of projectPath. |
java.lang.String |
dataLocalDir
Returns the path to the project's local data directory,
in which
<project_path> is the value of projectPath. |
java.lang.String |
preferenceDir
Returns the path to the project's preference directory,
in which
<project_path> is the value of projectPath. |
java.lang.String |
projectPath
Returns the project path fragment used to compute the project's cache/config/data directories.
|
java.lang.String |
runtimeDir
Returns the path to the project's runtime directory.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
static ProjectDirectories |
from(java.lang.String qualifier,
java.lang.String organization,
java.lang.String application)
Creates a
ProjectDirectories instance from values describing the project. |
static ProjectDirectories |
fromPath(java.lang.String path)
Creates a
ProjectDirectories instance directly from a path. |
int |
hashCode() |
java.lang.String |
toString() |
public final java.lang.String projectPath
The value is derived from the arguments provided to the from(java.lang.String, java.lang.String, java.lang.String) call and is platform-dependent.
public final java.lang.String cacheDir
<project_path> is the value of projectPath.
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | $XDG_CACHE_HOME/<project_path> or $HOME/.cache/<project_path> |
/home/alice/.cache/barapp |
| macOS | $HOME/Library/Caches/<project_path> |
/Users/Alice/Library/Caches/com.Foo-Corp.Bar-App |
| Windows | {FOLDERID_LocalAppData}\<project_path>\cache |
C:\Users\Alice\AppData\Local\Foo Corp\Bar App\cache |
public final java.lang.String configDir
<project_path> is the value of projectPath.
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | $XDG_CONFIG_HOME/<project_path> or $HOME/.config/<project_path> |
/home/alice/.config/barapp |
| macOS | $HOME/Library/Application Support/<project_path> |
/Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App |
| Windows | {FOLDERID_RoamingAppData}\<project_path>\config |
C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\config |
public final java.lang.String dataDir
<project_path> is the value of projectPath.
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | $XDG_DATA_HOME/<project_path> or $HOME/.local/share/<project_path> |
/home/alice/.local/share/barapp |
| macOS | $HOME/Library/Application Support/<project_path> |
/Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App |
| Windows | {FOLDERID_RoamingAppData}\<project_path>\data |
C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\data |
public final java.lang.String dataLocalDir
<project_path> is the value of projectPath.
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | $XDG_DATA_HOME/<project_path> or $HOME/.local/share/<project_path> |
/home/alice/.local/share/barapp |
| macOS | $HOME/Library/Application Support/<project_path> |
/Users/Alice/Library/Application Support/com.Foo-Corp.Bar-App |
| Windows | {FOLDERID_LocalAppData}\<project_path>\data |
C:\Users\Alice\AppData\Local\Foo Corp\Bar App\data |
public final java.lang.String preferenceDir
<project_path> is the value of projectPath.
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | $XDG_CONFIG_HOME/<project_path> or $HOME/.config/<project_path> |
/home/alice/.config/barapp |
| macOS | $HOME/Library/Preferences/<project_path> |
/Users/Alice/Library/Preferences/com.Foo-Corp.Bar-App |
| Windows | {FOLDERID_RoamingAppData}\<project_path>\config |
C:\Users\Alice\AppData\Roaming\Foo Corp\Bar App\config |
public final java.lang.String runtimeDir
| Platform | Value | Example |
|---|---|---|
| Linux/BSD | $XDG_RUNTIME_DIR |
/run/user/1001/barapp |
| macOS | – | null |
| Windows | – | null |
public static ProjectDirectories fromPath(java.lang.String path)
ProjectDirectories instance directly from a path.
The argument is used verbatim and is not adapted to operating system standards.
The use of fromPath(java.lang.String) is strongly discouraged, as its results will
not follow operating system standards on at least two of three platforms.
path - A string used verbatim as the path fragment to derive the directory field values.ProjectDirectories instance, whose directory field values are directly derived from the path argument.public static ProjectDirectories from(java.lang.String qualifier, java.lang.String organization, java.lang.String application)
ProjectDirectories instance from values describing the project.
The use of from(java.lang.String, java.lang.String, java.lang.String) – instead of fromPath(java.lang.String) – is strongly encouraged,
as its results will follow operating system standards on Linux, macOS and Windows.
qualifier - The reverse domain name notation of the application, excluding the
organization or application name itself."com.example", "org", "uk.co", "io", ""organization - The name of the organization that develops this application, or for which
the application is developed."Foo Corp", "Alice and Bob Inc", ""application - The name of the application itself."Bar App", "ExampleProgram", "Unicorn-Programme"ProjectDirectories, whose directory field values are based on the
qualifier, organization and application arguments.public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object