Javadoc, better param names, line length 120.
@@ -28,15 +28,18 @@ import java.util.Set;
/**
* Utility methods.
+ *
* @since 2.0
*/
public final class Utils {
- private static final ResourceBundle messages = ResourceBundle.getBundle(
- Utils.class.getPackage().getName() + ".LocalStrings");
+ private static final ResourceBundle messages = ResourceBundle
+ .getBundle(Utils.class.getPackage().getName() + ".LocalStrings");
- public static final boolean IS_SECURITY_ENABLED =
- System.getSecurityManager() != null;
+ /**
+ * Whether the security manager is enabled.
+ */
+ public static final boolean IS_SECURITY_ENABLED = System.getSecurityManager() != null;
/** Any SQL_STATE starting with this value is considered a fatal disconnect */
public static final String DISCONNECTION_SQL_CODE_PREFIX = "08";
@@ -71,12 +74,13 @@ public final class Utils {
/**
* Closes the ResultSet (which may be null).
*
- * @param rset a ResultSet, may be {@code null}
+ * @param resultSet
+ * a ResultSet, may be {@code null}
*/
- public static void closeQuietly(final ResultSet rset) {
- if (rset != null) {
+ public static void closeQuietly(final ResultSet resultSet) {
+ if (resultSet != null) {
try {
- rset.close();
+ resultSet.close();
} catch (final Exception e) {
// ignored
}
@@ -86,12 +90,13 @@ public final class Utils {
/**
* Closes the Connection (which may be null).
*
- * @param conn a Connection, may be {@code null}
+ * @param connection
+ * a Connection, may be {@code null}
*/
- public static void closeQuietly(final Connection conn) {
- if (conn != null) {
+ public static void closeQuietly(final Connection connection) {
+ if (connection != null) {
try {
- conn.close();
+ connection.close();
} catch (final Exception e) {
// ignored
}
@@ -101,30 +106,38 @@ public final class Utils {
/**
* Closes the Statement (which may be null).
*
- * @param stmt a Statement, may be {@code null}
+ * @param statement
+ * a Statement, may be {@code null}.
*/
- public static void closeQuietly(final Statement stmt) {
- if (stmt != null) {
+ public static void closeQuietly(final Statement statement) {
+ if (statement != null) {
try {
- stmt.close();
+ statement.close();
} catch (final Exception e) {
// ignored
}
}
}
-
/**
- * Obtain the correct i18n message for the given key.
+ * Gets the correct i18n message for the given key.
+ *
+ * @param key
+ * The key to look up an i18n message.
+ * @return The i18n message.
*/
public static String getMessage(final String key) {
return getMessage(key, (Object[]) null);
}
-
/**
- * Obtain the correct i18n message for the given key with placeholders
- * replaced by the supplied arguments.
+ * Gets the correct i18n message for the given key with placeholders replaced by the supplied arguments.
+ *
+ * @param key
+ * A message key.
+ * @param args
+ * The message arguments.
+ * @return An i18n message.
*/
public static String getMessage(final String key, final Object... args) {
final String msg = messages.getString(key);
@@ -146,7 +159,6 @@ public final class Utils {
return value != null ? value.toCharArray() : null;
}
-
/**
* Converts the given char[] to a String.
*
