Class EnvironmentRepository
java.lang.Object
com.github.joschi.jadconfig.repositories.EnvironmentRepository
- All Implemented Interfaces:
Repository
Repository class providing access to environment variables.
All keys are being looked up in upper case unless deactivated with the appropriate
constructor (EnvironmentRepository(boolean).
A prefix for all key lookups can be defined with EnvironmentRepository(String).
The default prefix is empty.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance ofEnvironmentRepositorywith the default settings, i. e. no prefix and keys looked up in upper case.EnvironmentRepository(boolean upperCase) Creates a new instance ofEnvironmentRepositorywith an empty prefix.EnvironmentRepository(String prefix) Creates a new instance ofEnvironmentRepositorywith the given prefix.EnvironmentRepository(String prefix, boolean upperCase) Creates a new instance ofEnvironmentRepositorywith the given prefix. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the underlying data source when it isn't require any more.voidopen()Opens the configuration repository, e. g. create a database connection, open a file on disk for readingReads the configuration parameter name from the backing data source.intsize()
-
Constructor Details
-
EnvironmentRepository
public EnvironmentRepository()Creates a new instance ofEnvironmentRepositorywith the default settings, i. e. no prefix and keys looked up in upper case. -
EnvironmentRepository
Creates a new instance ofEnvironmentRepositorywith the given prefix.- Parameters:
prefix- The prefix used for key lookups, e. g."MY_APP_".
-
EnvironmentRepository
public EnvironmentRepository(boolean upperCase) Creates a new instance ofEnvironmentRepositorywith an empty prefix.- Parameters:
upperCase- Whether keys should be looked up in upper case.
-
EnvironmentRepository
Creates a new instance ofEnvironmentRepositorywith the given prefix.- Parameters:
prefix- The prefix used for key lookups, e. g."MY_APP_".upperCase- Whether keys should be looked up in upper case.
-
-
Method Details
-
open
Description copied from interface:RepositoryOpens the configuration repository, e. g. create a database connection, open a file on disk for reading- Specified by:
openin interfaceRepository- Throws:
RepositoryException- If an error occurred while opening the data source
-
read
Description copied from interface:RepositoryReads the configuration parameter name from the backing data source. The name is specific to the underlying data source.- Specified by:
readin interfaceRepository- Parameters:
name- The parameter name- Returns:
- The value of the provided name as
String
-
close
Description copied from interface:RepositoryCloses the underlying data source when it isn't require any more.- Specified by:
closein interfaceRepository- Throws:
RepositoryException- If an error occurred while closing the underlying data source
-
size
public int size()
-