[Schmitzm-commits] r1001 - trunk/src/schmitzm/lang

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Sep 14 14:29:01 CEST 2010


Author: alfonx
Date: 2010-09-14 14:29:01 +0200 (Tue, 14 Sep 2010)
New Revision: 1001

Modified:
   trunk/src/schmitzm/lang/LangUtil.java
Log:
Neue Methode:

final static Pattern onlyZerosRegEx = Pattern.compile("^([\\s0.,]*)$");

	/**
	 * Liefert <code>true</code> wenn der String nur Nullen, Leerzeichen, Kommata und/oder
	 * Punkte enth?\195?\164lt.
	 */
	public static boolean onlyZero(String numerString) {
		return onlyZerosRegEx.matcher(numerString).find();
	}

Modified: trunk/src/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/src/schmitzm/lang/LangUtil.java	2010-09-13 17:01:12 UTC (rev 1000)
+++ trunk/src/schmitzm/lang/LangUtil.java	2010-09-14 12:29:01 UTC (rev 1001)
@@ -42,6 +42,7 @@
 import java.util.Locale;
 import java.util.TreeSet;
 import java.util.Vector;
+import java.util.regex.Pattern;
 
 import net.jini.loader.pref.PreferredClassLoader;
 
@@ -57,7 +58,17 @@
  */
 public class LangUtil {
 
+	final static Pattern onlyZerosRegEx = Pattern.compile("^([\\s0.,]*)$");
+
 	/**
+	 * Liefert <code>true</code> wenn der String nur Nullen, Leerzeichen, Kommata und/oder
+	 * Punkte enthält.
+	 */
+	public static boolean onlyZero(String numerString) {
+		return onlyZerosRegEx.matcher(numerString).find();
+	}
+
+	/**
 	 * {@link ResourceProvider}, der die Lokalisation fuer Komponenten des
 	 * Package {@code schmitzm.lang} zur Verfuegung stellt. Diese sind in
 	 * properties-Dateien unter {@code schmitzm.lang.resource.locales}
@@ -208,8 +219,8 @@
 		Arrays.fill(maxSpacePattern, ' ');
 
 		for (int pos; (pos = outString.indexOf('\t')) >= 0;) {
-			outString = outString.replaceFirst("\t", String.valueOf(
-					maxSpacePattern, 0, tabLen - pos % tabLen));
+			outString = outString.replaceFirst("\t",
+					String.valueOf(maxSpacePattern, 0, tabLen - pos % tabLen));
 		}
 		return outString;
 	}
@@ -250,8 +261,8 @@
 	 *            Trenner
 	 * @param maskChar
 	 *            Zeichen, mit dem die aneinandergehaengten Strings gekapselt
-	 *            werden (z.B. Apostroph oder Anfuehrungszeichen). Wenn {@code
-	 *            null} oder leer, werden die Strings nicht gekapselt.
+	 *            werden (z.B. Apostroph oder Anfuehrungszeichen). Wenn
+	 *            {@code null} oder leer, werden die Strings nicht gekapselt.
 	 * @param str
 	 *            aneinanderzuhaengende Stings
 	 */
@@ -268,15 +279,14 @@
 		}
 		return sb.toString();
 	}
-	
 
 	/**
 	 * Fügt einer beliebigen Anzahl vo String ein Prefix hinzu
 	 */
 	public static String[] stringAddPrefix(String prefix, String... str) {
-		String[] back = new String[0]; 
+		String[] back = new String[0];
 		for (String s : str) {
-			back = extendArray(back, prefix+s);
+			back = extendArray(back, prefix + s);
 		}
 		return back;
 	}
