[Schmitzm-commits] r939 - in trunk: src/schmitzm/geotools/feature src_junit/schmitzm/geotools/feature

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Jul 19 23:35:08 CEST 2010


Author: alfonx
Date: 2010-07-19 23:35:06 +0200 (Mon, 19 Jul 2010)
New Revision: 939

Modified:
   trunk/src/schmitzm/geotools/feature/FeatureUtil.java
   trunk/src_junit/schmitzm/geotools/feature/FeatureUtilTest.java
Log:
Improved the REGEX expression to guess attribute names consisting of [a-zA-Z_] in any CQL / ECQL expression.

Modified: trunk/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2010-07-19 12:06:05 UTC (rev 938)
+++ trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2010-07-19 21:35:06 UTC (rev 939)
@@ -149,7 +149,7 @@
 		if (formel == null)
 			return result;
 
-		String[] split = formel.split("[ /*+-\\^]");
+		String[] split = formel.split("[^a-zA-Z0-9_]");
 
 		for (String attName : split) {
 			// Mögliche Klammern entfernen

Modified: trunk/src_junit/schmitzm/geotools/feature/FeatureUtilTest.java
===================================================================
--- trunk/src_junit/schmitzm/geotools/feature/FeatureUtilTest.java	2010-07-19 12:06:05 UTC (rev 938)
+++ trunk/src_junit/schmitzm/geotools/feature/FeatureUtilTest.java	2010-07-19 21:35:06 UTC (rev 939)
@@ -34,20 +34,28 @@
 
 	@Test
 	public void testGetCQLAttributNames() throws Exception {
-		List<String> aa = FeatureUtil.getCQLAttributNames("de_fr/ddd");
-		assertEquals("de_fr", aa.get(0));
-		assertEquals("ddd", aa.get(1));
-
+		List<String> aa ;
+		
 		aa = FeatureUtil.getCQLAttributNames("fff*-3(de_fr/ddd)/100+2");
 		assertEquals(3, aa.size());
 		assertEquals("fff", aa.get(0));
 		assertEquals("de_fr", aa.get(1));
 		assertEquals("ddd", aa.get(2));
+		
+		aa = FeatureUtil.getCQLAttributNames("gest_1lj/lebeng_ge");
+		assertEquals(2, aa.size());
+		assertEquals("gest_1lj", aa.get(0));
+		assertEquals("lebeng_ge", aa.get(1));
+		
+		aa = FeatureUtil.getCQLAttributNames("de_fr/ddd");
+		assertEquals("de_fr", aa.get(0));
+		assertEquals("ddd", aa.get(1));
 
-		aa = FeatureUtil.getCQLAttributNames("3^a * -3^b*0.3");
-		assertEquals(2, aa.size());
+		aa = FeatureUtil.getCQLAttributNames("3^a * -3^b*0.3 + s^3");
+		assertEquals(3, aa.size());
 		assertEquals("a", aa.get(0));
 		assertEquals("b", aa.get(1));
+		assertEquals("s", aa.get(2));
 
 	}
 



More information about the Schmitzm-commits mailing list