Author: oheger Date: Sat May 21 19:36:11 2016 New Revision: 1744971 URL: http://svn.apache.org/viewvc?rev=1744971&view=rev Log: [CONFIGURATION-626] Updated user guide.
The now deprecated getArray() method is no longer described. Instead, it is mentioned that get() can handle arrays. Modified: commons/proper/configuration/trunk/src/site/xdoc/userguide/howto_basicfeatures.xml Modified: commons/proper/configuration/trunk/src/site/xdoc/userguide/howto_basicfeatures.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/site/xdoc/userguide/howto_basicfeatures.xml?rev=1744971&r1=1744970&r2=1744971&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/site/xdoc/userguide/howto_basicfeatures.xml (original) +++ commons/proper/configuration/trunk/src/site/xdoc/userguide/howto_basicfeatures.xml Sat May 21 19:36:11 2016 @@ -445,13 +445,21 @@ int theAnswer = config.getInt("answer"); Generic conversion methods are also available for obtaining arrays or collections. For instance, it is possible to obtain the value of a property as an array of <b>int</b> or a list of <code>java.lang.Long</code> - objects. This can be achieved using the following methods: + objects. For arrays these conversions are directly supported by the generic + <code>get()</code> methods: if the target type passed to the method is an + array class, an array conversion is done automatically. So to obtain an + array of <strong>int</strong> from a configuration, the following code + can be used: + </p> + <source><![CDATA[ +int[] result = config.getInt(int[].class, "myIntArrayKey"); +]]></source> + <p> + For conversions to collections specific methods are provided (this is + necessary because the element type of the collection cannot be + determined automatically as in case of arrays). These are the following + ones: <dl> - <dt>Object getArray(Class<?> cls, String key);</dt> - <dd>Returns an array of the specified element class. This method can - handle both object and primitive arrays. (Therefore, the return type - is just <code>Object</code> because there is no common base class for - all kinds of arrays.)</dd> <dt><T> List<T> getList(Class<T> cls, String key);</dt> <dd>Returns a list of the specified element class.</dd> <dt><T> Collection<T> getCollection(Class<T> cls, @@ -613,7 +621,7 @@ config.setConversionHandler(handler); AbstractConfiguration</a></code> offers a property named <em>configurationDecoder</em>. Making use of this property simplifies access to encoded properties: When the central configuration object is - created the decoder is initialized. Other parts of the application do not + created the decoder is initialized. Other parts of the application do not need any knowledge about the decoding algorithm to be applied; rather, it is sufficient to call the simple variant of <code>getEncodedString()</code> to obtain a property value which can be processed immediately.