1.1 restoration
[mir.git] / source / tool / BundleTool.java
index e44345b..0b007d4 100755 (executable)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with  any library licensed under the Apache Software License, 
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library 
- * (or with modified versions of the above that use the same license as the above), 
- * and distribute linked combinations including the two.  You must obey the 
- * GNU General Public License in all respects for all of the code used other than 
- * the above mentioned libraries.  If you modify this file, you may extend this 
- * exception to your version of the file, but you are not obligated to do so.  
+ * the code of this program with  any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two.  You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries.  If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
  * If you do not wish to do so, delete this exception statement from your version.
  */
 
 package tool;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.util.Arrays;
 import java.util.Iterator;
+import java.util.List;
 
 import mir.util.ExceptionFunctions;
 import mir.util.PropertiesManipulator;
@@ -47,7 +51,9 @@ public class BundleTool {
     PropertiesManipulator result;
 
     try {
-      master = PropertiesManipulator.readProperties(new FileInputStream(new File(aMaster)));
+      master = PropertiesManipulator.readProperties(
+        new BufferedInputStream(
+          new FileInputStream(new File(aMaster)),8192));
     }
     catch (Throwable t) {
       System.out.println("Unable to read master properties: " + t.getMessage());
@@ -55,7 +61,9 @@ public class BundleTool {
     }
 
     try {
-      slave = PropertiesManipulator.readProperties(new FileInputStream(new File(aSlave)));
+      slave = PropertiesManipulator.readProperties(
+        new BufferedInputStream(
+          new FileInputStream(new File(aSlave)),8192));
     }
     catch (FileNotFoundException t) {
       slave = new PropertiesManipulator();
@@ -114,7 +122,9 @@ public class BundleTool {
     PropertiesManipulator result;
 
     try {
-      master = PropertiesManipulator.readProperties(new FileInputStream(new File(aMaster)));
+      master = PropertiesManipulator.readProperties(
+        new BufferedInputStream(
+          new FileInputStream(new File(aMaster)),8192));
     }
     catch (Throwable t) {
       System.out.println("Unable to read master properties: " + t.getMessage());
@@ -122,7 +132,9 @@ public class BundleTool {
     }
 
     try {
-      slave = PropertiesManipulator.readProperties(new FileInputStream(new File(aSlave)));
+      slave = PropertiesManipulator.readProperties(
+        new BufferedInputStream(
+          new FileInputStream(new File(aSlave)),8192));
     }
     catch (FileNotFoundException t) {
       slave = new PropertiesManipulator();
@@ -176,7 +188,8 @@ public class BundleTool {
     }
 
     try {
-      PropertiesManipulator.writeProperties(result, new FileOutputStream(new File(aSlave)));
+      PropertiesManipulator.writeProperties(result, 
+        new BufferedOutputStream(new FileOutputStream(new File(aSlave)),8192));
     }
     catch (Throwable t) {
       System.out.println("Unable to write slave properties: " + t.getMessage());
@@ -188,9 +201,12 @@ public class BundleTool {
     PropertiesManipulator bundle;
 
     try {
-      bundle = PropertiesManipulator.readProperties(new FileInputStream(new File(aBundle)));
+      bundle = PropertiesManipulator.readProperties(
+        new BufferedInputStream(
+          new FileInputStream(new File(aBundle)),8192));
 
-      PropertiesManipulator.writeProperties(bundle, new FileOutputStream(anOutputFile), anEncoding, false);
+      PropertiesManipulator.writeProperties(bundle, 
+        new BufferedOutputStream(new FileOutputStream(anOutputFile),8192), anEncoding, false);
     }
     catch (Throwable t) {
       System.out.println("Unable to read master properties: " + t.getMessage());
@@ -202,7 +218,9 @@ public class BundleTool {
     PropertiesManipulator bundle;
 
     try {
-      bundle = PropertiesManipulator.readProperties(new FileInputStream(new File(aSourceFile)), anEncoding);
+      bundle = PropertiesManipulator.readProperties(
+        new BufferedInputStream(
+          new FileInputStream(new File(aSourceFile)),8192), anEncoding);
     }
     catch (Throwable t) {
       Throwable s = ExceptionFunctions.traceCauseException(t);
@@ -211,7 +229,8 @@ public class BundleTool {
       return;
     }
     try {
-      PropertiesManipulator.writeProperties(bundle, new FileOutputStream(aBundle));
+      PropertiesManipulator.writeProperties(bundle, 
+        new BufferedOutputStream(new FileOutputStream(aBundle),8192));
     }
     catch (Throwable t) {
       System.out.println("Unable to write bundle: " + t.toString());
@@ -219,6 +238,23 @@ public class BundleTool {
     }
   }
 
+  public static void rename(String anOldKeyName, String aNewKeyName, List aBundles) {
+    /*
+    PropertiesManipulator bundle;
+
+    try {
+      bundle = PropertiesManipulator.readProperties(new FileInputStream(new File(aBundle)));
+
+      PropertiesManipulator.writeProperties(bundle, new FileOutputStream(anOutputFile), anEncoding, false);
+    }
+    catch (Throwable t) {
+      System.out.println("Unable to read master properties: " + t.getMessage());
+      return;
+    }
+*/
+  }
+
+
   public static void main(String[] anArguments) {
     String command = "help";
 
@@ -253,9 +289,19 @@ public class BundleTool {
           return;
         }
       }
-    }
+      else if (command.equals("rename")) {
+        if (anArguments.length>=3) {
+          List arguments = Arrays.asList(anArguments);
 
+          rename(anArguments[0], anArguments[1], arguments.subList(2, arguments.size()));
 
+/*
+          decode(anArguments[1], anArguments[2], anArguments[3]);
+*/
+          return;
+        }
+      }
+    }
 
     System.out.println("Usage:");
 
@@ -274,6 +320,9 @@ public class BundleTool {
     System.out.println("  BundleTool decode <bundle> <encoding> <sourcefile>");
     System.out.println("");
     System.out.println("      Decodes the keys/values with a custom encoding.");
+    System.out.println("  BundleTool rename <old key> <new key> <bundle> [<bundle> [ ... ]]");
+    System.out.println("");
+    System.out.println("      Decodes the keys/values with a custom encoding.");
   }
 
 }
\ No newline at end of file