164 } |
164 } |
165 |
165 |
166 /** |
166 /** |
167 * Returns true if the specified string is all whitespace. |
167 * Returns true if the specified string is all whitespace. |
168 */ |
168 */ |
169 public static final boolean isWhiteSpace(CharSequence s) { |
169 public static boolean isWhiteSpace(CharSequence s) { |
170 for( int i=s.length()-1; i>=0; i-- ) |
170 for( int i=s.length()-1; i>=0; i-- ) |
171 if(!isWhiteSpace(s.charAt(i))) |
171 if(!isWhiteSpace(s.charAt(i))) |
172 return false; |
172 return false; |
173 return true; |
173 return true; |
174 } |
174 } |
175 |
175 |
176 /** returns true if the specified char is a white space character. */ |
176 /** returns true if the specified char is a white space character. */ |
177 public static final boolean isWhiteSpace(char ch) { |
177 public static boolean isWhiteSpace(char ch) { |
178 // most of the characters are non-control characters. |
178 // most of the characters are non-control characters. |
179 // so check that first to quickly return false for most of the cases. |
179 // so check that first to quickly return false for most of the cases. |
180 if( ch>0x20 ) return false; |
180 if( ch>0x20 ) return false; |
181 |
181 |
182 // other than we have to do four comparisons. |
182 // other than we have to do four comparisons. |
185 |
185 |
186 /** |
186 /** |
187 * Returns true if the specified char is a white space character |
187 * Returns true if the specified char is a white space character |
188 * but not 0x20. |
188 * but not 0x20. |
189 */ |
189 */ |
190 protected static final boolean isWhiteSpaceExceptSpace(char ch) { |
190 protected static boolean isWhiteSpaceExceptSpace(char ch) { |
191 // most of the characters are non-control characters. |
191 // most of the characters are non-control characters. |
192 // so check that first to quickly return false for most of the cases. |
192 // so check that first to quickly return false for most of the cases. |
193 if( ch>=0x20 ) return false; |
193 if( ch>=0x20 ) return false; |
194 |
194 |
195 // other than we have to do four comparisons. |
195 // other than we have to do four comparisons. |