--- /dev/null
+/**
+ * Macaco
+ * Copyright (c) 2009-2015 Marco Zanon <info@marcozanon.com>.
+ * Released under MIT license (see LICENSE for details).
+ */
+
+package com.marcozanon.macaco.text;
+
+@SuppressWarnings("serial")
+public class MTranslationFileParsingException extends MTranslationException {
+
+ /* */
+
+ public MTranslationFileParsingException() {
+ super();
+ }
+
+ public MTranslationFileParsingException(String message) {
+ super(message);
+ }
+
+ public MTranslationFileParsingException(Throwable error) {
+ super(error);
+ }
+
+ public MTranslationFileParsingException(String message, Throwable error) {
+ super(message, error);
+ }
+
+}
+++ /dev/null
-/**
- * Macaco
- * Copyright (c) 2009-2015 Marco Zanon <info@marcozanon.com>.
- * Released under MIT license (see LICENSE for details).
- */
-
-package com.marcozanon.macaco.text;
-
-@SuppressWarnings("serial")
-public class MTranslationFileParsingTextException extends MTranslationException {
-
- /* */
-
- public MTranslationFileParsingTextException() {
- super();
- }
-
- public MTranslationFileParsingTextException(String message) {
- super(message);
- }
-
- public MTranslationFileParsingTextException(Throwable error) {
- super(error);
- }
-
- public MTranslationFileParsingTextException(String message, Throwable error) {
- super(message, error);
- }
-
-}
/* */
- public MTranslator(String file, Locale basicLocale) throws MTranslationFileParsingTextException {
+ public MTranslator(String file, Locale basicLocale) throws MTranslationFileParsingException {
super();
//
if (null == basicLocale) {
try {
tmpMTranslator = new MTranslator(this.getFile(), this.getBasicLocale());
}
- catch (MTranslationFileParsingTextException exception) { // should not happen
+ catch (MTranslationFileParsingException exception) { // should not happen
}
return tmpMTranslator;
}
return this.messages;
}
- public void parseFile(String file) throws MTranslationFileParsingTextException {
+ public void parseFile(String file) throws MTranslationFileParsingException {
if (MText.isBlank(file)) {
throw new IllegalArgumentException("Invalid 'file': null or empty.");
}
buffer = new LineNumberReader(new InputStreamReader(new FileInputStream(file), MInformation.TEXT_ENCODING));
}
catch (FileNotFoundException exception) {
- throw new MTranslationFileParsingTextException("Could not open file.", exception);
+ throw new MTranslationFileParsingException("Could not open file.", exception);
}
catch (UnsupportedEncodingException exception) { // cannot happen
}
line = buffer.readLine();
}
catch (IOException exception) {
- throw new MTranslationFileParsingTextException("Could not read file.", exception);
+ throw new MTranslationFileParsingException("Could not read file.", exception);
}
if (null == line) {
break;
else if (null == message) {
message = line;
if (this.getMessagesReference().containsKey(message)) {
- throw new MTranslationFileParsingTextException(String.format("Invalid line: %s: duplicated message: %s.", buffer.getLineNumber(), message));
+ throw new MTranslationFileParsingException(String.format("Invalid line: %s: duplicated message: %s.", buffer.getLineNumber(), message));
}
this.getMessagesReference().put(message, new LinkedHashMap<String, String>());
}
else {
int a = line.indexOf("=");
if (-1 == a) {
- throw new MTranslationFileParsingTextException(String.format("Invalid line: %s: string malformed: %s.", buffer.getLineNumber(), line));
+ throw new MTranslationFileParsingException(String.format("Invalid line: %s: string malformed: %s.", buffer.getLineNumber(), line));
}
String localeRepresentation = line.substring(0, a).trim();
String translation = line.substring(a + 1).trim();
if (this.getMessagesReference().get(message).containsKey(localeRepresentation)) {
- throw new MTranslationFileParsingTextException(String.format("Invalid line: %s: duplicated translation for locale: %s.", buffer.getLineNumber(), message));
+ throw new MTranslationFileParsingException(String.format("Invalid line: %s: duplicated translation for locale: %s.", buffer.getLineNumber(), message));
}
this.getMessagesReference().get(message).put(localeRepresentation, translation);
}
buffer.close();
}
catch (IOException exception) {
- throw new MTranslationFileParsingTextException("Could not close file.", exception);
+ throw new MTranslationFileParsingException("Could not close file.", exception);
}
}