From: <pat...@us...> - 2009-10-16 19:02:28
|
Revision: 965 http://cishell.svn.sourceforge.net/cishell/?rev=965&view=rev Author: pataphil Date: 2009-10-16 19:02:20 +0000 (Fri, 16 Oct 2009) Log Message: ----------- * Added StringUtilities.interpretObjectAsString and StringUtilities.isEmptyOrWhiteSpace. * Reviewed by Joseph. Modified Paths: -------------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/DateUtilities.java trunk/core/org.cishell.utilities/src/org/cishell/utilities/StringUtilities.java Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/DateUtilities.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/DateUtilities.java 2009-10-14 21:27:55 UTC (rev 964) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/DateUtilities.java 2009-10-16 19:02:20 UTC (rev 965) @@ -82,7 +82,7 @@ endDate.getMonth(), endDate.getDate()); - return (int)startDateCalendar.diffDayPeriods(endDateCalendar); + return (int) startDateCalendar.diffDayPeriods(endDateCalendar); } public static int calculateMonthsBetween(Date startDate, Date endDate) { Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/StringUtilities.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/StringUtilities.java 2009-10-14 21:27:55 UTC (rev 964) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/StringUtilities.java 2009-10-16 19:02:20 UTC (rev 965) @@ -61,4 +61,33 @@ return (String[])filteredStrings.toArray(new String[0]); } + + /* + * This method is really meant to simplify working with Prefuse tables. + * Prefuse table columns are typed. If a column contains a null cell, + * Prefuse types that column as an array type, and it then represents + * null values with arrays of length 0. + */ + public static String interpretObjectAsString(Object object) { + if (object == null) { + return null; + } else if (object instanceof String[]) { + String[] objectAsStringArray = (String[])object; + + if (objectAsStringArray.length == 0) { + return null; + } else { + return objectAsStringArray[0]; + } + } else { + return object.toString(); + } + } + + // TODO Think about instead using a Pattern, "\s*". Don't have to though. + public static boolean isEmptyOrWhiteSpace(String test) { + String trimmed = test.trim(); + + return (trimmed.length() == 0); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |