Interface PropertyReader

All Known Implementing Classes:
PropertyFileReader

@API(status=STABLE, since="1.0", consumers="PropertyFileReader") @Component public interface PropertyReader
The PropertyReader is able to read properties from different resources like file, database or from the classpath. It is also possible to manipulate the property list. The key feature are the different cast methods for the property values to load them into the correct datatype.

A property set contains for each line a key=value pair. Comments starts with the # character.
Since:
1.0
Version:
1.2
Author:
elmar.dott@gmail.com
  • Field Details

    • FEATURE_ID

      @API(status=STABLE, since="1.2") static final String FEATURE_ID
      Identifier for the given feature.
      See Also:
  • Method Details

    • addProperty

      @API(status=STABLE, since="1.0") boolean addProperty(String key, String value)
      Add a single property to the property list. If the property already exist in the list, the new entry will not added and the method return FALSE.
      Parameters:
      key - as String
      value - as String
      Returns:
      true on success
    • addPropertyList

      @API(status=STABLE, since="1.0") boolean addPropertyList(Map<String,String> propertyList)
      Extend property list by Map<String, String>.
      Parameters:
      propertyList - as Map
      Returns:
      true on success
    • appendPropertiesFromClasspath

      @API(status=STABLE, since="3.0") boolean appendPropertiesFromClasspath(String resource) throws IOException
      Load a property list from an given file inside the classpath. eg: org/europa/together/properties/file.properties
      Parameters:
      resource - as String
      Returns:
      true on success
      Throws:
      IOException
    • appendPropertiesFromFile

      @API(status=STABLE, since="3.0") boolean appendPropertiesFromFile(String resource) throws IOException
      Load a property list from an external file. eg: /home/usr/application/file.properties
      Parameters:
      resource - as String
      Returns:
      true on success
      Throws:
      IOException
    • clear

      @API(status=STABLE, since="1.0") boolean clear()
      Clear the entire property list.
      Returns:
      true on success
    • removeProperty

      @API(status=STABLE, since="1.0") boolean removeProperty(String key)
      Remove a property by the given key from the list. If the property not exists the method return false.
      Parameters:
      key - as String
      Returns:
      true on success
    • updateProperty

      @API(status=STABLE, since="1.0") boolean updateProperty(String key, String value)
      Update an existing property entry. In the case the entry don't exist, it will be created.
      Parameters:
      key - as String
      value - as String
      Returns:
      true on success
    • count

      @API(status=STABLE, since="1.0") int count()
      Counts the amount of all properties and return the value.
      Returns:
      count of properties as int
    • getPropertyAsBoolean

      @API(status=STABLE, since="1.0") Boolean getPropertyAsBoolean(String key) throws MisconfigurationException
      Get the value of a property as boolean.Allowed values are:
      • 0 | 1
      • false | true
      • FALSE | TRUE
      All other values will evaluate to null.
      Parameters:
      key - as String
      Returns:
      property as Boolean
      Throws:
      MisconfigurationException
    • getPropertyAsDouble

      @API(status=STABLE, since="1.0") Double getPropertyAsDouble(String key) throws MisconfigurationException
      Get the property value as Double.
      Parameters:
      key - as String
      Returns:
      property as Double
      Throws:
      MisconfigurationException
    • getPropertyAsFloat

      @API(status=STABLE, since="1.0") Float getPropertyAsFloat(String key) throws MisconfigurationException
      Get the property value as Float.
      Parameters:
      key - as String
      Returns:
      property as Float
      Throws:
      MisconfigurationException
    • getPropertyAsInt

      @API(status=STABLE, since="1.0") Integer getPropertyAsInt(String key) throws MisconfigurationException
      Get the value of a property as Integer.
      Parameters:
      key - as String
      Returns:
      property as Integer
      Throws:
      MisconfigurationException
    • getPropertyAsString

      @API(status=STABLE, since="1.0") String getPropertyAsString(String key) throws MisconfigurationException
      Get the property value as String.
      Parameters:
      key - as String
      Returns:
      property as String
      Throws:
      MisconfigurationException
    • getPropertyList

      @API(status=STABLE, since="1.0") Map<String,String> getPropertyList() throws MisconfigurationException
      Get the full property list as Map.
      Returns:
      propertyList as Map
      Throws:
      MisconfigurationException