Class PropertiesRepository
java.lang.Object
com.github.joschi.jadconfig.repositories.PropertiesRepository
- All Implemented Interfaces:
Repository
Repository class providing access to a configuration repository backed by Properties files- Author:
- jschalanda
-
Constructor Summary
ConstructorsConstructorDescriptionPropertiesRepository(File propertiesFile) Creates a newPropertiesRepositoryfrom the provided propertiesFilePropertiesRepository(String filename) Creates a newPropertiesRepositoryfrom the provided properties file filename -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the underlying properties file.voidopen()Opens the properties file and reads itsPropertiesReturns the value for a property name or nullvoidsetPropertiesFile(File propertiesFile)
-
Constructor Details
-
PropertiesRepository
Creates a newPropertiesRepositoryfrom the provided properties file filename- Parameters:
filename- The filename of the properties file- Throws:
IllegalArgumentException- If the provided filename is null or empty
-
PropertiesRepository
Creates a newPropertiesRepositoryfrom the provided propertiesFile- Parameters:
propertiesFile- The propertiesFile- Throws:
IllegalArgumentException- If the providedFileis null
-
-
Method Details
-
open
Opens the properties file and reads itsProperties- Specified by:
openin interfaceRepository- Throws:
RepositoryException- If the propertiesFile is null, doesn't exist or an error occurred while reading the properties file.
-
read
Returns the value for a property name or null- Specified by:
readin interfaceRepository- Parameters:
name- The parameter name- Returns:
- The property value for name or null
-
close
Close the underlying properties file.- Specified by:
closein interfaceRepository- Throws:
RepositoryException
-
getPropertiesFile
-
setPropertiesFile
-