[Schmitzm-commits] r27 - in trunk: . src/schmitzm/data src/schmitzm/data/resource/locales src/schmitzm/geotools/feature src/schmitzm/geotools/feature/resource src/schmitzm/geotools/feature/resource/locales src/schmitzm/lang src/schmitzm/lang/resource src/schmitzm/lang/resource/locales src/schmitzm/lang/tree src/schmitzm/swing src/schmitzm/swing/resource/locales

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Mar 6 14:21:36 CET 2009


Author: mojays
Date: 2009-03-06 14:21:33 +0100 (Fri, 06 Mar 2009)
New Revision: 27

Added:
   trunk/src/schmitzm/geotools/feature/resource/
   trunk/src/schmitzm/geotools/feature/resource/locales/
   trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle.properties
   trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle_de.properties
   trunk/src/schmitzm/lang/resource/
   trunk/src/schmitzm/lang/resource/locales/
   trunk/src/schmitzm/lang/resource/locales/LangResourceBundle.properties
   trunk/src/schmitzm/lang/resource/locales/LangResourceBundle_de.properties
Modified:
   trunk/readme.txt
   trunk/src/schmitzm/data/RasterOperationTree.java
   trunk/src/schmitzm/data/RasterOperationTreeParser.java
   trunk/src/schmitzm/data/resource/locales/DataResourceBundle.properties
   trunk/src/schmitzm/data/resource/locales/DataResourceBundle_de.properties
   trunk/src/schmitzm/geotools/feature/FeatureOperationTree.java
   trunk/src/schmitzm/geotools/feature/FeatureUtil.java
   trunk/src/schmitzm/lang/LangUtil.java
   trunk/src/schmitzm/lang/ResourceProvider.java
   trunk/src/schmitzm/lang/tree/OperationTree.java
   trunk/src/schmitzm/lang/tree/OperationTreeParser.java
   trunk/src/schmitzm/swing/SwingUtil.java
   trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties
   trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties
   trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle_fr.properties
Log:
readme.txt: Informations about resource bundles
localization for OperationTree/OperationTreeParser
localization for FeatureOperationTree/FeatureOperationTreeParser 
localization for RasterOperationTree/RasterOperationTreeParser

Modified: trunk/readme.txt
===================================================================
--- trunk/readme.txt	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/readme.txt	2009-03-06 13:21:33 UTC (rev 27)
@@ -5,6 +5,14 @@
 === http://wald.intevation.org/projects/schmitzm/          ===
 ==============================================================
 
+This file contains some informations ...
+
+(1) about the dependencies of the SCHMITZM library
+(2) about localization in SCHMITZM
+
+-----------------------------------------------------------
+(1) Dependencies to other libraries
+-----------------------------------------------------------
 Because SCHMITZM is not an executable application, but an
 library for experienced programmers, I renounced to put all
 necessary libraries to the project.
@@ -31,3 +39,32 @@
 folder. But please DO NOT USE, MODIFY AND COMMIT THIS FILES,
 but instead copy first '.classpass' and '.project' to SCHMITZM
 root folder!!
+
+
+-----------------------------------------------------------
+(2) Localization in SCHMITZM library
+-----------------------------------------------------------
+Localization is done by the SCHMITZM class ResourceProvider, which is
+an extension to standard Java ResourceBundle.
+For example ResourceProvider.getString(..) allowes to specify
+additional parameters to fill wildcards ${0}, ${1}, ${2}, ... in the
+localization strings (see ResourceProvider class for more details).
+
+The SCHMITZM library contains resource bundles in the following
+packages, each located in sub-folders <package>/resource/locales:
+
+- schmitzm.data              -> DataResourceBundle
+- schmitzm.geotools.feature  -> FeatureResourceBundle
+- schmitzm.geotools.gui      -> GTResourceBundle
+- schmitzm.lang              -> LangResourceBundle
+- schmitzm.swing             -> SwingResourceBundle
+- skrueger.swing             -> SwingResourceBundle
+
+If you want SCHMITZM to provide an additional language, you have to
+translate all of these ResourceBundles.
+
+
+===========================================================
+http://wald.intevation.org/projects/xulu/
+http://wald.intevation.org/projects/schmitzm/
+===========================================================

Modified: trunk/src/schmitzm/data/RasterOperationTree.java
===================================================================
--- trunk/src/schmitzm/data/RasterOperationTree.java	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/data/RasterOperationTree.java	2009-03-06 13:21:33 UTC (rev 27)
@@ -80,7 +80,7 @@
     if ( result instanceof Boolean )
       result = (Boolean)result ? 1 : 0;
     if ( !(result instanceof Number) )
