From: hyeongseok.heo Date: Wed, 23 Oct 2013 12:41:44 +0000 (+0900) Subject: [Title] add get(String namespace,String key) method X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F11274%2F1;p=sdk%2Fide%2Fcommon-eplugin.git [Title] add get(String namespace,String key) method [Desc.] [Issue] Change-Id: Iff1efc5014cc74d5d1af941c087baedd7e66c239 Signed-off-by: hyeongseok.heo --- diff --git a/org.tizen.common/src/org/tizen/common/config/Preference.java b/org.tizen.common/src/org/tizen/common/config/Preference.java index dfd6873..c076fbb 100755 --- a/org.tizen.common/src/org/tizen/common/config/Preference.java +++ b/org.tizen.common/src/org/tizen/common/config/Preference.java @@ -32,6 +32,7 @@ import java.util.HashSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.tizen.common.util.Assert; import org.tizen.common.util.ParsingUtil; /** @@ -128,7 +129,6 @@ Preference /** * Return preference expression * - * @param name namespace name * @param key preference key * * @return preference expression @@ -154,6 +154,24 @@ Preference return null; } + + /** + * Return preference value by namespace + * @param namespace + * @param key + * @return + */ + public static String get(String namespace, String key) { + Assert.notNull(namespace); + logger.info( "Namespace :{}, Key :{}", namespace,key ); + PreferenceProvider provider = name2provider.get(namespace); + if( null != provider) { + final String exp = provider.get( key ); + logger.debug( "Provider :{}, Value :{}", provider, exp ); + return exp; + } + return null; + } /* List */ /** @@ -170,9 +188,11 @@ Preference ) { final HashSet keys = new HashSet(); - for ( final PreferenceProvider provider : providers ) - { - keys.addAll( provider.keys() ); + //fixed by Harry Hyeongseok Heo + //Fixed logic as JavaDoc says. + PreferenceProvider preferenceProvider = name2provider.get(name); + if( null != preferenceProvider) { + keys.addAll( preferenceProvider.keys() ); } return Collections.unmodifiableCollection( keys ); @@ -253,4 +273,6 @@ Preference } + + }