|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.util.StringUtils
public class StringUtils
This class contains convenience methods for working with strings.
| Method Summary | |
|---|---|
static java.lang.String |
capitalize(java.lang.String s)
Capitalizes the given string, making its first character upper case, and the rest of them lower case. |
static boolean |
endsWith(java.lang.String a,
char[] b)
Equivalent of String.endsWith(String) using a char[]. |
static boolean |
endsWithIgnoreCase(java.lang.String a,
char[] b)
Returns true if a ends with b regardless of the case. |
static boolean |
endsWithIgnoreCase(java.lang.String a,
java.lang.String b)
Returns true if a ends with b regardless of the case. |
static boolean |
equals(java.lang.String s1,
java.lang.String s2,
boolean caseSensitive)
Compares the two specified strings and returns true if both strings are equal. |
static boolean |
equals(java.lang.String s1,
java.lang.String s2,
java.util.Locale locale)
This method is a locale-aware version of java.lang.String#equals(Object). |
static boolean |
matches(java.lang.String a,
char[] b,
int posA)
Returns true if the substring of a starting at posA matches b. |
static boolean |
matchesIgnoreCase(java.lang.String a,
char[] b,
int posA)
Returns true if the substring of a starting at posA matches b regardless of the case. |
static boolean |
matchesIgnoreCase(java.lang.String a,
java.lang.String b,
int posA)
Returns true if the substring of a starting at posA matches b regardless of the case. |
static int |
parseIntDef(java.lang.String s,
int def)
Parses the string argument as a signed decimal integer. |
static java.lang.String |
replaceCompat(java.lang.String s,
java.lang.String target,
java.lang.String replacement)
Replaces each occurrence of the target string in the given string with the specified replacement string, and returns the resulting string. |
static boolean |
startsWithIgnoreCase(java.lang.String a,
java.lang.String b)
Returns true if a starts with b regardless of the case. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean endsWithIgnoreCase(java.lang.String a,
java.lang.String b)
true if a ends with b regardless of the case.
This method has a known bug under some alphabets with peculiar capitalisation rules such as the Georgian one,
where Character.toUpperCase(a) == Character.toUpperCase(b) doesn't necessarily imply that
Character.toLowerCase(a) == Character.toLowerCase(b). The performance hit of testing for this
exceptions is so huge that it was deemed an acceptable issue.
Note that this method will return true if b is an emptry string.
a - string to test.b - suffix to test for.
true if a ends with b regardless of the case, false otherwise.
public static boolean matchesIgnoreCase(java.lang.String a,
java.lang.String b,
int posA)
true if the substring of a starting at posA matches b regardless of the case.
This method has a known bug under some alphabets with peculiar capitalisation rules such as the Georgian one,
where Character.toUpperCase(a) == Character.toUpperCase(b) doesn't necessarily imply that
Character.toLowerCase(a) == Character.toLowerCase(b). The performance hit of testing for this
exceptions is so huge that it was deemed an acceptable issue.
Note that this method will return true if b is an emptry string.
a - string to test.b - suffix to test for.posA - position in a at which to look for b
true if a ends with b regardless of the case, false otherwise..
java.lang.ArrayIndexOutOfBoundsException - if a.length is smaller than posA.
public static boolean endsWithIgnoreCase(java.lang.String a,
char[] b)
true if a ends with b regardless of the case.
This method has a known bug under some alphabets with peculiar capitalisation rules such as the Georgian one,
where Character.toUpperCase(a) == Character.toUpperCase(b) doesn't necessarily imply that
Character.toLowerCase(a) == Character.toLowerCase(b). The performance hit of testing for this
exceptions is so huge that it was deemed an acceptable issue.
Note that this method will return true if b is an emptry string.
a - string to test.b - suffix to test for.
true if a ends with b regardless of the case, false otherwise.
public static boolean matchesIgnoreCase(java.lang.String a,
char[] b,
int posA)
true if the substring of a starting at posA matches b regardless of the case.
This method has a known bug under some alphabets with peculiar capitalisation rules such as the Georgian one,
where Character.toUpperCase(a) == Character.toUpperCase(b) doesn't necessarily imply that
Character.toLowerCase(a) == Character.toLowerCase(b). The performance hit of testing for this
exceptions is so huge that it was deemed an acceptable issue.
Note that this method will return true if b is an emptry string.
a - string to test.b - suffix to test for.posA - position in a at which to look for b
true if a ends with b regardless of the case, false otherwise..
java.lang.ArrayIndexOutOfBoundsException - if a.length is smaller than posA.
public static boolean endsWith(java.lang.String a,
char[] b)
String.endsWith(String) using a char[].
a - String to test.b - suffix to test.
true if a ends with b.
public static boolean matches(java.lang.String a,
char[] b,
int posA)
true if the substring of a starting at posA matches b.
a - String to test.b - substring to look for.posA - position in a at which to look for b
true if a contains b at position posA, false otherwise..
public static boolean startsWithIgnoreCase(java.lang.String a,
java.lang.String b)
true if a starts with b regardless of the case.
Note that this method will return true if b is an emptry string.
a - string to test.b - prefix to test for.
true if a starts with b regardless of the case, false otherwise..
public static java.lang.String replaceCompat(java.lang.String s,
java.lang.String target,
java.lang.String replacement)
java.lang.String#replace(CharSequence, CharSequence)
which was introduced in Java 1.5, but unlike the latter, this method can be used on any version of Java.
On Java 1.5 and up, this method delegates to java.lang.String#replace(CharSequence, CharSequence).
On Java 1.4 or below, a custom implementation (that doesn't use Regexp) is used.
s - the string in which to replace ocurrences of targettarget - the string to be replacedreplacement - the replacement for occurrences of target
public static boolean equals(java.lang.String s1,
java.lang.String s2,
java.util.Locale locale)
java.lang.String#equals(Object). It returns
true if the two given String are equal in the specified Locale.
This method is useful for testing text expressed in a language where two strings with an identical
written representation can have a different String representation according to
java.lang.String#equals(Object). Japanese is such a language for instance.
This method uses the java.text.Collator class under the hood.
s1 - a String to compares2 - a String to comparelocale - the Locale to consider for testing the String
public static boolean equals(java.lang.String s1,
java.lang.String s2,
boolean caseSensitive)
true if both strings are equal. This method handles
null values with no risk of a NullPointerException. The comparison is case-sensitive
only if requested.
In other words, this method returns true if strings are either both null
or equal according to String#equals(String) for case-sensitive comparison, or
String#equalsIgnoreCase(String) for case-insensitive comparison.
s1 - string to compare, potentially nulls2 - string to compare, potentially nullcaseSensitive - true for case-sensitive comparison, false for case-insensitive comparison
true if strings are equal or both null
public static int parseIntDef(java.lang.String s,
int def)
s - a String containing the int representation to be parseddef - a default value if string cannot be parsed
public static java.lang.String capitalize(java.lang.String s)
null or an empty string is passed.
s - the string to capitalize
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard