[Schmitzm-commits] r1157 - in branches/2.2.x/src/schmitzm/lang: . resource/locales tree

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Oct 21 19:08:32 CEST 2010


Author: mojays
Date: 2010-10-21 19:08:31 +0200 (Thu, 21 Oct 2010)
New Revision: 1157

Modified:
   branches/2.2.x/src/schmitzm/lang/ResourceProvider.java
   branches/2.2.x/src/schmitzm/lang/resource/locales/LangResourceBundle.properties
   branches/2.2.x/src/schmitzm/lang/resource/locales/LangResourceBundle_de.properties
   branches/2.2.x/src/schmitzm/lang/tree/OperationTreeParser.java
Log:
ResourceProvider: BugFix to handle "$" as replacement string for ${0}, ${1}, ...
OperationTreeParser: avoid additional "Unexpected error" exceptions on expected IllegalArgumentExceptions
LangResourceBundle: spelling error fixed

Modified: branches/2.2.x/src/schmitzm/lang/ResourceProvider.java
===================================================================
--- branches/2.2.x/src/schmitzm/lang/ResourceProvider.java	2010-10-20 16:04:53 UTC (rev 1156)
+++ branches/2.2.x/src/schmitzm/lang/ResourceProvider.java	2010-10-21 17:08:31 UTC (rev 1157)
@@ -43,6 +43,7 @@
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
+import java.util.regex.Matcher;
 
 import org.apache.log4j.Logger;
 
@@ -525,11 +526,17 @@
 		final Object object = getObject(key, requestedLocale);
 		String string = object != null ? object.toString()
 				: missingResourceString;
+		String replString = null;
 		try {
-			for (int i = 0; i < replParams.length; i++)
-				string = string.replaceAll("\\$\\{" + i + "\\}",
-						replParams[i] != null ? replParams[i].toString()
-								: "null");
+			for (int i = 0; i < replParams.length; i++) {
+              replString = replParams[i] != null ? replParams[i].toString() : "null";
+              // Problem with replacement of '$' sign in
+              // replace string, so first quote these characters
+              // in the replacement
+              replString = Matcher.quoteReplacement(replString);
+              // Perform the "real" replacement for the ${..}
+              string = string.replaceAll("\\$\\{" + i + "\\}", replString);
+			}
 		} catch (Throwable err) {
 			LOGGER.error("Could not replace parameters in resource string '"
 					+ string + "': "

Modified: branches/2.2.x/src/schmitzm/lang/resource/locales/LangResourceBundle.properties
===================================================================
--- branches/2.2.x/src/schmitzm/lang/resource/locales/LangResourceBundle.properties	2010-10-20 16:04:53 UTC (rev 1156)
+++ branches/2.2.x/src/schmitzm/lang/resource/locales/LangResourceBundle.properties	2010-10-21 17:08:31 UTC (rev 1157)
@@ -71,7 +71,7 @@
 OperationTree.err.IllegalOperator=Illegal operator ${0}
 OperationTree.err.IllegalOperatorSyntax=Illegal ${0} syntax '${1}'
 OperationTree.err.ParamSepExpected=Parameter-Separator expected
-OperationTree.err.IllegalCharacter=Illegal character '${0}' (${1} expected)");
+OperationTree.err.IllegalCharacter=Illegal character '${0}' (${1} expected)
 
 OperationTree.err.UnknownNode=Unknown operation tree node: ${0}
 OperationTree.err.UnknownOperator=Unknown operator: ${0}

Modified: branches/2.2.x/src/schmitzm/lang/resource/locales/LangResourceBundle_de.properties
===================================================================
--- branches/2.2.x/src/schmitzm/lang/resource/locales/LangResourceBundle_de.properties	2010-10-20 16:04:53 UTC (rev 1156)
+++ branches/2.2.x/src/schmitzm/lang/resource/locales/LangResourceBundle_de.properties	2010-10-21 17:08:31 UTC (rev 1157)
@@ -68,14 +68,14 @@
 OperationTree.err.MoreParamsExpected=Noch ${0} Funtionsparameter notwendig. Klammer kann nicht schliessen!
 OperationTree.err.UnexpectedBracket=Klammer ${0} kann ${1} nicht schliessen
 OperationTree.err.BracketsNotClosed=Klammer(n) werden nicht geschlossen: ${0}
-OperationTree.err.IllegalOperator=Ung\u00fcltiger Operator ${0}
+OperationTree.err.IllegalOperator=Ung\u00FCltiger Operator ${0}
 OperationTree.err.IllegalOperatorSyntax=Fehlerhafte ${0} Syntax '${1}'
 OperationTree.err.ParamSepExpected=Parameter-Trennzeichen erwartet
-OperationTree.err.IllegalCharacter=Ung\u00fcltiges Zeichen '${0}' (${1} erwartet)");
+OperationTree.err.IllegalCharacter=Ung\u00FCltiges Zeichen '${0}' (${1} erwartet)
 
 OperationTree.err.UnknownNode=Unbekannter Operator-Knoten: ${0}
 OperationTree.err.UnknownOperator=Unbekannter Operator: ${0}
 OperationTree.err.UnknownAliasOperator=Unbekannter Alias-Operator: ${0}
-OperationTree.err.LessParams1=Mindestens ${0} Funktionsparameter ben\u00f6tigt: ${1}(..)
-OperationTree.err.LessParams2=${0} Funktionsparameter ben\u00f6tigt: ${1}(..)
-OperationTree.err.IllegalParam=Illegaler Funktionsparameter ${0} f\u00fcr ${1}(..): ${2} erwartet
+OperationTree.err.LessParams1=Mindestens ${0} Funktionsparameter ben\u00F6tigt\: ${1}(..)
+OperationTree.err.LessParams2=${0} Funktionsparameter ben\u00F6tigt\: ${1}(..)
+OperationTree.err.IllegalParam=Illegaler Funktionsparameter ${0} f\u00FCr ${1}(..)\: ${2} erwartet

Modified: branches/2.2.x/src/schmitzm/lang/tree/OperationTreeParser.java
===================================================================
--- branches/2.2.x/src/schmitzm/lang/tree/OperationTreeParser.java	2010-10-20 16:04:53 UTC (rev 1156)
+++ branches/2.2.x/src/schmitzm/lang/tree/OperationTreeParser.java	2010-10-21 17:08:31 UTC (rev 1157)
@@ -478,6 +478,11 @@
       return new OperationTree( parseRule() );
     } catch (NoSuchElementException err) {
       throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.UnexpectedEOR") );
+    } catch (IllegalArgumentException err) {
+      // The IAEs should be caused by OperationTree-internal problems,
+      // e.g. unexpected character
+      // These errors should not be masked with an addionial "unexpected parse error".
+      throw err;
     } catch (Exception err) {
       throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.UnexpectedError"), err );
     }



More information about the Schmitzm-commits mailing list