X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fresources%2FBundle.java;fp=src%2Fbe%2Fnikiroo%2Futils%2Fresources%2FBundle.java;h=c757e2b1d705dc005b52ac425f7a9a89a14deabd;hp=0c57bf992b495d8777b40753e850f9b827e47c39;hb=4840f1a45e02bb85a5990780594c4d8080d3c880;hpb=d15905f9d78264562da8bbcc36622e4ea4ac4d82 diff --git a/src/be/nikiroo/utils/resources/Bundle.java b/src/be/nikiroo/utils/resources/Bundle.java index 0c57bf9..c757e2b 100644 --- a/src/be/nikiroo/utils/resources/Bundle.java +++ b/src/be/nikiroo/utils/resources/Bundle.java @@ -95,8 +95,8 @@ public class Bundle> { * @param name * the id of the setting to check * @param includeDefaultValue - * TRUE to only return false when the setting is not set AND - * there is no default value + * TRUE to only return false when the setting is explicitly set + * to NULL (and not just "no set") in the change maps * * @return TRUE if the setting is set */ @@ -160,13 +160,7 @@ public class Bundle> { public String getString(E id, String def, int item) { String rep = getString(id.name(), null); if (rep == null) { - try { - Meta meta = type.getDeclaredField(id.name()).getAnnotation( - Meta.class); - rep = meta.def(); - } catch (NoSuchFieldException e) { - } catch (SecurityException e) { - } + rep = getMetaDef(id.name()); } if (rep == null || rep.isEmpty()) { @@ -937,9 +931,35 @@ public class Bundle> { return changeMap.containsKey(key) || map.containsKey(key); } + /** + * The default {@link MetaInfo.def} value for the given enumeration name. + * + * @param id + * the enumeration name (the "id") + * + * @return the def value in the {@link MetaInfo} or "" if none (never NULL) + */ + protected String getMetaDef(String id) { + String rep = ""; + try { + Meta meta = type.getDeclaredField(id).getAnnotation(Meta.class); + rep = meta.def(); + } catch (NoSuchFieldException e) { + } catch (SecurityException e) { + } + + if (rep == null) { + rep = ""; + } + + return rep; + } + /** * Get the value for the given key if it exists in the internal map, or * def if not. + *

+ * DO NOT get the default meta value (MetaInfo.def()). * * @param key * the key to check for