-      throw new UnsupportedOperationException("RasterCalculator can only handle numeric results: "+result);
+      throw new UnsupportedOperationException( DataUtil.RESOURCE.getString("RasterOperationTree.err.NonNumericResult", result) );
     return ((Number)result).doubleValue();
   }
 
@@ -110,7 +110,7 @@
       RasterFilter   filter      = getInputFilter( filterRefereceNode.getFilterNumber() );
       BinaryTreeNode operandNode = filterRefereceNode.getLeftChild();
       if ( !(operandNode instanceof RasterOperationTree.RasterReferenceNode) )
-        throw new UnsupportedOperationException("Filter can only be applied on a raster reference");
+        throw new UnsupportedOperationException( DataUtil.RESOURCE.getString("RasterOperationTree.err.FilterReferenceNotAllowed") );
       ReadableGrid   raster      = getInputRaster( ((RasterReferenceNode)operandNode).getObject() );
       return filter.evaluate(raster,x, y);
     }
@@ -168,8 +168,9 @@
    */
   private ReadableGrid getInputRaster(int rasterNo) {
     if ( rasterNo >= inputRaster.length ) {
-      String allowedStr = ( inputRaster.length > 0 ) ? "allowed: 0 to "+(inputRaster.length-1) : "none allowed";
-      throw new IllegalArgumentException("Invalid input raster reference '#"+rasterNo+"' ("+allowedStr+")");
+      String allowedStr = ( inputRaster.length > 0 ) ? DataUtil.RESOURCE.getString( "RasterOperationTree.err.AllowedIdx", inputRaster.length-1 )
+                                                     : DataUtil.RESOURCE.getString( "RasterOperationTree.err.NoneAllowed");
+      throw new IllegalArgumentException( DataUtil.RESOURCE.getString("RasterOperationTree.err.InvalidRasterReference",rasterNo,allowedStr) ); 
     }
     return inputRaster[rasterNo];
   }
@@ -182,8 +183,9 @@
    */
   private RasterFilter getInputFilter(int filterNo) {
     if ( filterNo >= inputFilter.length ) {
-      String allowedStr = ( inputFilter.length > 0 ) ? "allowed: 0 to "+(inputFilter.length-1) : "none allowed";
-      throw new IllegalArgumentException("Invalid input filter reference 'F"+inputFilter+"' ("+allowedStr+")");
+      String allowedStr = ( inputFilter.length > 0 ) ? DataUtil.RESOURCE.getString( "RasterOperationTree.err.AllowedIdx", inputFilter.length-1 )
+                                                     : DataUtil.RESOURCE.getString( "RasterOperationTree.err.NoneAllowed");
+      throw new IllegalArgumentException( DataUtil.RESOURCE.getString("RasterOperationTree.err.InvalidFilterReference",inputFilter,allowedStr) ); 
     }
     return inputFilter[filterNo];
   }

Modified: trunk/src/schmitzm/data/RasterOperationTreeParser.java
===================================================================
--- trunk/src/schmitzm/data/RasterOperationTreeParser.java	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/data/RasterOperationTreeParser.java	2009-03-06 13:21:33 UTC (rev 27)
@@ -77,7 +77,7 @@
     if (token.startsWith("F")) {
       BinaryTreeNode operandNode = parseRulePart();
       if ( !(operandNode instanceof RasterOperationTree.RasterReferenceNode) )
-        throw new UnsupportedOperationException("Filter can only be applied on a raster reference");
+        throw new UnsupportedOperationException( DataUtil.RESOURCE.getString("RasterOperationTree.err.FilterReferenceNotAllowed") );
       return new RasterOperationTree.FilterReferenceNode(getIntFromString(token.substring(1)),operandNode);
     }
 

Modified: trunk/src/schmitzm/data/resource/locales/DataResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/data/resource/locales/DataResourceBundle.properties	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/data/resource/locales/DataResourceBundle.properties	2009-03-06 13:21:33 UTC (rev 27)
@@ -1,6 +1,6 @@
 # -----------------------------------------------------------
 # ------ Default Translations (english) for components ------
-# ------ in Package schmitz.data                       ------
+# ------ in Package schmitzm.data                      ------
 # -----------------------------------------------------------
 
 RasterDim.GridWidth=Grid width
@@ -9,3 +9,11 @@
 RasterDim.CellHeight=Cell height
 RasterDim.SampleType=Grid sample type
 RasterDim.ErrorMess=${0} of '${1}' is incompatible to '${2}'...
