1. Project Clover database Wed Jan 17 2024 23:40:18 CST
  2. Package org.europa.together.business

File PropertyReader.java

 

Code metrics

0
0
0
1
176
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
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
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:
114    * <ul>
115    * <li>0 | 1</li>
116    * <li>false | true</li>
117    * <li>FALSE | TRUE</li>
118    * </ul>
119    * All other values will evaluate to <b>null</b>.
120    *
121    * @param key as String
122    * @return property as Boolean
123    * @throws org.europa.together.exceptions.MisconfigurationException
124    */
125    @API(status = STABLE, since = "1.0")
126    Boolean getPropertyAsBoolean(String key) throws MisconfigurationException;
127   
128    /**
129    * Get the property value as Double.
130    *
131    * @param key as String
132    * @return property as Double
133    * @throws org.europa.together.exceptions.MisconfigurationException
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
144    */
145    @API(status = STABLE, since = "1.0")
146    Float getPropertyAsFloat(String key) throws MisconfigurationException;
147   
148    /**
149    * Get the value of a property as Integer.
150    *
151    * @param key as String
152    * @return property as Integer
153    * @throws org.europa.together.exceptions.MisconfigurationException
154    */
155    @API(status = STABLE, since = "1.0")
156    Integer getPropertyAsInt(String key) throws MisconfigurationException;
157   
158    /**
159    * Get the property value as String.
160    *
161    * @param key as String
162    * @return property as String
163    * @throws org.europa.together.exceptions.MisconfigurationException
164    */
165    @API(status = STABLE, since = "1.0")
166    String getPropertyAsString(String key) throws MisconfigurationException;
167   
168    /**
169    * Get the full property list as Map.
170    *
171    * @return propertyList as Map
172    * @throws org.europa.together.exceptions.MisconfigurationException
173    */
174    @API(status = STABLE, since = "1.0")
175    Map<String, String> getPropertyList() throws MisconfigurationException;
176    }