diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2010-07-12 14:59:01 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2010-07-12 14:59:01 +0000 |
commit | 04cac3354cde9cbbf72cd91cef559a02d0143b20 (patch) | |
tree | 1febf0158fee5ec0cf7db649599d2cc8456c9519 /src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java | |
parent | a16201daf3842b3abae0f876a6f43429fbee145c (diff) | |
download | jitsi-04cac3354cde9cbbf72cd91cef559a02d0143b20.zip jitsi-04cac3354cde9cbbf72cd91cef559a02d0143b20.tar.gz jitsi-04cac3354cde9cbbf72cd91cef559a02d0143b20.tar.bz2 |
Merges branches/gsoc10/passwdstrg@7435 which represents the work of Dmitri Melnikov on the "Password storage" GSoC 2010 project into trunk.
Diffstat (limited to 'src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java')
-rw-r--r-- | src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java index 5f753d2..60ee2e3 100644 --- a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java +++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java @@ -19,19 +19,25 @@ import net.java.sip.communicator.util.xml.*; import org.osgi.framework.*; /** - * A straight forward implementation of the ConfigurationService using an xml - * file for storing properties. Currently only String properties are - * meaningfully saved (we should probably consider how and whether we should - * take care of the rest). + * A straightforward implementation of the <tt>ConfigurationService</tt> using + * an XML or a .properties file for storing properties. Currently only + * <tt>String</tt> properties are meaningfully saved (we should probably + * consider how and whether we should take care of the rest). * * @author Emil Ivov * @author Damian Minkov * @author Lubomir Marinov + * @author Dmitri Melnikov */ public class ConfigurationServiceImpl implements ConfigurationService { - private final Logger logger = Logger.getLogger(ConfigurationServiceImpl.class); + /** + * The <tt>Logger</tt> used by this <tt>ConfigurationServiceImpl</tt> + * instance for logging output. + */ + private final Logger logger + = Logger.getLogger(ConfigurationServiceImpl.class); private static final String SYS_PROPS_FILE_NAME_PROPERTY = "net.java.sip.communicator.SYS_PROPS_FILE_NAME"; @@ -366,6 +372,43 @@ public class ConfigurationServiceImpl } /** + * Returns a <tt>List</tt> of <tt>String</tt>s containing the property names + * that have the specified suffix. A suffix is considered to be everything + * after the last dot in the property name. + * <p> + * For example, imagine a configuration service instance containing two + * properties only: + * </p> + * <code> + * net.java.sip.communicator.PROP1=value1 + * net.java.sip.communicator.service.protocol.PROP1=value2 + * </code> + * <p> + * A call to this method with <tt>suffix</tt> equal to "PROP1" will return + * both properties, whereas the call with <tt>suffix</tt> equal to + * "communicator.PROP1" or "PROP2" will return an empty <tt>List</tt>. Thus, + * if the <tt>suffix</tt> argument contains a dot, nothing will be found. + * </p> + * + * @param suffix the suffix for the property names to be returned + * @return a <tt>List</tt> of <tt>String</tt>s containing the property names + * which contain the specified <tt>suffix</tt> + */ + public List<String> getPropertyNamesBySuffix(String suffix) + { + List<String> resultKeySet = new LinkedList<String>(); + + for (String key : store.getPropertyNames()) + { + int ix = key.lastIndexOf('.'); + + if ((ix != -1) && suffix.equals(key.substring(ix+1))) + resultKeySet.add(key); + } + return resultKeySet; + } + + /** * Adds a PropertyChangeListener to the listener list. * * @param listener the PropertyChangeListener to be added |