Re: Character.isWhitespace alternative? (whitespace check)

2009-09-30 Thread Ed

H Interesting Dominik.
Thanks for the information.
It's sure is clean, but didn't know that performance of regexp is
good in this case..

What I want is: if a character at index X is a white space. That means
I always have to take first a substring of one character and then do a
match. So besides checking for a whitespace, I also take a substring,
does that still perform well ??...
Besides that: I always understood that object creation should be
reduces as much as possible. In this case it always creates more
objects...

Might it be a good idea to store the pattern in a static field, to
overcome unnecessary pattern compilation?
So do something like this:

private final static Pattern PATTERN_WHITE_SPACE = Pattern.compile(\
\S);
..
...
..
In a helper method:

public static boolean matchWhiteSpace(String input) {
return PATTERN_WHITE_SPACE.matcher(input).matches();
}



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Character.isWhitespace alternative? (whitespace check)

2009-09-30 Thread mars1412

if performance is really that critical you should test several
alternatives and check which one is really the best for your case (and
don't forget to test cross-browser; especially IE)


On Sep 30, 10:32 am, Ed post2edb...@hotmail.com wrote:
 H Interesting Dominik.
 Thanks for the information.
 It's sure is clean, but didn't know that performance of regexp is
 good in this case..

 What I want is: if a character at index X is a white space. That means
 I always have to take first a substring of one character and then do a
 match. So besides checking for a whitespace, I also take a substring,
 does that still perform well ??...
 Besides that: I always understood that object creation should be
 reduces as much as possible. In this case it always creates more
 objects...

 Might it be a good idea to store the pattern in a static field, to
 overcome unnecessary pattern compilation?
 So do something like this:

 private final static Pattern PATTERN_WHITE_SPACE = Pattern.compile(\
 \S);
 ..
 ...
 ..
 In a helper method:

 public static boolean matchWhiteSpace(String input) {
         return PATTERN_WHITE_SPACE.matcher(input).matches();

 }


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Character.isWhitespace alternative? (whitespace check)

2009-09-29 Thread Ed

Yes I can, but don't want to, as it's way to heave for just checking
if a character is a white space... Especialy in my case where
performance is an issue.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Character.isWhitespace alternative? (whitespace check)

2009-09-29 Thread Dominik Steiner

Hi Ed,

for performance reason I would definitely recommend you to actually  
use regex instead of equals or equalsIgnoreCase methods of the String  
class. Especially IE has really performance problems with former ones.  
Concerning heavy, I would actually say that it is much cleaner to use  
regex and more adaptable in case you would need in the future

HTH

Dominik
Am 29.09.2009 um 01:11 schrieb Ed:


 Yes I can, but don't want to, as it's way to heave for just checking
 if a character is a white space... Especialy in my case where
 performance is an issue.

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Character.isWhitespace alternative? (whitespace check)

2009-09-28 Thread Dominik Steiner

did you try to use the regex method

boolean matches = someString.matches(\\S);

HTH

Dominik

On 28 Sep., 13:39, Ed post2edb...@hotmail.com wrote:
 What is the correct way to check for a white space character?

 This is done by the method Character.isWhitespace(char) but not
 supported by GWT. What is the alternative?

 I know check for whiteSpaces through
 someString.charAt(index) == ' ';

 But I am not sure if that's good enough as I think I forget things
 like \t
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~--~~~~--~~--~--~---