Added clone() method to MTranslator.
authorMarco Zanon <info@marcozanon.com>
Mon, 13 Aug 2012 20:03:48 +0000 (20:03 +0000)
committerMarco Zanon <info@marcozanon.com>
Mon, 13 Aug 2012 20:03:48 +0000 (20:03 +0000)
src/java/com/marcozanon/macaco/text/MTranslator.java

index 24f6330e098d2cc7afec37957b0cb270b5b09d2c..fab81d2b49908708b88e84cad990e0353b3c1709 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Locale;
 
 public class MTranslator extends MObject {
 
+    protected String file = null;
     protected Locale basicLocale = null;
 
     protected LinkedHashMap<String, LinkedHashMap<String, String>> messages = new LinkedHashMap<String, LinkedHashMap<String, String>>();
@@ -32,8 +33,26 @@ public class MTranslator extends MObject {
             throw new IllegalArgumentException("Invalid 'basicLocale': null.");
         }
         //
+        this.file = file;
         this.basicLocale = basicLocale;
-        this.parseFile(file);
+        //
+        this.parseFile(this.getFile());
+    }
+
+    public MTranslator clone() {
+        MTranslator tmpMTranslator = null;
+        try {
+            tmpMTranslator = new MTranslator(this.getFile(), this.getBasicLocale());
+        }
+        catch (MTranslationFileParsingTextException exception) { // should not happen
+        }
+        return tmpMTranslator;
+    }
+
+    /* File */
+
+    public String getFile() {
+        return this.file;
     }
 
     /* Locale */