Package org.europa.together.application
Class PropertyFileReader
java.lang.Object
org.europa.together.application.PropertyFileReader
- All Implemented Interfaces:
PropertyReader
Implementation of the Property Reader.
-
Field Summary
Fields inherited from interface org.europa.together.business.PropertyReader
FEATURE_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addProperty
(String key, String value) Add a single property to the property list.boolean
addPropertyList
(Map<String, String> resource) Extend property list by Map<String, String>.boolean
appendPropertiesFromClasspath
(String resource) Load a property list from an given file inside the classpath.boolean
appendPropertiesFromFile
(String resource) Load a property list from an external file.boolean
clear()
Clear the entire property list.int
count()
Counts the amount of all properties and return the value.Get the value of a property as boolean.Allowed values are: 0 | 1 false | true FALSE | TRUE All other values will evaluate to null.Get the property value as Double.getPropertyAsFloat
(String key) Get the property value as Float.getPropertyAsInt
(String key) Get the value of a property as Integer.Get the property value as String.Get the full property list as Map.boolean
removeProperty
(String key) Remove a property by the given key from the list.boolean
updateProperty
(String key, String value) Update an existing property entry.
-
Constructor Details
-
PropertyFileReader
public PropertyFileReader()Constructor.
-
-
Method Details
-
addProperty
Description copied from interface:PropertyReader
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.- Specified by:
addProperty
in interfacePropertyReader
- Parameters:
key
- as Stringvalue
- as String- Returns:
- true on success
-
addPropertyList
Description copied from interface:PropertyReader
Extend property list by Map<String, String>.- Specified by:
addPropertyList
in interfacePropertyReader
- Parameters:
resource
- as Map- Returns:
- true on success
-
appendPropertiesFromClasspath
public boolean appendPropertiesFromClasspath(String resource) throws UnsupportedEncodingException, IOException Description copied from interface:PropertyReader
Load a property list from an given file inside the classpath. eg: org/europa/together/properties/file.properties- Specified by:
appendPropertiesFromClasspath
in interfacePropertyReader
- Parameters:
resource
- as String- Returns:
- true on success
- Throws:
IOException
UnsupportedEncodingException
-
appendPropertiesFromFile
Description copied from interface:PropertyReader
Load a property list from an external file. eg: /home/usr/application/file.properties- Specified by:
appendPropertiesFromFile
in interfacePropertyReader
- Parameters:
resource
- as String- Returns:
- true on success
- Throws:
IOException
-
clear
public boolean clear()Description copied from interface:PropertyReader
Clear the entire property list.- Specified by:
clear
in interfacePropertyReader
- Returns:
- true on success
-
removeProperty
Description copied from interface:PropertyReader
Remove a property by the given key from the list. If the property not exists the method return false.- Specified by:
removeProperty
in interfacePropertyReader
- Parameters:
key
- as String- Returns:
- true on success
-
updateProperty
Description copied from interface:PropertyReader
Update an existing property entry. In the case the entry don't exist, it will be created.- Specified by:
updateProperty
in interfacePropertyReader
- Parameters:
key
- as Stringvalue
- as String- Returns:
- true on success
-
count
public int count()Description copied from interface:PropertyReader
Counts the amount of all properties and return the value.- Specified by:
count
in interfacePropertyReader
- Returns:
- count of properties as int
-
getPropertyAsBoolean
Description copied from interface:PropertyReader
Get the value of a property as boolean.Allowed values are:- 0 | 1
- false | true
- FALSE | TRUE
- Specified by:
getPropertyAsBoolean
in interfacePropertyReader
- Parameters:
key
- as String- Returns:
- property as Boolean
- Throws:
MisconfigurationException
-
getPropertyAsDouble
Description copied from interface:PropertyReader
Get the property value as Double.- Specified by:
getPropertyAsDouble
in interfacePropertyReader
- Parameters:
key
- as String- Returns:
- property as Double
- Throws:
MisconfigurationException
-
getPropertyAsFloat
Description copied from interface:PropertyReader
Get the property value as Float.- Specified by:
getPropertyAsFloat
in interfacePropertyReader
- Parameters:
key
- as String- Returns:
- property as Float
- Throws:
MisconfigurationException
-
getPropertyAsInt
Description copied from interface:PropertyReader
Get the value of a property as Integer.- Specified by:
getPropertyAsInt
in interfacePropertyReader
- Parameters:
key
- as String- Returns:
- property as Integer
- Throws:
MisconfigurationException
-
getPropertyAsString
Description copied from interface:PropertyReader
Get the property value as String.- Specified by:
getPropertyAsString
in interfacePropertyReader
- Parameters:
key
- as String- Returns:
- property as String
- Throws:
MisconfigurationException
-
getPropertyList
Description copied from interface:PropertyReader
Get the full property list as Map.- Specified by:
getPropertyList
in interfacePropertyReader
- Returns:
- propertyList as Map
-