[Schmitzm-commits] r1725 - trunk/schmitzm-core/src/main/java/de/schmitzm/lang

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Sep 11 13:18:23 CEST 2011


Author: alfonx
Date: 2011-09-11 13:18:23 +0200 (Sun, 11 Sep 2011)
New Revision: 1725

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
Log:


Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2011-09-10 18:44:14 UTC (rev 1724)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2011-09-11 11:18:23 UTC (rev 1725)
@@ -235,40 +235,49 @@
 
 		return combinedDateCal.getTime();
 	}
-	
+
 	/**
 	 * Increases a date by milliseconds.
-	 * @param date date to increase
-	 * @param millies milliseconds to increase the date with
+	 * 
+	 * @param date
+	 *            date to increase
+	 * @param millies
+	 *            milliseconds to increase the date with
 	 * @return a new {@link Date} instance
 	 */
 	public static Date incDate(Date date, long millies) {
-	  if ( date == null )
-	    return null;
-	  return new Date(date.getTime() + millies);
+		if (date == null)
+			return null;
+		return new Date(date.getTime() + millies);
 	}
 
-    /**
-     * Increases a date by days.
-     * @param date date to increase
-     * @param days days to increase the date with
-     * @return a new {@link Date} instance
-     */
-    public static Date incDays(Date date, int days) {
-      return incDate(date, days * DAY_MILLIS);
-    }
+	/**
+	 * Increases a date by days.
+	 * 
+	 * @param date
+	 *            date to increase
+	 * @param days
+	 *            days to increase the date with
+	 * @return a new {@link Date} instance
+	 */
+	public static Date incDays(Date date, int days) {
+		return incDate(date, days * DAY_MILLIS);
+	}
 
-    /**
-     * Decreases a date by days.
-     * @param date date to decrease
-     * @param days days to decrease the date with
-     * @return a new {@link Date} instance
-     */
-    public static Date decDays(Date date, int days) {
-      return incDays(date, -days);
-    }
+	/**
+	 * Decreases a date by days.
+	 * 
+	 * @param date
+	 *            date to decrease
+	 * @param days
+	 *            days to decrease the date with
+	 * @return a new {@link Date} instance
+	 */
+	public static Date decDays(Date date, int days) {
+		return incDays(date, -days);
+	}
 
-    /**
+	/**
 	 * Tries several date formats to parse a date string.
 	 * 
 	 * @param dateStr
@@ -1954,6 +1963,12 @@
 	}
 
 	/**
+	 * // Alle Zeilenumbrüche raus // Geschützte Leerzeichen weg // Tabulator -> Leer
+	 */
+	final static Pattern REMOVE_WHITESPACES_PATTERN = RegexCache.getInstance().getPattern(
+			"[\\n|\\t|\\r|\\u0085|\\u2028|\\u2029|\\u00A0]");
+
+	/**
 	 * Fasst Zeilenumbrüche und sonstige Leerräume zu einem einizgen Leerzeichen zusammen.
 	 * 
 	 * @author gregor
@@ -1963,20 +1978,19 @@
 			return "";
 
 		// Alle Zeilenumbrüche raus
-		Matcher matcher = RegexCache.getInstance().getPattern("[\\n|\\r|\\u0085|\\u2028|\\u2029]").matcher(string);
-		string = matcher.replaceAll(" ");
-
 		// Geschützte Leerzeichen weg
-		matcher = RegexCache.getInstance().getPattern("\\u00A0").matcher(string);
-		string = matcher.replaceAll(" ");
-
 		// Tabulator -> Leer
-		matcher = RegexCache.getInstance().getPattern("\\t").matcher(string);
+		final Matcher matcher = REMOVE_WHITESPACES_PATTERN.matcher(string);
 		string = matcher.replaceAll(" ");
 
+		// matcher = RegexCache.getInstance().getPattern("\\u00A0").matcher(string);
+		// string = matcher.replaceAll(" ");
+		//
+		// matcher = RegexCache.getInstance().getPattern("\\t").matcher(string);
+		// string = matcher.replaceAll(" ");
+
 		// Leerraum konsolidieren
-		matcher = RegexCache.getInstance().getPattern("\\s{2,}").matcher(string);
-		return matcher.replaceAll(" ");
+		return RegexCache.getInstance().getPattern("\\s{2,}").matcher(string).replaceAll(" ");
 	}
 
 }



More information about the Schmitzm-commits mailing list