Lines 2962-2967
Link Here
|
2962 |
} |
2962 |
} |
2963 |
|
2963 |
|
2964 |
/** |
2964 |
/** |
|
|
2965 |
* Answers true if the given name, starting from the given index, starts with the given prefix, |
2966 |
* false otherwise. isCaseSensitive is used to find out whether or not the comparison should be |
2967 |
* case sensitive. |
2968 |
* <br> |
2969 |
* <br> |
2970 |
* For example: |
2971 |
* <ol> |
2972 |
* <li><pre> |
2973 |
* prefix = { 'a' , 'B' } |
2974 |
* name = { 'c', 'd', 'a' , 'b', 'b', 'a', 'b', 'a' } |
2975 |
* startIndex = 2 |
2976 |
* isCaseSensitive = false |
2977 |
* result => true |
2978 |
* </pre> |
2979 |
* </li> |
2980 |
* <li><pre> |
2981 |
* prefix = { 'a' , 'B' } |
2982 |
* name = { 'c', 'd', 'a' , 'b', 'b', 'a', 'b', 'a' } |
2983 |
* startIndex = 2 |
2984 |
* isCaseSensitive = true |
2985 |
* result => false |
2986 |
* </pre> |
2987 |
* </li> |
2988 |
* </ol> |
2989 |
* |
2990 |
* @param prefix the given prefix |
2991 |
* @param name the given name |
2992 |
* @param isCaseSensitive to find out whether or not the comparison should be case sensitive |
2993 |
* @param startIndex index from which the prefix should be searched in the name |
2994 |
* @return true if the given name starts with the given prefix, false otherwise |
2995 |
* @throws NullPointerException if the given name is null or if the given prefix is null |
2996 |
* @since 3.7 |
2997 |
*/ |
2998 |
public static final boolean prefixEquals( |
2999 |
char[] prefix, |
3000 |
char[] name, |
3001 |
boolean isCaseSensitive, |
3002 |
int startIndex) { |
3003 |
|
3004 |
int max = prefix.length; |
3005 |
if (name.length - startIndex < max) |
3006 |
return false; |
3007 |
if (isCaseSensitive) { |
3008 |
for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name |
3009 |
if (prefix[i] != name[startIndex + i]) |
3010 |
return false; |
3011 |
return true; |
3012 |
} |
3013 |
|
3014 |
for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name |
3015 |
if (ScannerHelper.toLowerCase(prefix[i]) |
3016 |
!= ScannerHelper.toLowerCase(name[startIndex + i])) |
3017 |
return false; |
3018 |
return true; |
3019 |
} |
3020 |
|
3021 |
/** |
2965 |
* Answers a new array removing a given character. Answers the given array if there is |
3022 |
* Answers a new array removing a given character. Answers the given array if there is |
2966 |
* no occurrence of the character to remove. |
3023 |
* no occurrence of the character to remove. |
2967 |
* <br> |
3024 |
* <br> |