|
1 | | -package com.sporniket.libre.lang ; |
| 1 | +package com.sporniket.libre.lang; |
2 | 2 |
|
3 | | -import java.util.Map ; |
4 | | -import java.util.ResourceBundle ; |
| 3 | +import java.util.Map; |
| 4 | +import java.util.ResourceBundle; |
5 | 5 |
|
6 | 6 | /** |
7 | 7 | * Macros for collections and resources. |
8 | 8 | * <p> |
9 | | - * These macros are meant to be used when retrieving a value from a <code>ResourceBundle</code> or a <code>Collection</code> and wanting a default value if it fails. |
| 9 | + * These macros are meant to be used when retrieving a value from a <code>ResourceBundle</code> or a <code>Collection</code> and |
| 10 | + * wanting a default value if it fails. |
10 | 11 | * </p> |
11 | 12 | * |
12 | 13 | * <p> |
|
18 | 19 | * This file is part of <i>The Sporniket Core Library – lang</i>. |
19 | 20 | * |
20 | 21 | * <p> |
21 | | - * <i>The Sporniket Core Library – lang</i> is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published |
22 | | - * by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. |
| 22 | + * <i>The Sporniket Core Library – lang</i> is free software: you can redistribute it and/or modify it under the terms of the |
| 23 | + * GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your |
| 24 | + * option) any later version. |
23 | 25 | * |
24 | 26 | * <p> |
25 | | - * <i>The Sporniket Core Library – lang</i> is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
26 | | - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 27 | + * <i>The Sporniket Core Library – lang</i> is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 28 | + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 29 | + * License for more details. |
27 | 30 | * |
28 | 31 | * <p> |
29 | | - * You should have received a copy of the GNU Lesser General Public License along with <i>The Sporniket Core Library – lang</i>. If not, see |
30 | | - * <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>. 2 |
| 32 | + * You should have received a copy of the GNU Lesser General Public License along with <i>The Sporniket Core Library – |
| 33 | + * lang</i>. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>. 2 |
31 | 34 | * |
32 | 35 | * <hr> |
33 | 36 | * |
34 | 37 | * @author David SPORN |
35 | 38 | * @version 22.09.00 |
36 | 39 | * @since 12.06.01 |
37 | 40 | */ |
38 | | -public class CollectionTools { |
| 41 | +public class CollectionTools |
| 42 | +{ |
39 | 43 |
|
40 | 44 | /** |
41 | 45 | * Return an object from a ResourceBundle. |
42 | 46 | * |
43 | | - * @param source ResourceBundle from which extract the value |
44 | | - * @param key The key to retrieve the value |
45 | | - * @param defaultValue When the wanted value doesn't exist, return this one |
| 47 | + * @param source |
| 48 | + * ResourceBundle from which extract the value |
| 49 | + * @param key |
| 50 | + * The key to retrieve the value |
| 51 | + * @param defaultValue |
| 52 | + * When the wanted value doesn't exist, return this one |
46 | 53 | * @return The wanted object or defaulValue |
47 | 54 | */ |
48 | | - public static Object getObject(final ResourceBundle source, final String key, final Object defaultValue) { |
49 | | - try { |
50 | | - return source.getObject(key) ; |
51 | | - } catch (Exception _exception) { |
52 | | - return defaultValue ; |
| 55 | + public static Object getObject(final ResourceBundle source, final String key, final Object defaultValue) |
| 56 | + { |
| 57 | + try |
| 58 | + { |
| 59 | + return source.getObject(key); |
| 60 | + } |
| 61 | + catch (Exception _exception) |
| 62 | + { |
| 63 | + return defaultValue; |
53 | 64 | } |
54 | 65 | } |
55 | 66 |
|
56 | 67 | /** |
57 | 68 | * Return an object from a Map. |
58 | 69 | * |
59 | | - * @param source Map from which extract the value |
60 | | - * @param key The key to retrieve the value |
61 | | - * @param defaultValue When the wanted value doesn't exist, return this one |
| 70 | + * @param source |
| 71 | + * Map from which extract the value |
| 72 | + * @param key |
| 73 | + * The key to retrieve the value |
| 74 | + * @param defaultValue |
| 75 | + * When the wanted value doesn't exist, return this one |
62 | 76 | * @return The wanted object or defaulValue |
63 | 77 | */ |
64 | | - public static Object getObject(final Map<String, Object> source, final String key, final Object defaultValue) { |
65 | | - try { |
66 | | - return source.get(key) ; |
67 | | - } catch (Exception _exception) { |
68 | | - return defaultValue ; |
| 78 | + public static Object getObject(final Map<String, Object> source, final String key, final Object defaultValue) |
| 79 | + { |
| 80 | + try |
| 81 | + { |
| 82 | + return source.get(key); |
| 83 | + } |
| 84 | + catch (Exception _exception) |
| 85 | + { |
| 86 | + return defaultValue; |
69 | 87 | } |
70 | 88 | } |
71 | 89 |
|
72 | 90 | /** |
73 | 91 | * Return an string from a ResourceBundle. |
74 | 92 | * |
75 | | - * @param source ResourceBundle from which extract the value |
76 | | - * @param key The key to retrieve the value |
77 | | - * @param defaultValue When the wanted value doesn't exist, return this one |
| 93 | + * @param source |
| 94 | + * ResourceBundle from which extract the value |
| 95 | + * @param key |
| 96 | + * The key to retrieve the value |
| 97 | + * @param defaultValue |
| 98 | + * When the wanted value doesn't exist, return this one |
78 | 99 | * @return The wanted object or defaulValue |
79 | 100 | */ |
80 | | - public static String getString(final ResourceBundle source, final String key, final String defaultValue) { |
81 | | - try { |
82 | | - return source.getString(key) ; |
83 | | - } catch (Exception _exception) { |
84 | | - return defaultValue ; |
| 101 | + public static String getString(final ResourceBundle source, final String key, final String defaultValue) |
| 102 | + { |
| 103 | + try |
| 104 | + { |
| 105 | + return source.getString(key); |
| 106 | + } |
| 107 | + catch (Exception _exception) |
| 108 | + { |
| 109 | + return defaultValue; |
85 | 110 | } |
86 | 111 | } |
87 | 112 |
|
|
0 commit comments