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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddProperty(String key, String value) Add a single property to the property list.booleanaddPropertyList(Map<String, String> resource) Extend property list by Map<String, String>.booleanappendPropertiesFromClasspath(String resource) Load a property list from an given file inside the classpath. eg: org/europa/together/properties/file.propertiesbooleanappendPropertiesFromFile(String resource) Load a property list from an external file. eg: /home/usr/application/file.propertiesbooleanclear()Clear the entire property list.intcount()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.booleanremoveProperty(String key) Remove a property by the given key from the list.booleanupdateProperty(String key, String value) Update an existing property entry.
-
Constructor Details
-
PropertyFileReader
public PropertyFileReader()Constructor.
-
-
Method Details
-
addProperty
Description copied from interface:PropertyReaderAdd 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:
addPropertyin interfacePropertyReader- Parameters:
key- as Stringvalue- as String- Returns:
- true on success
-
addPropertyList
Description copied from interface:PropertyReaderExtend property list by Map<String, String>.- Specified by:
addPropertyListin interfacePropertyReader- Parameters:
resource- as Map- Returns:
- true on success
-
appendPropertiesFromClasspath
public boolean appendPropertiesFromClasspath(String resource) throws UnsupportedEncodingException, IOException Description copied from interface:PropertyReaderLoad a property list from an given file inside the classpath. eg: org/europa/together/properties/file.properties- Specified by:
appendPropertiesFromClasspathin interfacePropertyReader- Parameters:
resource- as String- Returns:
- true on success
- Throws:
IOException- case of errorUnsupportedEncodingException
-
appendPropertiesFromFile
Description copied from interface:PropertyReaderLoad a property list from an external file. eg: /home/usr/application/file.properties- Specified by:
appendPropertiesFromFilein interfacePropertyReader- Parameters:
resource- as String- Returns:
- true on success
- Throws:
IOException- case of error
-
clear
public boolean clear()Description copied from interface:PropertyReaderClear the entire property list.- Specified by:
clearin interfacePropertyReader- Returns:
- true on success
-
removeProperty
Description copied from interface:PropertyReaderRemove a property by the given key from the list. If the property not exists the method return false.- Specified by:
removePropertyin interfacePropertyReader- Parameters:
key- as String- Returns:
- true on success
-
updateProperty
Description copied from interface:PropertyReaderUpdate an existing property entry. In the case the entry don't exist, it will be created.- Specified by:
updatePropertyin interfacePropertyReader- Parameters:
key- as Stringvalue- as String- Returns:
- true on success
-
count
public int count()Description copied from interface:PropertyReaderCounts the amount of all properties and return the value.- Specified by:
countin interfacePropertyReader- Returns:
- count of properties as int
-
getPropertyAsBoolean
Description copied from interface:PropertyReaderGet the value of a property as boolean.Allowed values are:
- 0 | 1
- false | true
- FALSE | TRUE
All other values will evaluate to null.- Specified by:
getPropertyAsBooleanin interfacePropertyReader- Parameters:
key- as String- Returns:
- property as Boolean
- Throws:
MisconfigurationException- case of error
-
getPropertyAsDouble
Description copied from interface:PropertyReaderGet the property value as Double.- Specified by:
getPropertyAsDoublein interfacePropertyReader- Parameters:
key- as String- Returns:
- property as Double
- Throws:
MisconfigurationException- case of error
-
getPropertyAsFloat
Description copied from interface:PropertyReaderGet the property value as Float.- Specified by:
getPropertyAsFloatin interfacePropertyReader- Parameters:
key- as String- Returns:
- property as Float
- Throws:
MisconfigurationException- case of error
-
getPropertyAsInt
Description copied from interface:PropertyReaderGet the value of a property as Integer.- Specified by:
getPropertyAsIntin interfacePropertyReader- Parameters:
key- as String- Returns:
- property as Integer
- Throws:
MisconfigurationException- case of error
-
getPropertyAsString
Description copied from interface:PropertyReaderGet the property value as String.- Specified by:
getPropertyAsStringin interfacePropertyReader- Parameters:
key- as String- Returns:
- property as String
- Throws:
MisconfigurationException- case of error
-
getPropertyList
Description copied from interface:PropertyReaderGet the full property list as Map.- Specified by:
getPropertyListin interfacePropertyReader- Returns:
- propertyList as Map
-