public final class ConfigFileReader extends Object
Simple implementation to read OCI configuration files.
Note, config files MUST contain a "DEFAULT" profile, else validation will fail. Additional profiles are optional.
Modifier and Type | Class and Description |
---|---|
static class |
ConfigFileReader.ConfigFile
ConfigFile represents a simple lookup mechanism for a OCI config file.
|
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_FILE_PATH
Default location of the config file.
|
static String |
FALLBACK_DEFAULT_FILE_PATH
The fallback default location of the config file.
|
static String |
OCI_CONFIG_FILE_PATH_ENV_VAR_NAME
Environment variable name for the config file location
|
Modifier and Type | Method and Description |
---|---|
static ConfigFileReader.ConfigFile |
parse(InputStream configurationStream,
String profile)
Create a new instance using an UTF-8 input stream.
|
static ConfigFileReader.ConfigFile |
parse(InputStream configurationStream,
String profile,
Charset charset)
Create a new instance using an input stream.
|
static ConfigFileReader.ConfigFile |
parse(String configurationFilePath)
Create a new instance using a file at a given location.
|
static ConfigFileReader.ConfigFile |
parse(String configurationFilePath,
String profile)
Create a new instance using a file at a given location.
|
static ConfigFileReader.ConfigFile |
parseDefault()
Creates a new ConfigFile instance using the configuration at the default location, using the
default profile.
|
static ConfigFileReader.ConfigFile |
parseDefault(String profile)
Creates a new ConfigFile instance using the configuration at the default location, using the
given profile.
|
public static final String DEFAULT_FILE_PATH
Default location of the config file.
public static final String FALLBACK_DEFAULT_FILE_PATH
The fallback default location of the config file. If and only if the DEFAULT_FILE_PATH
does not exist, this fallback default location will be used.
public static final String OCI_CONFIG_FILE_PATH_ENV_VAR_NAME
Environment variable name for the config file location
public static ConfigFileReader.ConfigFile parseDefault() throws IOException
Creates a new ConfigFile instance using the configuration at the default location, using the
default profile. See DEFAULT_FILE_PATH
.
IOException
- if the file could not be read.public static ConfigFileReader.ConfigFile parseDefault(@Nullable String profile) throws IOException
Creates a new ConfigFile instance using the configuration at the default location, using the
given profile. See DEFAULT_FILE_PATH
.
profile
- The profile name to load, or null if you want to load the “DEFAULT” profile.IOException
- if the file could not be read.public static ConfigFileReader.ConfigFile parse(String configurationFilePath) throws IOException
Create a new instance using a file at a given location.
This method is the same as calling parse(String, String)
with "DEFAULT" as the
profile.
configurationFilePath
- The path to the config file.IOException
- if the file could not be read.public static ConfigFileReader.ConfigFile parse(String configurationFilePath, @Nullable String profile) throws IOException
Create a new instance using a file at a given location.
configurationFilePath
- The path to the config file.profile
- The profile name to load, or null if you want to load the “DEFAULT” profile.IOException
- if the file could not be read.public static ConfigFileReader.ConfigFile parse(InputStream configurationStream, @Nullable String profile) throws IOException
Create a new instance using an UTF-8 input stream.
configurationStream
- The path to the config file.profile
- The profile name to load, or null if you want to load the “DEFAULT” profile.IOException
- if the file could not be read.public static ConfigFileReader.ConfigFile parse(InputStream configurationStream, @Nullable String profile, @Nonnull Charset charset) throws IOException
Create a new instance using an input stream.
configurationStream
- The path to the config file.profile
- The profile name to load, or null if you want to load the “DEFAULT” profile.charset
- The charset used when parsing the input streamIOException
- if the file could not be read.Copyright © 2016–2024. All rights reserved.