Class PropertiesRepository

java.lang.Object
com.github.joschi.jadconfig.repositories.PropertiesRepository
All Implemented Interfaces:
Repository

public class PropertiesRepository extends Object implements Repository
Repository class providing access to a configuration repository backed by Properties files
Author:
jschalanda
  • Constructor Details

    • PropertiesRepository

      public PropertiesRepository(String filename)
      Creates a new PropertiesRepository from the provided properties file filename
      Parameters:
      filename - The filename of the properties file
      Throws:
      IllegalArgumentException - If the provided filename is null or empty
    • PropertiesRepository

      public PropertiesRepository(File propertiesFile)
      Creates a new PropertiesRepository from the provided propertiesFile
      Parameters:
      propertiesFile - The properties File
      Throws:
      IllegalArgumentException - If the provided File is null
  • Method Details

    • open

      public void open() throws RepositoryException
      Opens the properties file and reads its Properties
      Specified by:
      open in interface Repository
      Throws:
      RepositoryException - If the propertiesFile is null, doesn't exist or an error occurred while reading the properties file.
    • read

      public String read(String name)
      Returns the value for a property name or null
      Specified by:
      read in interface Repository
      Parameters:
      name - The parameter name
      Returns:
      The property value for name or null
    • close

      public void close() throws RepositoryException
      Close the underlying properties file.
      Specified by:
      close in interface Repository
      Throws:
      RepositoryException
    • getPropertiesFile

      public File getPropertiesFile()
    • setPropertiesFile

      public void setPropertiesFile(File propertiesFile)