[Schmitzm-commits] r2310 - in trunk/schmitzm-core/src/main: java/de/schmitzm/io java/de/schmitzm/lang resources/de/schmitzm/swing/resource/locales

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Thu May 23 15:36:21 CEST 2013


Author: mojays
Date: 2013-05-23 15:36:21 +0200 (Thu, 23 May 2013)
New Revision: 2310

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/io/IOUtil.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
   trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties
   trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties
Log:
IOUtil.getFileExtIdx(.): do not treat dot as file extension delimiter if file name starts with dot (e.g. .classpath)
LangUtil.interpreteCommandLineArguments(.): generic method to put command line arguments in map


Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/io/IOUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/io/IOUtil.java	2013-05-11 15:31:21 UTC (rev 2309)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/io/IOUtil.java	2013-05-23 13:36:21 UTC (rev 2310)
@@ -152,6 +152,10 @@
 		int lastSepIdx = pathOrName.lastIndexOf(File.separatorChar);
 		if (lastPointIdx < lastSepIdx)
 			return -1;
+		// If filename starts with dot, it does not separate the
+		// filename extension
+		if ( lastPointIdx == lastSepIdx+1 ) 
+		  return -1;
 		return lastPointIdx;
 	}
 

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2013-05-11 15:31:21 UTC (rev 2309)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2013-05-23 13:36:21 UTC (rev 2310)
@@ -2774,4 +2774,50 @@
         }
         return sb.toString();
     }
+    
+    
+    /**
+     * Interprets the command line arguments specified by "/x value" or "-x value" and puts
+     * the values in a map. If multiple values are specified for a command, the
+     * map value is a {@link List}.
+     * @param args command line arguments
+     * @param dest destination map (can be {@code null})
+     */
+    public static Map<String,Object> interpreteCommandLineArguments(String[] args, Map<String,Object> dest) {
+      if ( dest == null )
+        dest = new HashMap<String,Object>();
+      if ( args == null )
+        return dest;
+      
+      
+      String lastCmd = "";
+      for (int i=0; i<args.length; i++) {
+        String param = args[i];
+        
+        if ( args[i].startsWith("/") || args[i].startsWith("-") ) {
+          lastCmd = param;
+          // If map does not yet contain key, put it in with
+          // null value, so that map contains command even if
+          // there follow no values!
+          if ( !dest.containsKey(param) )
+            dest.put(param, null);
+          continue;
+        }
+
+        Object currValue = dest.get(lastCmd);
+        if ( currValue == null )
+          dest.put(lastCmd, param);
+        else if ( currValue instanceof List )
+          ((List<Object>)currValue).add(param);
+        else {
+          // current value is a single value
+          List<Object> cmdList = new ArrayList<Object>();
+          cmdList.add( currValue );
+          cmdList.add( param );
+          dest.put(lastCmd, cmdList);
+        }
+      }
+      
+      return dest;
+    }
 }

Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2013-05-11 15:31:21 UTC (rev 2309)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2013-05-23 13:36:21 UTC (rev 2310)
@@ -63,6 +63,7 @@
 Cancel=Cancel
 Cancel.Desc=Cancels the operation
 Apply=Apply
+Apply.Desc=Applies the operation
 Ready=Ready
 Open=Open
 OpenFolder=Open folder

Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties	2013-05-11 15:31:21 UTC (rev 2309)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties	2013-05-23 13:36:21 UTC (rev 2310)
@@ -36,6 +36,7 @@
 Cancel=Abbrechen
 Cancel.Desc=Aktion abbrechen
 Apply=\u00DCbernehmen
+Apply.Desc=Aktion \u00fcbernehmen
 Ready=Fertig
 Open=\u00D6ffnen
 OpenFolder=Ordner \u00F6ffnen



More information about the Schmitzm-commits mailing list