From 745b02ca1959ce864e0851aa9515cb8d171535da Mon Sep 17 00:00:00 2001 From: lado Date: Fri, 15 Feb 2013 00:12:42 +0100 Subject: added equals --- .../src/de/bjusystems/vdrmanager/StringUtils.java | 37 ++++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/StringUtils.java b/vdrmanager/src/de/bjusystems/vdrmanager/StringUtils.java index b440055..97050dc 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/StringUtils.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/StringUtils.java @@ -11,14 +11,14 @@ public class StringUtils { * An empty immutable String array. */ public static final String[] EMPTY_STRING_ARRAY = new String[0]; - + public static final String EMPTY_STRING = ""; - + /** - * Performs the logic for the split and - * splitPreserveAllTokens methods that return a maximum array + * Performs the logic for the split and + * splitPreserveAllTokens methods that return a maximum array * length. * * @param str the String to parse, may be null @@ -114,9 +114,9 @@ public class StringUtils { } return (String[]) list.toArray(new String[list.size()]); } - + /** - *

Splits the provided text into an array, separators specified, + *

Splits the provided text into an array, separators specified, * preserving all tokens, including empty tokens created by adjacent * separators. This is an alternative to using StringTokenizer.

* @@ -152,4 +152,29 @@ public class StringUtils { return splitWorker(str, separatorChars, -1, true); } + // Equals + //----------------------------------------------------------------------- + /** + *

Compares two Strings, returning true if they are equal.

+ * + *

nulls are handled without exceptions. Two null + * references are considered to be equal. The comparison is case sensitive.

+ * + *
+     * StringUtils.equals(null, null)   = true
+     * StringUtils.equals(null, "abc")  = false
+     * StringUtils.equals("abc", null)  = false
+     * StringUtils.equals("abc", "abc") = true
+     * StringUtils.equals("abc", "ABC") = false
+     * 
+ * + * @see java.lang.String#equals(Object) + * @param str1 the first String, may be null + * @param str2 the second String, may be null + * @return true if the Strings are equal, case sensitive, or + * both null + */ + public static boolean equals(String str1, String str2) { + return str1 == null ? str2 == null : str1.equals(str2); + } } -- cgit v1.2.3