+
+# --- Translations for RasterOperationTree / RasterOperationTreeParser
+RasterOperationTree.AllowedIdx=allowed: 0 to ${0}
+RasterOperationTree.NoneAllowed=none allowed
+RasterOperationTree.err.NonNumericResult=RasterCalculator can only handle numeric results: ${0}
+RasterOperationTree.err.FilterReferenceNotAllowed=Filter can only be applied on a raster reference
+RasterOperationTree.err.InvalidRasterReference=Invalid input raster reference '#${0}' (${1})
+RasterOperationTree.err.InvalidFilterReference=Invalid input filter reference 'F${0}' (${1})

Modified: trunk/src/schmitzm/data/resource/locales/DataResourceBundle_de.properties
===================================================================
--- trunk/src/schmitzm/data/resource/locales/DataResourceBundle_de.properties	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/data/resource/locales/DataResourceBundle_de.properties	2009-03-06 13:21:33 UTC (rev 27)
@@ -1,6 +1,6 @@
 # ------------------------------------------------
 # ------ German Translations for components ------
-# ------ in Package schmitz.data            ------
+# ------ in Package schmitzm.data           ------
 # ------------------------------------------------
 
 RasterDim.GridWidth=Raster-Breite
@@ -9,3 +9,11 @@
 RasterDim.CellHeight=Zellen-Hoehe
 RasterDim.SampleType=Raster-Datentyp
 RasterDim.ErrorMess=${0} von '${1}' ist nicht kompatibel zu '${2}'...
+
+# --- Translations for RasterOperationTree / RasterOperationTreeParser
+RasterOperationTree.AllowedIdx=erlaubt: 0 to ${0}
+RasterOperationTree.NoneAllowed=keine erlaubt
+RasterOperationTree.err.NonNumericResult=RasterCalculator kann nur numerische Ergebnisse verarbeiten: ${0}
+RasterOperationTree.err.FilterReferenceNotAllowed=Filter kann nur auf Raster-Referenzen angewandt werden
+RasterOperationTree.err.InvalidRasterReference=Ungültige Raster-Referenz '#${0}' (${1})
+RasterOperationTree.err.InvalidFilterReference=Ungültige Filter-Referenz 'F${0}' (${1})

Modified: trunk/src/schmitzm/geotools/feature/FeatureOperationTree.java
===================================================================
--- trunk/src/schmitzm/geotools/feature/FeatureOperationTree.java	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/geotools/feature/FeatureOperationTree.java	2009-03-06 13:21:33 UTC (rev 27)
@@ -13,6 +13,7 @@
 
 import org.geotools.feature.Feature;
 
+import schmitzm.lang.LangUtil;
 import schmitzm.lang.tree.OperationTree;
 import schmitzm.lang.tree.BinaryTreeNode;
 import schmitzm.lang.tree.TreeNode;
@@ -77,7 +78,7 @@
       int attrIdx = ((AttributeIndexReferenceNode)opTreeNode).getObject();
       Object object = feature.getAttribute( attrIdx );
       if ( object == null )
-        throw new UnsupportedOperationException("FeatureOperationTree can not evaluate null-Attributes: "+attrIdx);
+        throw new UnsupportedOperationException( FeatureUtil.RESOURCE.getString("FeatureOperationTree.err.NullAttr",attrIdx) );
 //      if ( !(object instanceof Number) )
 //        throw new UnsupportedOperationException("FeatureOperationTree only can evaluate numeric Attributes: Attribute "+attrIdx+" is of type "+object.getClass().getSimpleName());
 //      return ((Number)object).doubleValue();
@@ -89,9 +90,9 @@
       String attrName = ((AttributeNameReferenceNode)opTreeNode).getObject();
       Object object = feature.getAttribute( attrName );
       if ( feature.getFeatureType().getAttributeType( attrName ) == null )
-        throw new UnsupportedOperationException("Unknown feature attribute: "+attrName);
+        throw new UnsupportedOperationException( FeatureUtil.RESOURCE.getString("FeatureOperationTree.err.UnknownAttr",attrName) );
       if ( object == null )
-        throw new UnsupportedOperationException("FeatureOperationTree can not evaluate null-Attributes: "+attrName);
+        throw new UnsupportedOperationException( FeatureUtil.RESOURCE.getString("FeatureOperationTree.err.NullAttr",attrName) );
 //      if ( !(object instanceof Number) )
 //        throw new UnsupportedOperationException("FeatureOperationTree can only evaluate numeric Attributes: '"+attrName+"' is of type "+object.getClass().getSimpleName());
 //      return ((Number)object).doubleValue();

