diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2009-10-17 21:08:38 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2009-10-17 21:08:38 +0000 |
commit | 7277bf34b9abb4a5b2fa4f4984d2bc02952b432d (patch) | |
tree | 63688aafcc8c535b6b1e1d6ad9d27be62d3ac4da /src | |
parent | 0f148ad9c13d7e197d7ed14c8024a919fa289473 (diff) | |
download | jitsi-7277bf34b9abb4a5b2fa4f4984d2bc02952b432d.zip jitsi-7277bf34b9abb4a5b2fa4f4984d2bc02952b432d.tar.gz jitsi-7277bf34b9abb4a5b2fa4f4984d2bc02952b432d.tar.bz2 |
Prevents NumberFormatException in the cases in which it is clear that it will be thrown and caught for the sake of performance.
Diffstat (limited to 'src')
3 files changed, 55 insertions, 20 deletions
diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java index 2643a3b..f47374b 100644 --- a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java +++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java @@ -1051,15 +1051,33 @@ public class ConfigurationServiceImpl .parseBoolean(stringValue); } - /* - * Implements ConfigurationService#getInt(String, int). + /** + * Gets the value of a specific property as a signed decimal integer. If the + * specified property name is associated with a value in this + * <tt>ConfigurationService</tt>, the string representation of the value is + * parsed into a signed decimal integer according to the rules of + * {@link Integer#parseInt(String)} . If parsing the value as a signed + * decimal integer fails or there is no value associated with the specified + * property name, <tt>defaultValue</tt> is returned. + * + * @param propertyName the name of the property to get the value of as a + * signed decimal integer + * @param defaultValue the value to be returned if parsing the value of the + * specified property name as a signed decimal integer fails or there is no + * value associated with the specified property name in this + * <tt>ConfigurationService</tt> + * @return the value of the property with the specified name in this + * <tt>ConfigurationService</tt> as a signed decimal integer; + * <tt>defaultValue</tt> if parsing the value of the specified property name + * fails or no value is associated in this <tt>ConfigurationService</tt> + * with the specified property name */ public int getInt(String propertyName, int defaultValue) { String stringValue = getString(propertyName); int intValue = defaultValue; - if (stringValue != null) + if ((stringValue != null) && (stringValue.length() > 0)) { try { diff --git a/src/net/java/sip/communicator/service/configuration/ConfigurationService.java b/src/net/java/sip/communicator/service/configuration/ConfigurationService.java index 95520fb..d7eddc6 100644 --- a/src/net/java/sip/communicator/service/configuration/ConfigurationService.java +++ b/src/net/java/sip/communicator/service/configuration/ConfigurationService.java @@ -201,26 +201,23 @@ public interface ConfigurationService /** * Gets the value of a specific property as a signed decimal integer. If the * specified property name is associated with a value in this - * <code>ConfigurationService</code>, the string representation of the value - * is parsed into a signed decimal integer according to the rules of + * <tt>ConfigurationService</tt>, the string representation of the value is + * parsed into a signed decimal integer according to the rules of * {@link Integer#parseInt(String)} . If parsing the value as a signed * decimal integer fails or there is no value associated with the specified - * property name, <code>defaultValue</code> is returned. + * property name, <tt>defaultValue</tt> is returned. * - * @param propertyName - * the name of the property to get the value of as a signed - * decimal integer - * @param defaultValue - * the value to be returned if parsing the value of the specified - * property name as a signed decimal integer fails or there is no - * value associated with the specified property name in this - * <code>ConfigurationService</code> + * @param propertyName the name of the property to get the value of as a + * signed decimal integer + * @param defaultValue the value to be returned if parsing the value of the + * specified property name as a signed decimal integer fails or there is no + * value associated with the specified property name in this + * <tt>ConfigurationService</tt> * @return the value of the property with the specified name in this - * <code>ConfigurationService</code> as a signed decimal integer; - * <code>defaultValue</code> if parsing the value of the specified - * property name fails or no value is associated in this - * <code>ConfigurationService</code> with the specified property - * name + * <tt>ConfigurationService</tt> as a signed decimal integer; + * <tt>defaultValue</tt> if parsing the value of the specified property name + * fails or no value is associated in this <tt>ConfigurationService</tt> + * with the specified property name */ public int getInt(String propertyName, int defaultValue); diff --git a/src/net/java/sip/communicator/service/protocol/AccountID.java b/src/net/java/sip/communicator/service/protocol/AccountID.java index 84523ff..bcfed62 100644 --- a/src/net/java/sip/communicator/service/protocol/AccountID.java +++ b/src/net/java/sip/communicator/service/protocol/AccountID.java @@ -195,12 +195,32 @@ public abstract class AccountID return (value == null) ? defaultValue : Boolean.parseBoolean(value); } + /** + * Gets the value of a specific property as a signed decimal integer. If the + * specified property key is associated with a value in this + * <tt>AccountID</tt>, the string representation of the value is parsed into + * a signed decimal integer according to the rules of + * {@link Integer#parseInt(String)} . If parsing the value as a signed + * decimal integer fails or there is no value associated with the specified + * property key, <tt>defaultValue</tt> is returned. + * + * @param key the key of the property to get the value of as a + * signed decimal integer + * @param defaultValue the value to be returned if parsing the value of the + * specified property key as a signed decimal integer fails or there is no + * value associated with the specified property key in this + * <tt>AccountID</tt> + * @return the value of the property with the specified key in this + * <tt>AccountID</tt> as a signed decimal integer; <tt>defaultValue</tt> if + * parsing the value of the specified property key fails or no value is + * associated in this <tt>AccountID</tt> with the specified property name + */ public int getAccountPropertyInt(Object key, int defaultValue) { String stringValue = getAccountPropertyString(key); int intValue = defaultValue; - if (stringValue != null) + if ((stringValue != null) && (stringValue.length() > 0)) { try { |