[Schmitzm-commits] r2064 - 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
Thu Jun 28 01:12:10 CEST 2012


Author: alfonx
Date: 2012-06-28 01:12:10 +0200 (Thu, 28 Jun 2012)
New Revision: 2064

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 22:00:52 UTC (rev 2063)
+++ trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java	2012-06-27 23:12:10 UTC (rev 2064)
@@ -66,6 +66,10 @@
 
 		hn = RegexCache.getInstance().replaceAll(hn, "^0+", "");
 		hn = RegexCache.getInstance().replaceAll(hn, "\\s", "");
+		hn = RegexCache.getInstance().replaceAll(hn, "\\+", ",");
+		hn = RegexCache.getInstance().replaceAll(hn, "\\\\", "\\");
+//		hn = RegexCache.getInstance().replaceAll(hn, ",", "");
+//		hn = RegexCache.getInstance().replaceAll(hn, "/", "");
 		hn = RegexCache.getInstance().replaceAll(hn, "bis", "-");
 
 		return hn;
@@ -80,18 +84,15 @@
 		if (hn == null)
 			return null;
 
-		Integer smallestHn = null;
-
 		Matcher m = RegexCache.getInstance().getMatcher("(\\d+)", hn);
 
 		while (m.find()) {
 			Integer h = Integer.valueOf(m.group(1));
 
-			if (smallestHn == null || h < smallestHn)
-				smallestHn = h;
+			return h;
 		}
 
-		return smallestHn;
+		return null;
 	}
 
 	/**

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 22:00:52 UTC (rev 2063)
+++ trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java	2012-06-27 23:12:10 UTC (rev 2064)
@@ -347,14 +347,18 @@
 	public void testSimplyfyHn() {
 		assertEquals(1, AddrStringUtil.simplyfyHn("001"),0);
 		assertEquals(32, AddrStringUtil.simplyfyHn("32-34"),0);
-		assertEquals(32, AddrStringUtil.simplyfyHn("34-32"),0);
+		assertEquals(34, AddrStringUtil.simplyfyHn("34-32"),0);
 		assertEquals(12, AddrStringUtil.simplyfyHn("12/24"),0);
-		assertEquals(1, AddrStringUtil.simplyfyHn("12 bis 24/1"),0);
+		assertEquals(12, AddrStringUtil.simplyfyHn("12+13"),0);
+		assertEquals(12, AddrStringUtil.simplyfyHn("12 bis 24/1"),0);
 	}
 	@Test
 	public void testNormalizeHn() {
 		assertEquals("1", AddrStringUtil.normalizeHn(" 001"));
 		assertEquals("1", AddrStringUtil.normalizeHn("001"));
+		assertEquals("5,7", AddrStringUtil.normalizeHn("5 + 7"));
+		assertEquals("5,7", AddrStringUtil.normalizeHn("5 , 7"));
+		assertEquals("5/7", AddrStringUtil.normalizeHn("5 / 7"));
 		assertEquals("19", AddrStringUtil.normalizeHn(" 19"));
 		assertEquals("119", AddrStringUtil.normalizeHn("119"));
 		assertEquals("34", AddrStringUtil.normalizeHn("  34 34  "));



More information about the Schmitzm-commits mailing list