| 1 | |
package org.jbehave.core.steps.needle.configuration; |
| 2 | |
|
| 3 | |
import java.util.Enumeration; |
| 4 | |
import java.util.MissingResourceException; |
| 5 | |
import java.util.ResourceBundle; |
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | 2 | public enum LoadResourceBundle { |
| 14 | 1 | INSTANCE; |
| 15 | |
|
| 16 | 1 | public static final ResourceBundle EMPTY_RESOURCE_BUNDLE = new ResourceBundle() { |
| 17 | |
|
| 18 | |
@Override |
| 19 | |
public Enumeration<String> getKeys() { |
| 20 | 0 | return new Enumeration<String>() { |
| 21 | |
|
| 22 | |
public boolean hasMoreElements() { |
| 23 | 0 | return false; |
| 24 | |
} |
| 25 | |
|
| 26 | |
public String nextElement() { |
| 27 | 0 | return null; |
| 28 | |
} |
| 29 | |
}; |
| 30 | |
} |
| 31 | |
|
| 32 | |
@Override |
| 33 | |
protected Object handleGetObject(final String key) { |
| 34 | 0 | return ""; |
| 35 | |
} |
| 36 | |
}; |
| 37 | |
|
| 38 | |
public final ResourceBundle apply(final String resourceName) { |
| 39 | 9 | if (resourceName == null || "".equals(resourceName.trim())) { |
| 40 | 0 | throw new IllegalArgumentException("resourceName must not be null or empty!"); |
| 41 | |
} |
| 42 | |
|
| 43 | |
try { |
| 44 | 9 | return ResourceBundle.getBundle(resourceName); |
| 45 | 0 | } catch (final MissingResourceException e) { |
| 46 | 0 | return EMPTY_RESOURCE_BUNDLE; |
| 47 | |
} |
| 48 | |
} |
| 49 | |
|
| 50 | |
} |