Class Information
Package: com.onepg.util
Class Name: PropertiesUtil
Description
Properties file utility class.
- The properties file extension is .properties. (Others are ignored)
- The properties file storage directory (hereinafter, configuration directory) is the config
directory directly under the application deployment directory, and is fixed relative to the application deployment directory.
[Example] For application/lib/program.jar, it is under application/config/.
For details on the application deployment directory, refer to#APPLICATION_DIR_PATH. - Normally, the configuration directory path is as described above, but if you want to change the path, specify the path with the configuration key CONFIG_DIR in config/config.properties.
- The character set of the properties file is assumed to be UTF-8.
- The content of the properties file lists configuration keys and values as shown in the example below.
KEY1=VAL1
KEY2=VAL2
KEY3=VAL3 - The properties file name is flexible, but the following file names are reserved for framework components and cannot be used.
web.properties
bat.properties
db.properties
config.properties - The number of properties files is flexible, but configuration keys must be unique across properties files. (Duplication with framework component properties files is acceptable)
- If the configuration value is enclosed in ${ and }, it is replaced with the value of the enclosed environment variable. (Partial replacement is also possible)
However, if the environment variable does not exist, a system error occurs.
[Example Windows environment]${USERNAME}is replaced with the current user name.
[Example Linux environment]${USER}is replaced with the current user name. - $ApplicationDirPath in the configuration value is replaced with the application deployment directory path. (Partial replacement is also possible)
For details on the application deployment directory, refer to#APPLICATION_DIR_PATH. - $TemporaryDirPath in the configuration value is replaced with the OS temporary directory path. (Partial replacement is also possible)
Specifically, it replaces the path of Java's java.io.tmpdir system property. - Configuration values starting with <ConvertAbsolutePath> are converted to absolute paths.
- Lines starting with # in the properties file
are ignored as comments. (Specification of
Properties#load(java.io.InputStream)) - This class does not handle writing to properties files.
Enumeration List
FwPropertiesName
public enum FwPropertiesName
Framework-reserved properties file name.
Constants
WEBBATDBLOGPROPDIR
Constants and Variables
LOCALHOST_NAME
public String LOCALHOST_NAME
Local host name.
APPLICATION_DIR_PATH
public String APPLICATION_DIR_PATH
Application deployment directory path.
- The application deployment directory refers to one of the following directories.
- Two directories above the Java class file deployment root directory (such as com or jp)
[Example] For appdeploy/classes/com/onepg/Program.class, it is appdeploy - Two directories above the Jar file deployment directory
[Example] For appdeploy/lib/program.jar, it is appdeploy
- Two directories above the Java class file deployment root directory (such as com or jp)
MODULE_PROP_MAP
public IoItems MODULE_PROP_MAP
Module configuration.
- Returns configuration values from properties files under the configuration directory as a map.
- Excludes framework-reserved properties files.
- The number of properties files is flexible, but configuration keys must be unique across properties files.
[Example] final String value = PropertiesUtil.MODULE_PROP_MAP.getString("module.unique.key");
Method List
getFrameworkProps
public IoItems getFrameworkProps(FwPropertiesName propFileName)
Gets framework configuration.
Parameters
| Name | Type | Description |
|---|---|---|
propFileName |
FwPropertiesName |
properties file name |
Return Value
IoItems - configuration value map
isWindowsOs
public boolean isWindowsOs()
Checks MS-Windows OS.
Return Value
boolean - true if Windows OS