[Schmitzm-commits] r2061 - in trunk/schmitzm-adresses/src: main/java/de/schmitzm/adresses test/java/de/schmitzm/adresses

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Jun 27 22:31:27 CEST 2012


Author: alfonx
Date: 2012-06-27 22:31:26 +0200 (Wed, 27 Jun 2012)
New Revision: 2061

Modified:
   trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java
   trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java
Log:


Modified: trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java
===================================================================
--- trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java	2012-06-27 14:20:23 UTC (rev 2060)
+++ trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java	2012-06-27 20:31:26 UTC (rev 2061)
@@ -60,12 +60,14 @@
 		if (hn == null)
 			return null;
 
+		Matcher matcher = RegexCache.getInstance().getMatcher("^(\\d+)\\D+\\1", hn);
+		if (matcher.find())
+			hn = matcher.group(1);
+		
 		hn = RegexCache.getInstance().replaceAll(hn, "^0+", "");
+		hn = RegexCache.getInstance().replaceAll(hn, "\\s", "");
+		hn = RegexCache.getInstance().replaceAll(hn, "bis", "-");
 
-		Matcher matcher = RegexCache.getInstance().getMatcher("(\\d+)\\s+\\1", hn);
-		if (matcher.find())
-			return matcher.group(1);
-
 		return hn;
 	}
 
@@ -599,7 +601,7 @@
 
 		strasse = RegexCache.getInstance().replaceAll(strasse, "^Str\\.$", "");
 		
-		strasse = RegexCache.getInstance().replaceFirst(strasse, "([\\d\\s])(?:eg|og|vh|hh)\\s*(?:li|re|links|rechts)$", "$1");
+		strasse = RegexCache.getInstance().replaceFirst(strasse, "([\\d\\s])(?:(?i)eg|og|vh|hh)\\s*(?:(?i)li|re|links|rechts)$", "$1");
 
 		{
 			// Großschreibung aller Anfangsbuchstaben, AUSSER in den Hausnummerzusätzen

Modified: trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java
===================================================================
--- trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java	2012-06-27 14:20:23 UTC (rev 2060)
+++ trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java	2012-06-27 20:31:26 UTC (rev 2061)
@@ -350,9 +350,15 @@
 		assertEquals("19", AddrStringUtil.normalizeHn(" 19"));
 		assertEquals("119", AddrStringUtil.normalizeHn("119"));
 		assertEquals("34", AddrStringUtil.normalizeHn("  34 34  "));
+		assertEquals("1", AddrStringUtil.normalizeHn("1-1"));
 		assertEquals("34", AddrStringUtil.normalizeHn("34 34"));
 		assertEquals("34-45", AddrStringUtil.normalizeHn("34-45"));
-		assertEquals("2-2", AddrStringUtil.normalizeHn("2-2"));
+		assertEquals("322-223", AddrStringUtil.normalizeHn("322-223"));
+		assertEquals("322-223", AddrStringUtil.normalizeHn("  322  -   223  "));
+		assertEquals("322", AddrStringUtil.normalizeHn("  322  -   322  "));
+		assertEquals("34/45", AddrStringUtil.normalizeHn("34 / 45"));
+		assertEquals("34-45", AddrStringUtil.normalizeHn("34 bis 45"));
+		assertEquals("2", AddrStringUtil.normalizeHn("2-2"));
 		assertEquals("34", AddrStringUtil.normalizeHn("34"));
 		assertEquals("34", AddrStringUtil.normalizeHn(" 34 "));
 	}



More information about the Schmitzm-commits mailing list