@@ -502,11 +512,11 @@
 	 */
 	public static <T> T[] cloneArray(T[] source, boolean replNull,
 			T... replElem) {
-        if ( source == null )
-          return null;
-      
-		T[] newArray = java.util.Arrays.copyOf(source, Math.max(source.length,
-				replElem.length));
+		if (source == null)
+			return null;
+
+		T[] newArray = java.util.Arrays.copyOf(source,
+				Math.max(source.length, replElem.length));
 		for (int i = 0; i < replElem.length; i++)
 			if (replNull || replElem[i] != null)
 				newArray[i] = replElem[i];
@@ -539,11 +549,11 @@
 	 * @return Array von der Groesse {@code max(source.length, replElem.length)}
 	 */
 	public static long[] cloneArray(long[] source, long... replElem) {
-        if ( source == null )
-          return null;
-      
-		long[] newArray = java.util.Arrays.copyOf(source, Math.max(
-				source.length, replElem.length));
+		if (source == null)
+			return null;
+
+		long[] newArray = java.util.Arrays.copyOf(source,
+				Math.max(source.length, replElem.length));
 		for (int i = 0; i < replElem.length; i++)
 			newArray[i] = replElem[i];
 		return newArray;
@@ -560,11 +570,11 @@
 	 * @return Array von der Groesse {@code max(source.length, replElem.length)}
 	 */
 	public static int[] cloneArray(int[] source, int... replElem) {
-        if ( source == null )
-          return null;
-      
-		int[] newArray = java.util.Arrays.copyOf(source, Math.max(
-				source.length, replElem.length));
+		if (source == null)
+			return null;
+
+		int[] newArray = java.util.Arrays.copyOf(source,
+				Math.max(source.length, replElem.length));
 		for (int i = 0; i < replElem.length; i++)
 			newArray[i] = replElem[i];
 		return newArray;
@@ -581,11 +591,11 @@
 	 * @return Array von der Groesse {@code max(source.length, replElem.length)}
 	 */
 	public static short[] cloneArray(short[] source, short... replElem) {
-        if ( source == null )
-          return null;
-      
-		short[] newArray = java.util.Arrays.copyOf(source, Math.max(
-				source.length, replElem.length));
+		if (source == null)
+			return null;
+
+		short[] newArray = java.util.Arrays.copyOf(source,
+				Math.max(source.length, replElem.length));
 		for (int i = 0; i < replElem.length; i++)
 			newArray[i] = replElem[i];
 		return newArray;
@@ -602,13 +612,13 @@
 	 * @return Array von der Groesse {@code max(source.length, replElem.length)}
 	 */
 	public static byte[] cloneArray(byte[] source, byte... replElem) {
-      if ( source == null )
-        return null;
-      byte[] newArray = java.util.Arrays.copyOf(source, Math.max(
-          source.length, replElem.length));
-      for (int i = 0; i < replElem.length; i++)
-        newArray[i] = replElem[i];
-      return newArray;
+		if (source == null)
+			return null;
+		byte[] newArray = java.util.Arrays.copyOf(source,
+				Math.max(source.length, replElem.length));
+		for (int i = 0; i < replElem.length; i++)
+			newArray[i] = replElem[i];
+		return newArray;
 	}
 
 	/**
@@ -622,11 +632,11 @@
 	 * @return Array von der Groesse {@code max(source.length, replElem.length)}
 	 */
 	public static double[] cloneArray(double[] source, double... replElem) {
-	    if ( source == null )
-	      return null;
-		
-	    double[] newArray = java.util.Arrays.copyOf(source, Math.max(
-				source.length, replElem.length));
+		if (source == null)
+			return null;
+
+		double[] newArray = java.util.Arrays.copyOf(source,
+				Math.max(source.length, replElem.length));
 		for (int i = 0; i < replElem.length; i++)
 			newArray[i] = replElem[i];
 		return newArray;
@@ -643,11 +653,11 @@
 	 * @return Array von der Groesse {@code max(source.length, replElem.length)}
 	 */
 	public static float[] cloneArray(float[] source, float... replElem) {
-        if ( source == null )
-          return null;
-      
-		float[] newArray = java.util.Arrays.copyOf(source, Math.max(
-				source.length, replElem.length));
+		if (source == null)
+			return null;
+
+		float[] newArray = java.util.Arrays.copyOf(source,
+				Math.max(source.length, replElem.length));
 		for (int i = 0; i < replElem.length; i++)
 			newArray[i] = replElem[i];
 		return newArray;
@@ -664,10 +674,10 @@
 	 * @return Array von der Groesse {@code max(source.length, replElem.length)}
 	 */
 	public static boolean[] cloneArray(boolean[] source, boolean... replElem) {
-	    if ( source == null )
-	      return null;
-		boolean[] newArray = java.util.Arrays.copyOf(source, Math.max(
-				source.length, replElem.length));
+		if (source == null)
+			return null;
+		boolean[] newArray = java.util.Arrays.copyOf(source,
+				Math.max(source.length, replElem.length));
 		for (int i = 0; i < replElem.length; i++)
 			newArray[i] = replElem[i];
 		return newArray;
@@ -684,10 +694,10 @@
 	 * @return Array von der Groesse {@code max(source.length, replElem.length)}
 	 */
 	public static char[] cloneArray(char[] source, char... replElem) {
-        if ( source == null )
-          return null;
-		char[] newArray = java.util.Arrays.copyOf(source, Math.max(
-				source.length, replElem.length));
+		if (source == null)
+			return null;
+		char[] newArray = java.util.Arrays.copyOf(source,
+				Math.max(source.length, replElem.length));
 		for (int i = 0; i < replElem.length; i++)
 			newArray[i] = replElem[i];
 		return newArray;
@@ -903,8 +913,8 @@
 	 *            Pfade, in denen der ClassLoader nach Klassen sucht
 	 */
 	public static ClassLoader createClassLoader(URL[] searchPath) {
-		return URLClassLoader.newInstance(searchPath, ClassLoader
-				.getSystemClassLoader());
+		return URLClassLoader.newInstance(searchPath,
+				ClassLoader.getSystemClassLoader());
 	}
 
 	/**
@@ -1330,8 +1340,8 @@
 	 * 
 	 * @param object
 	 *            ein Objekt
-	 * @return Logger mit dem Namen "NULL", falls das uebergebene Objekt {@code
-	 *         null} ist
+	 * @return Logger mit dem Namen "NULL", falls das uebergebene Objekt
+	 *         {@code null} ist
 	 */
 	public static Logger createLogger(Object object) {
 		if (object == null)



More information about the Schmitzm-commits mailing list