1. Project Clover database Mon Dec 22 2025 14:59:38 CST
  2. Package org.europa.together.business

File PropertyReader.java

 

Code metrics

0
0
0
1
180
41
0
-
-
0
-

Classes

Class Line # Actions
PropertyReader 25 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package org.europa.together.business;
2   
3    import java.io.IOException;
4    import java.util.Map;
5    import org.apiguardian.api.API;
6    import static org.apiguardian.api.API.Status.STABLE;
7    import org.europa.together.exceptions.MisconfigurationException;
8    import org.springframework.stereotype.Component;
9   
10    /**
11    * The PropertyReader is able to read properties from different resources like
12    * file, database or from the classpath. It is also possible to manipulate the
13    * property list. The key feature are the different cast methods for the
14    * property values to load them into the correct datatype.
15    * <br><br>
16    * A property set contains for each line a key=value pair. Comments starts with
17    * the # character.
18    *
19    * @author elmar.dott@gmail.com
20    * @version 1.2
21    * @since 1.0
22    */
23    @API(status = STABLE, since = "1.0", consumers = "PropertyFileReader")
24    @Component
 
25    public interface PropertyReader {
26   
27    /**
28    * Identifier for the given feature.
29    */
30    @API(status = STABLE, since = "1.2")
31    String FEATURE_ID = "CM-04";
32   
33    /**
34    * Add a single property to the property list. If the property already exist
35    * in the list, the new entry will not added and the method return FALSE.
36    *
37    * @param key as String
38    * @param value as String
39    * @return true on success
40    */
41    @API(status = STABLE, since = "1.0")
42    boolean addProperty(String key, String value);
43   
44    /**
45    * Extend property list by Map&lt;String, String&gt;.
46    *
47    * @param propertyList as Map
48    * @return true on success
49    */
50    @API(status = STABLE, since = "1.0")
51    boolean addPropertyList(Map<String, String> propertyList);
52   
53    /**
54    * Load a property list from an given file inside the classpath. eg:
55    * org/europa/together/properties/file.properties
56    *
57    * @param resource as String
58    * @return true on success
59    * @throws java.io.IOException case of error
60    */
61    @API(status = STABLE, since = "3.0")
62    boolean appendPropertiesFromClasspath(String resource) throws IOException;
63   
64    /**
65    * Load a property list from an external file. eg:
66    * /home/usr/application/file.properties
67    *
68    * @param resource as String
69    * @return true on success
70    * @throws java.io.IOException case of error
71    */
72    @API(status = STABLE, since = "3.0")
73    boolean appendPropertiesFromFile(String resource) throws IOException;
74   
75    /**
76    * Clear the entire property list.
77    *
78    * @return true on success
79    */
80    @API(status = STABLE, since = "1.0")
81    boolean clear();
82   
83    /**
84    * Remove a property by the given key from the list. If the property not
85    * exists the method return false.
86    *
87    * @param key as String
88    * @return true on success
89    */
90    @API(status = STABLE, since = "1.0")
91    boolean removeProperty(String key);
92   
93    /**
94    * Update an existing property entry. In the case the entry don't exist, it
95    * will be created.
96    *
97    * @param key as String
98    * @param value as String
99    * @return true on success
100    */
101    @API(status = STABLE, since = "1.0")
102    boolean updateProperty(String key, String value);
103   
104    /**
105    * Counts the amount of all properties and return the value.
106    *
107    * @return count of properties as int
108    */
109    @API(status = STABLE, since = "1.0")
110    int count();
111   
112    /**
113    * Get the value of a property as boolean.Allowed values are:<br>
114    * - 0 | 1<br>
115    * - false | true<br>
116    * - FALSE | TRUE<br>
117    * All other values will evaluate to <b>null</b>.
118    *
119    * @param key as String
120    * @return property as Boolean
121    * @throws org.europa.together.exceptions.MisconfigurationException case of
122    * error
123    */
124    @API(status = STABLE, since = "1.0")
125    Boolean getPropertyAsBoolean(String key) throws MisconfigurationException;
126   
127    /**
128    * Get the property value as Double.
129    *
130    * @param key as String
131    * @return property as Double
132    * @throws org.europa.together.exceptions.MisconfigurationException case of
133    * error
134    */
135    @API(status = STABLE, since = "1.0")
136    Double getPropertyAsDouble(String key) throws MisconfigurationException;
137   
138    /**
139    * Get the property value as Float.
140    *
141    * @param key as String
142    * @return property as Float
143    * @throws org.europa.together.exceptions.MisconfigurationException case of
144    * error
145    */
146    @API(status = STABLE, since = "1.0")
147    Float getPropertyAsFloat(String key) throws MisconfigurationException;
148   
149    /**
150    * Get the value of a property as Integer.
151    *
152    * @param key as String
153    * @return property as Integer
154    * @throws org.europa.together.exceptions.MisconfigurationException case of
155    * error
156    */
157    @API(status = STABLE, since = "1.0")
158    Integer getPropertyAsInt(String key) throws MisconfigurationException;
159   
160    /**
161    * Get the property value as String.
162    *
163    * @param key as String
164    * @return property as String
165    * @throws org.europa.together.exceptions.MisconfigurationException case of
166    * error
167    */
168    @API(status = STABLE, since = "1.0")
169    String getPropertyAsString(String key) throws MisconfigurationException;
170   
171    /**
172    * Get the full property list as Map.
173    *
174    * @return propertyList as Map
175    * @throws org.europa.together.exceptions.MisconfigurationException case of
176    * error
177    */
178    @API(status = STABLE, since = "1.0")
179    Map<String, String> getPropertyList() throws MisconfigurationException;
180    }