Author: shane.bryzak(a)jboss.com
Date: 2008-11-30 21:43:21 -0500 (Sun, 30 Nov 2008)
New Revision: 9677
Modified:
trunk/src/main/org/jboss/seam/util/Strings.java
Log:
JBSEAM-3745
Modified: trunk/src/main/org/jboss/seam/util/Strings.java
===================================================================
--- trunk/src/main/org/jboss/seam/util/Strings.java 2008-11-30 00:44:50 UTC (rev 9676)
+++ trunk/src/main/org/jboss/seam/util/Strings.java 2008-12-01 02:43:21 UTC (rev 9677)
@@ -30,7 +30,20 @@
public static boolean isEmpty(String string)
{
- return string == null || string.trim().length() == 0;
+ int len;
+ if (string == null || (len = string.length()) == 0)
+ {
+ return true;
+ }
+
+ for (int i = 0; i < len; i++)
+ {
+ if ((Character.isWhitespace(string.charAt(i)) == false))
+ {
+ return false;
+ }
+ }
+ return true;
}
public static String nullIfEmpty(String string)
@@ -52,7 +65,7 @@
for (PropertyDescriptor descriptor : props)
{
builder.append( descriptor.getName() )
- .append("=")
+ .append('=')
.append( descriptor.getReadMethod().invoke(component) )
.append("; ");
}
@@ -95,7 +108,7 @@
{
builder.append(sep).append(object);
}
- return builder.substring(2);
+ return builder.substring(sep.length());
}
public static String toClassNameString(String sep, Object... objects)
@@ -114,7 +127,7 @@
builder.append( object.getClass().getName() );
}
}
- return builder.substring(2);
+ return builder.substring(sep.length());
}
public static String toString(String sep, Class... classes)
@@ -129,8 +142,8 @@
}
public static String toString(InputStream in) throws IOException {
- StringBuffer out = new StringBuffer();
- byte[] b = new byte[4096];
+ final StringBuilder out = new StringBuilder();
+ final byte[] b = new byte[4096];
for ( int n; (n = in.read(b)) != -1; )
{
out.append(new String(b, 0, n));
Show replies by date