Modified: trunk/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2009-03-06 13:21:33 UTC (rev 27)
@@ -22,6 +22,7 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.Vector;
@@ -59,6 +60,8 @@
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
 import schmitzm.lang.LangUtil;
+import schmitzm.lang.ResourceProvider;
+
 import com.vividsolutions.jts.geom.Geometry;
 import com.vividsolutions.jts.geom.GeometryFactory;
 import com.vividsolutions.jts.geom.LineString;
@@ -77,6 +80,12 @@
  * @version 1.1
  */
 public class FeatureUtil {
+  /** {@link ResourceProvider}, der die Lokalisation fuer Komponenten
+   *  des Package {@code schmitzm.geotools.feature} zur Verfuegung stellt. Diese sind
+   *  in properties-Dateien unter {@code schmitzm.geotools.feature.resource.locales}
+   *  hinterlegt. */
+  public static ResourceProvider RESOURCE = new ResourceProvider( LangUtil.extendPackagePath(FeatureUtil.class,"resource.locales.FeatureResourceBundle"), Locale.ENGLISH );
+
   private static final Logger LOGGER = LangUtil.createLogger(FeatureUtil.class);
 
   private static final String DEFAULT_VECTOR_STYLE_NAME = "default vector style";

Added: trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle.properties	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle.properties	2009-03-06 13:21:33 UTC (rev 27)
@@ -0,0 +1,8 @@
+# -----------------------------------------------------------
+# ------ Default Translations (english) for components ------
+# ------ in Package schmitzm.geotools.feature          ------
+# -----------------------------------------------------------
+
+# --- Translations for FeatureOperationTree / FeatureOperationTreeParser
+FeatureOperationTree.err.NullAttr=FeatureOperationTree can not evaluate null-Attributes: ${0}
+FeatureOperationTree.err.UnknownAttr=Unknown feature attribute: ${0}

Added: trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle_de.properties
===================================================================
--- trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle_de.properties	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/geotools/feature/resource/locales/FeatureResourceBundle_de.properties	2009-03-06 13:21:33 UTC (rev 27)
@@ -0,0 +1,8 @@
+# --------------------------------------------------
+# ------ German Translations for components   ------
+# ------ in Package schmitzm.geotools.feature ------
+# --------------------------------------------------
+
+# --- Translations for FeatureOperationTree / FeatureOperationTreeParser
+FeatureOperationTree.err.NullAttr=FeatureOperationTree keine null-Attribute auswerten: ${0}
+FeatureOperationTree.err.UnknownAttr=Unbekanntes Feature-Attribut: ${0}

Modified: trunk/src/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/src/schmitzm/lang/LangUtil.java	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/lang/LangUtil.java	2009-03-06 13:21:33 UTC (rev 27)
@@ -13,6 +13,7 @@
 
 import java.util.AbstractCollection;
 import java.util.Collection;
+import java.util.Locale;
 import java.util.TreeSet;
 import java.util.Vector;
 import java.util.Arrays;
@@ -25,6 +26,8 @@
 import org.apache.log4j.Logger;
 import org.apache.log4j.Category;
 
+import schmitzm.swing.SwingUtil;
+
 /**
  * Diese Klasse stellt Hilfsfunktionen fuer Basisoperationen bereit.
  * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
@@ -32,6 +35,11 @@
  */
 public class LangUtil {
 
+  /** {@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}
+   *  hinterlegt. */
+  public static ResourceProvider RESOURCE = new ResourceProvider( extendPackagePath(LangUtil.class,"resource.locales.LangResourceBundle"), Locale.ENGLISH );
 
   /**
    * Liefert den einfachen Namen einer Klasse (ohne Package) oder den

Modified: trunk/src/schmitzm/lang/ResourceProvider.java
===================================================================
--- trunk/src/schmitzm/lang/ResourceProvider.java	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/lang/ResourceProvider.java	2009-03-06 13:21:33 UTC (rev 27)
@@ -291,7 +291,7 @@
     Object object = getObject(key);
     String string = object != null ? object.toString() : missingResourceString;
     for (int i=0; i<replParams.length; i++)
-      string = string.replaceAll("\\$\\{"+i+"\\}", replParams[i].toString());
+      string = string.replaceAll("\\$\\{"+i+"\\}", replParams[i] != null ? replParams[i].toString() : "null");
     return string;
   }
 

Added: trunk/src/schmitzm/lang/resource/locales/LangResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/lang/resource/locales/LangResourceBundle.properties	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/lang/resource/locales/LangResourceBundle.properties	2009-03-06 13:21:33 UTC (rev 27)
@@ -0,0 +1,26 @@
+# -----------------------------------------------------------
+# ------ Default Translations (english) for components ------
+# ------ in Package schmitzm.lang                      ------
+# -----------------------------------------------------------
+
+# --- Translations for OperationTree / OperationTreeParser
+OperationTree.Integer=Integer
+OperationTree.Number=Number
+OperationTree.err.ParseErrorMess=Parse-Error at "${0}": ${1}
+OperationTree.err.UnexpectedEOR=Unexpected end of rule!
+OperationTree.err.UnexpectedError=Unexpected error!
+OperationTree.err.TokenNotExpected=${0} not expected
+OperationTree.err.MoreParamsExpected=${0} more function parameters expected. Bracket can not close!
+OperationTree.err.UnexpectedBracket=Bracket ${0} can not close ${1}
+OperationTree.err.BracketsNotClosed=Bracket(s) not closed: ${0}
+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.UnknownNode=Unknown operation tree node: ${0}
+OperationTree.err.UnknownOperator=Unknown operator: ${0}
+OperationTree.err.UnknownAliasOperator=Unknown alias operator: ${0}
+OperationTree.err.LessParams1=At least ${0} function parameters expected: ${1}(..)
+OperationTree.err.LessParams2=${0} function parameters expected: ${1}(..)
+OperationTree.err.IllegalParam=Illegal parameter ${0} for ${1}(..): ${2} expected

Added: trunk/src/schmitzm/lang/resource/locales/LangResourceBundle_de.properties
===================================================================
--- trunk/src/schmitzm/lang/resource/locales/LangResourceBundle_de.properties	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/lang/resource/locales/LangResourceBundle_de.properties	2009-03-06 13:21:33 UTC (rev 27)
@@ -0,0 +1,26 @@
+# ------------------------------------------------
+# ------ German Translations for components ------
+# ------ in Package schmitzm.lang           ------
+# ------------------------------------------------
+
+# --- Translations for OperationTree / OperationTreeParser
+OperationTree.Integer=Ganzzahl
+OperationTree.Number=Numerisch
+OperationTree.err.ParseErrorMess=Parser-Fehler bei "${0}": ${1}
+OperationTree.err.UnexpectedEOR=Unerwartetes Ende der Formel!
+OperationTree.err.UnexpectedError=Unerwarteter Fehler!
+OperationTree.err.TokenNotExpected=${0} nicht erlaubt
+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ültiger Operator ${0}
+OperationTree.err.IllegalOperatorSyntax=Fehlerhafte ${0} Syntax '${1}'
+OperationTree.err.ParamSepExpected=Parameter-Trennzeichen erwartet
+OperationTree.err.IllegalCharacter=Ungültiges 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ötigt: ${1}(..)
+OperationTree.err.LessParams2=${0} Funktionsparameter benötigt: ${1}(..)
+OperationTree.err.IllegalParam=Illegaler Funktionsparameter ${0} für ${1}(..): ${2} erwartet

Modified: trunk/src/schmitzm/lang/tree/OperationTree.java
===================================================================
--- trunk/src/schmitzm/lang/tree/OperationTree.java	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/lang/tree/OperationTree.java	2009-03-06 13:21:33 UTC (rev 27)
@@ -197,7 +197,7 @@
       return performOperation(operator,operand1,operand2);
     }
 
-    throw new UnsupportedOperationException("Unknown operation tree node: "+opTreeNode.getClass().getName());
+    throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.UnknownNode",opTreeNode.getClass().getName()) );
   }
 
   /**
@@ -216,19 +216,19 @@
    */
   protected Object performOperation(String operator, Object[] operand) {
     if ( operator == null )
-      throw new UnsupportedOperationException("Unknown operator: "+operator);
+      throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.UnknownOperator",operator) );
 
     operator = operator.toUpperCase();
 
     if ( operator.equals("SUBSTR") ) {
       if ( operand.length < 2 )
-        throw new UnsupportedOperationException("At least 2 function parameters expected: SUBSTR(..)");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.LessParams1",2,operator) );
       if ( !(operand[0] instanceof String) )
-        throw new UnsupportedOperationException("Illegal parameter 1 for SUBSTR(..): String expected");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.IllegalParam",1,operator,"String") );
       if ( !(operand[1] instanceof Number) )
-        throw new UnsupportedOperationException("Illegal parameter 2 for SUBSTR(..): Number expected");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.IllegalParam",2,operator,"Number") );
       if ( operand.length > 2 && !(operand[2] instanceof Number) )
-        throw new UnsupportedOperationException("Illegal parameter 3 for SUBSTR(..): Number expected");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.IllegalParam",3,operator,"Number") );
 
       String str      = (String)operand[0];
       int    startPos = ((Number)operand[1]).intValue();
@@ -240,13 +240,13 @@
 
     if ( operator.equals("SPLIT") ) {
       if ( operand.length < 2 )
-        throw new UnsupportedOperationException("At least 2 function parameters expected: SUBSTR(..)");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.LessParams1",2,operator) );
       if ( !(operand[0] instanceof String) )
-        throw new UnsupportedOperationException("Illegal parameter 1 for SPLIT(..): String expected");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.IllegalParam",1,operator,"String") );
       if ( !(operand[1] instanceof String) )
-        throw new UnsupportedOperationException("Illegal parameter 2 for SPLIT(..): String expected");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.IllegalParam",2,operator,"String") );
       if ( operand.length > 2 && !(operand[2] instanceof Number) )
-        throw new UnsupportedOperationException("Illegal parameter 3 for SPLIT(..): Number expected");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.IllegalParam",3,operator,"Number") );
 
       String[] result = operand[0].toString().split(operand[1].toString());
       int      idx    = operand.length > 2 ? ((Number)operand[2]).intValue() : 0;
@@ -257,13 +257,13 @@
 
     if ( operator.equals("REPLALL") ) {
       if ( operand.length != 3 )
-        throw new UnsupportedOperationException("3 function parameters expected: REPLALL(..)");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.LessParams2",3,operator) );
       if ( !(operand[0] instanceof String) )
-        throw new UnsupportedOperationException("Illegal parameter 1 for REPLALL(..): String expected");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.IllegalParam",1,operator,"String") );
       if ( !(operand[1] instanceof String) )
-        throw new UnsupportedOperationException("Illegal parameter 2 for REPLALL(..): String expected");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.IllegalParam",2,operator,"String") );
       if ( !(operand[2] instanceof String) )
-        throw new UnsupportedOperationException("Illegal parameter 3 for REPLALL(..): String expected");
+        throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.IllegalParam",3,operator,"String") );
 
       String result = operand[0].toString().replaceAll(operand[1].toString(), operand[2].toString());
       return result;
@@ -275,8 +275,8 @@
         paramMess += ", ";
       paramMess += (op != null) ? op.getClass().getSimpleName() : null;
     }
-    throw new UnsupportedOperationException("Unknown operator: "+operator+" ("+paramMess+")");
-  }
+    throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.UnknownOperator",operator+" ("+paramMess+")") );
+}
 
   /**
    * Wertet einen 2-stelligen Operator aus. Als Operator unterstuetzt diese
@@ -324,7 +324,7 @@
     if ( operand1 == null && operand2 == null )
       return null;
     if ( operator == null )
-      throw new UnsupportedOperationException("Unknown operator: "+operator);
+      throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.UnknownOperator",operator) );
 
     operator = operator.toUpperCase();
 
@@ -398,8 +398,8 @@
 
     String op1Class = (operand1 != null) ? operand1.getClass().getSimpleName() : null;
     String op2Class = (operand2 != null) ? operand2.getClass().getSimpleName() : null;
-    throw new UnsupportedOperationException("Unknown operator: "+operator+" ("+op1Class+", "+op2Class+")");
-  }
+    throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.UnknownOperator",operator+" ("+op1Class+", "+op2Class+")") );
+}
 
   /**
    * Wertet einen 1-stelligen Operator aus. Als Operator unterstuetzt diese
@@ -441,7 +441,7 @@
    */
   protected Object performOperation(String operator, Object operand) {
     if ( operator == null )
-      throw new UnsupportedOperationException("Unknown operator: "+operator);
+      throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.UnknownOperator",operator) );
 
     operator = operator.toUpperCase();
 
@@ -498,8 +498,8 @@
         return op.toLowerCase();
     }
     String opClass = (operand != null) ? operand.getClass().getSimpleName() : null;
-    throw new UnsupportedOperationException("Unknown operator: "+operator+"("+opClass+")");
-  }
+    throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.UnknownOperator",operator+"("+opClass+")") );
+}
 
   /**
    * Wertet einen 0-stelligen Operator (Alias oder Variable) aus.
@@ -518,7 +518,7 @@
       return Double.NaN;
     if ( operator.equals("CURR_MILLIS") )
       return System.currentTimeMillis();
-    throw new UnsupportedOperationException("Unknown alias operator: "+operator);
+    throw new UnsupportedOperationException( LangUtil.RESOURCE.getString("OperationTree.err.UnknownAliasOperator",operator) );
   }
 
   ///////////////////////////////////////////////////////////////////

Modified: trunk/src/schmitzm/lang/tree/OperationTreeParser.java
===================================================================
--- trunk/src/schmitzm/lang/tree/OperationTreeParser.java	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/lang/tree/OperationTreeParser.java	2009-03-06 13:21:33 UTC (rev 27)
@@ -11,7 +11,10 @@
 
 package schmitzm.lang.tree;
 
+import java.util.NoSuchElementException;
+
 import schmitzm.lang.tree.BinaryTreeNode;
+import schmitzm.lang.LangUtil;
 import schmitzm.lang.PushbackStringTokenizer;
 import schmitzm.lang.tree.OperationTree.*;
 import org.apache.log4j.Logger;
@@ -426,7 +429,15 @@
 //    tok  = new PushbackStringTokenizer(rule,delimiter,true);
 //    return new OperationTree( parseRulePart() );
     tok  = new PushbackStringTokenizer(rule,delimiter,true);
-    return new OperationTree( parseRule() );
+    try {
+      return new OperationTree( parseRule() );
+    } catch (NoSuchElementException err) {
+      throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.UnexpectedEOR") );
+    } catch (Exception err) {
+      throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.UnexpectedError") );
+    }
+    // kann nicht vorkommen!!
+    return null;
   }
 
 //  /**
@@ -580,7 +591,7 @@
 
     // aktuelle Klammerung ermitteln
     if ( openBrackets.length() == 0 )
-        throwParseError(token + " not expected!");
+        throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.TokenNotExpected",token) );
     char openBracket = openBrackets.charAt(0);
 
     // Schliessende Klammer
@@ -597,9 +608,9 @@
       // Wenn keine oeffnende Klammer auf Stack liegt (sondern ein Parameter-Zaehler)
       // kann Klammer nicht schliessen, da noch ein Parameter erwartet wird
       if ( !isOpeningBracket(String.valueOf(openBracket)) )
-        throwParseError(openBracket+" more function parameters expected. Bracket can not close!'");
+        throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.MoreParamsExpected",openBracket) );
       if ( !checkCorrespondingBrackets(openBracket,token.charAt(0)) )
-        throwParseError("Bracket " + token + " can not close " + openBracket);
+        throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.UnexpectedBracket",token,openBracket) );
 
       return funcEnding ? RuleClosingType.func_pram : RuleClosingType.rule_part;
     }
@@ -607,7 +618,7 @@
     // Trenner zwischen Funktions-Parametern
     if ( isParameterSeperator(token) ) {
       if ( isOpeningBracket(String.valueOf(openBracket)) )
-        throwParseError(token+" not expected!'");
+        throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.TokenNotExpected",token) );
       return RuleClosingType.func_pram;
     }
 
@@ -622,7 +633,7 @@
   private void checkRemainingBrackets() {
     // keine Token mehr, aber noch offene Klammern
     if ( !tok.hasMoreTokens() && openBrackets.length() > 0 )
-      throwParseError("Bracket"+(openBrackets.length() > 1 ? "s" : "")+" "+openBrackets.toString()+" not closed!");
+      throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.BracketsNotClosed",openBrackets.toString()) );
   }
 
   /**
@@ -651,7 +662,7 @@
 
       // Pruefen, ob es wirklich ein Operator ist
       if ( !isOperatorChar(operator) )
-        throwParseError("Illegal operator " + operator);
+        throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.IllegalOperator", operator) );
       // Sonderfall: boolesche Operatoren u.U. 2-stellig (<=, >=, !=, <>, ==)
       operator = expandOperator(operator);
 
@@ -708,7 +719,7 @@
 
       // Pruefen, ob es wirklich ein Operator ist
       if ( !isOperatorChar(operator) )
-        throwParseError("Illegal operator " + operator);
+        throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.IllegalOperator", operator) );
       // Sonderfall: boolesche Operatoren u.U. 2-stellig (<=, >=, !=, <>, ==)
       operator = expandOperator(operator);
 
@@ -767,7 +778,7 @@
 
       // Pruefen, ob es wirklich ein Operator ist
       if ( !isOperatorChar(operator) )
-        throwParseError("Illegal operator '" + operator + "'");
+        throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.IllegalOperator", operator) );
       // Sonderfall: boolesche Operatoren u.U. 2-stellig (<=, >=, !=, <>, ==)
       operator = expandOperator(operator);
 
@@ -961,7 +972,7 @@
     // naechstes Token muss eine oeffnende Klammer sein!
     String token = nextNonWSToken();
     if ( !token.equals("(") )
-      throwParseError("Illegal "+operator+" syntax '" + token + "'");
+    throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.IllegalOperatorSyntax", operator, token) );
     openBrackets.insert(0,"(");
 
     openBrackets.insert(0, String.valueOf(paramCount-1)); // noch X weitere Parameter (Trenner) erwartet
@@ -970,7 +981,7 @@
       // Parameter fuer ITE lesen
       paramNode[i] = parseRule();
       if ( !isParameterSeperator( tok.nextToken() ) ) // Seperator entfernen
-        throwParseError("Parameter-Seperator expected");
+        throwParseError( LangUtil.RESOURCE.getString("OperationTree.err.ParamSepExpected") );
       openBrackets.replace(0, 1, String.valueOf(paramCount-(i+2))); // noch X-1 weiterer Parameter (Trenner) erwartet
     }
     // den letzten Parameter parsen
@@ -999,7 +1010,7 @@
     String errorPos = tok.getReadTokens();
 //    // Die Klammer entfernen, die am Anfang kuenstlich eingefuegt wurde
 //    errorPos = errorPos.substring(1);
-    throw new IllegalArgumentException("Parse-Error at '"+errorPos+"': "+mess);
+    throw new IllegalArgumentException( LangUtil.RESOURCE.getString("OperationTree.err.ParseErrorMess", errorPos, mess) );
   }
 
   /**
@@ -1035,7 +1046,11 @@
       return Integer.parseInt(token);
     }
     catch (Exception err) {
-      throwParseError("Illegal character '" + token + "' (int expected)");
+      throwParseError( LangUtil.RESOURCE.getString(
+                                 "OperationTree.err.IllegalCharacter",
+                                 token,
+                                 LangUtil.RESOURCE.getString("OperationTree.Integer")
+      ));
     }
     return 0;
   }
@@ -1057,7 +1072,11 @@
       return Double.parseDouble(token);
     }
     catch (Exception err) {
-      throwParseError("Illegal character '" + token + "' (number expected)");
+      throwParseError( LangUtil.RESOURCE.getString(
+                               "OperationTree.err.IllegalCharacter",
+                               token,
+                               LangUtil.RESOURCE.getString("OperationTree.Number")
+      ));
     }
     return 0;
   }

Modified: trunk/src/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/src/schmitzm/swing/SwingUtil.java	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/swing/SwingUtil.java	2009-03-06 13:21:33 UTC (rev 27)
@@ -64,7 +64,7 @@
 
   /** {@link ResourceProvider}, der die Lokalisation fuer GUI-Komponenten
    *  des Package {@code schmitzm.swing} zur Verfuegung stellt. Diese sind
-   *  in properties-Datein unter {@code schmitzm.swing.resource.locales}
+   *  in properties-Dateien unter {@code schmitzm.swing.resource.locales}
    *  hinterlegt. */
   public static ResourceProvider RESOURCE = new ResourceProvider( LangUtil.extendPackagePath(SwingUtil.class,"resource.locales.SwingResourceBundle"), Locale.ENGLISH );
 

Modified: trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2009-03-06 13:21:33 UTC (rev 27)
@@ -1,6 +1,6 @@
 # ---------------------------------------------------------------
 # ------ Default Translations (english) for GUI components ------
-# ------ in Package schmitz.swing                          ------
+# ------ in Package schmitzm.swing                         ------
 # ---------------------------------------------------------------
 
 Ok=Ok

Modified: trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties
===================================================================
--- trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties	2009-03-06 13:21:33 UTC (rev 27)
@@ -1,6 +1,6 @@
 # ----------------------------------------------------
 # ------ German Translations for GUI components ------
-# ------ in Package schmitz.swing               ------
+# ------ in Package schmitzm.swing              ------
 # ----------------------------------------------------
 
 Cancel=Abbrechen

Modified: trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle_fr.properties
===================================================================
--- trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle_fr.properties	2009-03-05 17:34:19 UTC (rev 26)
+++ trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle_fr.properties	2009-03-06 13:21:33 UTC (rev 27)
@@ -1,6 +1,6 @@
 # ----------------------------------------------------
 # ------ German Translations for GUI components ------
-# ------ in Package schmitz.swing               ------
+# ------ in Package schmitzm.swing              ------
 # ----------------------------------------------------
 
 Cancel=Abandonner



More information about the Schmitzm-commits mailing list