Cleaned up the code.
authorMarco Zanon <info@marcozanon.com>
Mon, 21 Mar 2022 10:47:52 +0000 (10:47 +0000)
committerMarco Zanon <info@marcozanon.com>
Mon, 21 Mar 2022 10:47:52 +0000 (10:47 +0000)
18 files changed:
7.x/src/main/java/com/marcozanon/macaco/MInformation.java
7.x/src/main/java/com/marcozanon/macaco/conversion/MDateConverter.java
7.x/src/main/java/com/marcozanon/macaco/conversion/MLocalDateConverter.java
7.x/src/main/java/com/marcozanon/macaco/conversion/MLocalDateTimeConverter.java
7.x/src/main/java/com/marcozanon/macaco/conversion/MNumberConverter.java
7.x/src/main/java/com/marcozanon/macaco/database/MDatabaseConnection.java
7.x/src/main/java/com/marcozanon/macaco/database/MDatabaseConnectionPool.java
7.x/src/main/java/com/marcozanon/macaco/database/MSqlStatementResults.java
7.x/src/main/java/com/marcozanon/macaco/database/MSqlTable.java
7.x/src/main/java/com/marcozanon/macaco/json/MJsonArray.java
7.x/src/main/java/com/marcozanon/macaco/json/MJsonBoolean.java
7.x/src/main/java/com/marcozanon/macaco/json/MJsonNull.java
7.x/src/main/java/com/marcozanon/macaco/json/MJsonNumber.java
7.x/src/main/java/com/marcozanon/macaco/json/MJsonObject.java
7.x/src/main/java/com/marcozanon/macaco/json/MJsonString.java
7.x/src/main/java/com/marcozanon/macaco/logging/MLogDatabaseTable.java
7.x/src/main/java/com/marcozanon/macaco/text/MText.java
7.x/src/main/java/com/marcozanon/macaco/text/MTranslator.java

index b50ebd738106d37f98eaa44b5ae13b83d080103a..24aa0896914492164f55bcaf1b9c328e3c6e79a3 100644 (file)
@@ -23,10 +23,12 @@ public class MInformation extends MObject {
 
     public static String getMacacoCopyrightInformation() {
         StringBuilder s = new StringBuilder("");
+        //
         s.append(MInformation.getMacacoFullName() + System.getProperty("line.separator"));
         s.append("Copyright (c) 2009-2022 by Marco Zanon." + System.getProperty("line.separator"));
-        s.append("Released under MIT license (see LICENSE.MIT.sample for details)." + System.getProperty("line.separator"));
+        s.append("Released under MIT license (https://opensource.org/licenses/MIT)." + System.getProperty("line.separator"));
         s.append("Small portions inspired by other projects or web pages. See source code for additional information.");
+        //
         return s.toString();
     }
 
@@ -39,6 +41,7 @@ public class MInformation extends MObject {
         //
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
+        //
         throwable.printStackTrace(pw);
         pw.flush();
         sw.flush();
index 43dec3b80754a3d0a93796ef3703169330799378..181da3bb665171f354d16ce597edbc24c07cd589 100644 (file)
@@ -146,6 +146,7 @@ public class MDateConverter extends MObject {
         c1.setLenient(false);
         SimpleDateFormat sdf = new SimpleDateFormat(inputDateFormat, inputLocale);
         sdf.setCalendar(c1);
+        //
         Date d1 = null;
         try {
             d1 = sdf.parse(x);
@@ -153,6 +154,7 @@ public class MDateConverter extends MObject {
         catch (ParseException exception) {
             throw new MInvalidConversionFormatException(String.format("Invalid 'x' or parsing: %s (input format: %s).", x, inputDateFormat)); // no need to propagate exception
         }
+        //
         Calendar c2 = Calendar.getInstance(inputTimeZone, inputLocale);
         c2.clear();
         c2.set(Calendar.YEAR, c1.get(Calendar.YEAR));
@@ -161,10 +163,12 @@ public class MDateConverter extends MObject {
         c2.set(Calendar.HOUR_OF_DAY, c1.get(Calendar.HOUR_OF_DAY));
         c2.set(Calendar.MINUTE, c1.get(Calendar.MINUTE));
         c2.set(Calendar.SECOND, c1.get(Calendar.SECOND));
+        //
         Date d2 = c2.getTime();
         if (!x.equals(sdf.format(d2))) {
             throw new MInvalidConversionFormatException(String.format("Invalid 'x' or parsing: %s (input format: %s).", x, inputDateFormat));
         }
+        //
         return d2;
     }
 
@@ -182,6 +186,7 @@ public class MDateConverter extends MObject {
         //
         SimpleDateFormat sdf = new SimpleDateFormat(outputDateFormat, outputLocale);
         sdf.setCalendar(Calendar.getInstance(outputTimeZone, outputLocale));
+        //
         return sdf.format(date);
     }
 
@@ -190,6 +195,7 @@ public class MDateConverter extends MObject {
         for (String dateFormat: this.getDateFormats()) {
             try {
                 y = MDateConverter.getDateFromStringByParameters(x, dateFormat, this.getLocale(), this.getTimeZone());
+                //
                 return y;
             }
             catch (MInvalidConversionFormatException exception) {
@@ -198,6 +204,7 @@ public class MDateConverter extends MObject {
         if (null == y) {
             throw new MInvalidConversionFormatException(String.format("Invalid 'x': %s.", x));
         }
+        //
         return y; // necessary to avoid Java compilation errors
     }
 
@@ -218,6 +225,7 @@ public class MDateConverter extends MObject {
         calendar.set(Calendar.MINUTE, 0);
         calendar.set(Calendar.SECOND, 0);
         calendar.set(Calendar.MILLISECOND, 0);
+        //
         return calendar.getTime();
     }
 
@@ -232,6 +240,7 @@ public class MDateConverter extends MObject {
         calendar.set(Calendar.MINUTE, 59);
         calendar.set(Calendar.SECOND, 59);
         calendar.set(Calendar.MILLISECOND, 999);
+        //
         return calendar.getTime();
     }
 
index fc52143a4f2e60065971b69373c13897f8634a7c..85dd861084b87a27fda9c76fedf4588c63470a8c 100644 (file)
@@ -143,6 +143,7 @@ public class MLocalDateConverter extends MObject {
         for (String dateFormat: this.getDateFormats()) {
             try {
                 y = MLocalDateConverter.getDateFromStringByParameters(x, dateFormat, this.getLocale());
+                //
                 return y;
             }
             catch (MInvalidConversionFormatException exception) {
@@ -151,6 +152,7 @@ public class MLocalDateConverter extends MObject {
         if (null == y) {
             throw new MInvalidConversionFormatException(String.format("Invalid 'x': %s.", x));
         }
+        //
         return y; // necessary to avoid Java compilation errors
     }
 
index fdfa86cc850eee497db097aa1e52430ff07d7ebf..67f0e94a3a6e1b1a664dfba1a5a8e9c752fb5bc1 100644 (file)
@@ -143,6 +143,7 @@ public class MLocalDateTimeConverter extends MObject {
         for (String datetimeFormat: this.getDatetimeFormats()) {
             try {
                 y = MLocalDateTimeConverter.getDatetimeFromStringByParameters(x, datetimeFormat, this.getLocale());
+                //
                 return y;
             }
             catch (MInvalidConversionFormatException exception) {
@@ -151,6 +152,7 @@ public class MLocalDateTimeConverter extends MObject {
         if (null == y) {
             throw new MInvalidConversionFormatException(String.format("Invalid 'x': %s.", x));
         }
+        //
         return y; // necessary to avoid Java compilation errors
     }
 
index 5543c6c0cb8dec69813d5bfabc8494b8fc0069c1..6f5d6564888873fa1ee4334b7ed7f318e7412c96 100644 (file)
@@ -119,11 +119,13 @@ public class MNumberConverter extends MObject {
         DecimalFormatSymbols dfs = new DecimalFormatSymbols(inputLocale);
         DecimalFormat df = new DecimalFormat(inputNumberFormat, dfs);
         df.setParseBigDecimal(true);
+        //
         ParsePosition validPosition = new ParsePosition(0);
         BigDecimal bd = (BigDecimal)df.parse(x, validPosition);
         if (validPosition.getIndex() < x.length()) {
             throw new MInvalidConversionFormatException(String.format("Invalid 'x' or parsing: %s (input format: %s).", x, inputNumberFormat));
         }
+        //
         return bd;
     }
 
@@ -139,6 +141,7 @@ public class MNumberConverter extends MObject {
         DecimalFormatSymbols dfs = new DecimalFormatSymbols(outputLocale);
         DecimalFormat df = new DecimalFormat(outputNumberFormat, dfs);
         df.setRoundingMode(RoundingMode.HALF_UP);
+        //
         return df.format(number);
     }
 
@@ -147,6 +150,7 @@ public class MNumberConverter extends MObject {
         for (String numberFormat: this.getNumberFormats()) {
             try {
                 y = MNumberConverter.getNumberFromStringByParameters(x, numberFormat, this.getLocale());
+                //
                 return y;
             }
             catch (MInvalidConversionFormatException exception) {
@@ -155,6 +159,7 @@ public class MNumberConverter extends MObject {
         if (null == y) {
             throw new MInvalidConversionFormatException(String.format("Invalid 'x': %s.", x));
         }
+        //
         return y; // necessary to avoid Java compilation errors
     }
 
index 9aa684d9290490bce68d2ae80e5d82a0b2ee7d3d..3d334ce618cfddd27420574e74739f10abee39db 100644 (file)
@@ -239,14 +239,17 @@ public class MDatabaseConnection extends MObject {
                     this.getConnection().setAutoCommit(true);
                     this.setTransactionStatus(MDatabaseConnection.TransactionStatus.CLOSED);
                     this.logStatement("### COMMIT ###");
+                    //
                     return MDatabaseConnection.TransactionStatus.SUCCESSFUL;
                 }
                 catch (SQLException exception) {
                     this.rollBackTransaction();
+                    //
                     return MDatabaseConnection.TransactionStatus.FAILED;
                 }
             case FAILED:
                 this.rollBackTransaction();
+                //
                 return MDatabaseConnection.TransactionStatus.FAILED;
             default: // instead of "case CLOSED:" (necessary to avoid Java compilation errors)
                 throw new MSqlTransactionException("Transaction not started.");
@@ -304,6 +307,7 @@ public class MDatabaseConnection extends MObject {
             }
             throw new MSqlStatementException(String.format("Could not execute prepared statement: %s.", preparedStatement), exception);
         }
+        //
         return results;
     }
 
index 40fb91e03a5814cb129b658e16c5eb4d8294f337..c9c713ac7d5b8bb6c1bf70dd128509b9f9a4abd0 100644 (file)
@@ -87,6 +87,7 @@ public class MDatabaseConnectionPool extends MObject {
 
     public synchronized MDatabaseConnection popDatabaseConnection() throws MDatabaseConnectionFailureException {
         LinkedList<MDatabaseConnection> databaseConnections = this.getDatabaseConnections();
+        //
         MDatabaseConnection databaseConnection = null;
         if (0 == databaseConnections.size()) {
             databaseConnection = this.getDatabaseConnectionGenerator().getNewDatabaseConnection();
@@ -94,9 +95,11 @@ public class MDatabaseConnectionPool extends MObject {
         else {
             databaseConnection = databaseConnections.removeLast();
         }
+        //
         if (this.getMinimumSize() > databaseConnections.size()) {
             databaseConnections.add(this.getDatabaseConnectionGenerator().getNewDatabaseConnection());
         }
+        //
         return databaseConnection;
     }
 
@@ -113,6 +116,7 @@ public class MDatabaseConnectionPool extends MObject {
         }
         else {
             LinkedList<MDatabaseConnection> databaseConnections = this.getDatabaseConnections();
+            //
             if (this.getMaximumSize() >= databaseConnections.size()) {
                 databaseConnections.add(databaseConnection);
             }
index 3322c73f663d10712b5bbdcd51c8c317fcd39058..74ff328d92ceccc4fa6f8822377fb14853aaad22 100644 (file)
@@ -137,6 +137,7 @@ public class MSqlStatementResults extends MObject {
             }
             recordsByField.add(r);
         }
+        //
         return recordsByField;
     }
 
index cfdf38071eb0cb91faba2b5b80324486f5d387d9..cbc5a55289ff8d6f5fa905dc5a335fad18266ffe 100644 (file)
@@ -67,6 +67,7 @@ public class MSqlTable extends MObject {
         LinkedList<Object> p = new LinkedList<Object>();
         StringBuilder fields = new StringBuilder("");
         StringBuilder s = new StringBuilder("");
+        //
         for (String field: map.keySet()) {
             fields.append("\"" + this.getTable() + "\".\"" + field + "\", ");
             s.append("?, ");
@@ -91,6 +92,7 @@ public class MSqlTable extends MObject {
         //
         LinkedList<Object> p = new LinkedList<Object>();
         StringBuilder s = new StringBuilder("");
+        //
         for (String field: map.keySet()) {
             s.append("\"" + this.getTable() + "\".\"" + field + "\" = ?, ");
             p.add(map.get(field));
@@ -151,16 +153,19 @@ public class MSqlTable extends MObject {
         //
         String whereClause = null;
         LinkedList<Object> p = null;
+        //
         if (0 == idSet.size()) {
             whereClause = "0";
         }
         else {
             StringJoiner s = new StringJoiner(", ");
             p = new LinkedList<Object>();
+            //
             for (Object id: idSet) {
                 s.add("?");
                 p.add(id);
             }
+            //
             whereClause = "\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" IN (" + s.toString() + ")";
         }
         //
index ff94a5a915b75a4a56353f96c443023425733f8b..587449663d06d567ef3a7f68c301e508634f8869 100644 (file)
@@ -35,11 +35,13 @@ public class MJsonArray extends MJsonValue {
     @Override
     public MJsonArray clone() {
         MJsonArray tmpMJsonArray = null;
+        //
         try {
             tmpMJsonArray = new MJsonArray(this.getJsonValue());
         }
         catch (MInvalidJsonValueException exception) { // cannot happen
         }
+        //
         return tmpMJsonArray;
     }
 
@@ -102,17 +104,20 @@ public class MJsonArray extends MJsonValue {
         if ((2 > x.length()) || ('[' != x.charAt(0))) {
             return 0;
         }
+        //
         int position = x.indexOf("]", 1);
         while (-1 < position) {
             try {
                 MJsonArray testValue = new MJsonArray();
                 testValue.parseString(x.substring(0, position + 1));
+                //
                 return position + 1;
             }
             catch (MInvalidJsonValueException exception) {
                 position = x.indexOf("]", position + 1);
             }
         }
+        //
         return 0;
     }
 
@@ -124,6 +129,7 @@ public class MJsonArray extends MJsonValue {
         if ((2 > x.length()) || ('[' != x.charAt(0)) || (']' != x.charAt(x.length() - 1))) {
             throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: must begin and end with square brackets.", x));
         }
+        //
         String y = x.substring(1, x.length() - 1);
         int parsingPosition = 0;
         MJsonArray.ParsingMode parsingMode = MJsonArray.ParsingMode.START;
@@ -183,6 +189,7 @@ public class MJsonArray extends MJsonValue {
                     break;
             }
         }
+        //
         if (MJsonArray.ParsingMode.POST_VALUE_SEPARATOR == parsingMode) {
             parsingMode = MJsonArray.ParsingMode.ERROR;
         }
@@ -196,6 +203,7 @@ public class MJsonArray extends MJsonValue {
     @Override
     public String getJsonValue() {
         StringBuilder s = new StringBuilder("");
+        //
         s.append("[");
         for (int i = 0; this.getValueCount() > i; i++) {
             if (0 < i) {
@@ -204,6 +212,7 @@ public class MJsonArray extends MJsonValue {
             s.append(this.getValues().get(i).getJsonValue());
         }
         s.append("]");
+        //
         return s.toString();
     }
 
index c1f26eff7fc0915639691495930b819869cca3c3..97d092d937b7e2965e5bbdeb244a492062544692 100644 (file)
@@ -27,11 +27,13 @@ public class MJsonBoolean extends MJsonValue {
     @Override
     public MJsonBoolean clone() {
         MJsonBoolean tmpMJsonBoolean = null;
+        //
         try {
             tmpMJsonBoolean = new MJsonBoolean(this.getJsonValue());
         }
         catch (MInvalidJsonValueException exception) { // cannot happen
         }
+        //
         return tmpMJsonBoolean;
     }
 
@@ -62,6 +64,7 @@ public class MJsonBoolean extends MJsonValue {
         else if (x.startsWith("false")) {
             return "false".length();
         }
+        //
         return 0;
     }
 
@@ -73,6 +76,7 @@ public class MJsonBoolean extends MJsonValue {
         if ((!"true".equals(x)) && (!"false".equals(x))) {
             throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json boolean.", x));
         }
+        //
         this.setValue(Boolean.valueOf(x));
     }
 
index a6e4339cc411afa49d0261eae9019122895ea4ba..e3a5803d025da484f35f61cb7aa70cb83cd130f2 100644 (file)
@@ -25,11 +25,13 @@ public class MJsonNull extends MJsonValue {
     @Override
     public MJsonNull clone() {
         MJsonNull tmpMJsonNull = null;
+        //
         try {
             tmpMJsonNull = new MJsonNull(this.getJsonValue());
         }
         catch (MInvalidJsonValueException exception) { // cannot happen
         }
+        //
         return tmpMJsonNull;
     }
 
@@ -43,6 +45,7 @@ public class MJsonNull extends MJsonValue {
         if (x.startsWith("null")) {
             return "null".length();
         }
+        //
         return 0;
     }
 
index 8e20402ee0914d946a6abc82316e51d4bb2a1c3a..3566a3093d6588c6cd94ef64ba17bcc3853e3c4a 100644 (file)
@@ -28,11 +28,13 @@ public class MJsonNumber extends MJsonValue {
     @Override
     public MJsonNumber clone() {
         MJsonNumber tmpMJsonNumber = null;
+        //
         try {
             tmpMJsonNumber = new MJsonNumber(this.getJsonValue());
         }
         catch (MInvalidJsonValueException exception) { // cannot happen
         }
+        //
         return tmpMJsonNumber;
     }
 
@@ -60,9 +62,11 @@ public class MJsonNumber extends MJsonValue {
         if (' ' == x.charAt(0)) {
             return 0;
         }
+        //
         int position = 0;
         int validPosition = 0;
         BigDecimal y = null;
+        //
         while (x.length() > position) {
             if (' ' == x.charAt(position)) {
                 break;
@@ -78,6 +82,7 @@ public class MJsonNumber extends MJsonValue {
                 }
             }
         }
+        //
         return validPosition;
     }
 
@@ -87,12 +92,14 @@ public class MJsonNumber extends MJsonValue {
         }
         //
         BigDecimal y = null;
+        //
         try {
             y = new BigDecimal(x);
         }
         catch (NumberFormatException exception) {
             throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json number.", x)); // no need to propagate exception
         }
+        //
         this.setValue(y);
     }
 
index 76101f095fd29326edb9aeb6ca7607d2a55736fa..ffcefbdd1180f768d79c56d158f544e95b391f04 100644 (file)
@@ -38,11 +38,13 @@ public class MJsonObject extends MJsonValue {
     @Override
     public MJsonObject clone() {
         MJsonObject tmpMJsonObject = null;
+        //
         try {
             tmpMJsonObject = new MJsonObject(this.getJsonValue());
         }
         catch (MInvalidJsonValueException exception) { // cannot happen
         }
+        //
         return tmpMJsonObject;
     }
 
@@ -71,6 +73,7 @@ public class MJsonObject extends MJsonValue {
         if (!this.containsKey(key)) {
             throw new IllegalArgumentException(String.format("Invalid 'key': %s: not available.", key));
         }
+        //
         return this.getValues().get(key).clone();
     }
 
@@ -86,6 +89,7 @@ public class MJsonObject extends MJsonValue {
         if (!this.containsKey(key)) {
             throw new IllegalArgumentException(String.format("Invalid 'key': %s: not available.", key));
         }
+        //
         this.getValues().remove(key);
     }
 
@@ -106,6 +110,7 @@ public class MJsonObject extends MJsonValue {
         for (String key: this.getValues().keySet()) {
             keys.add(key);
         }
+        //
         return keys;
     }
 
@@ -119,17 +124,20 @@ public class MJsonObject extends MJsonValue {
         if ((2 > x.length()) || ('{' != x.charAt(0))) {
             return 0;
         }
+        //
         int position = x.indexOf("}", 1);
         while (-1 < position) {
             try {
                 MJsonObject testValue = new MJsonObject();
                 testValue.parseString(x.substring(0, position + 1));
+                //
                 return position + 1;
             }
             catch (MInvalidJsonValueException exception) {
                 position = x.indexOf("}", position + 1);
             }
         }
+        //
         return 0;
     }
 
@@ -141,6 +149,7 @@ public class MJsonObject extends MJsonValue {
         if ((2 > x.length()) || ('{' != x.charAt(0)) || ('}' != x.charAt(x.length() - 1))) {
             throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: must begin and end with curly brackets.", x));
         }
+        //
         String y = x.substring(1, x.length() - 1);
         int parsingPosition = 0;
         MJsonObject.ParsingMode parsingMode = MJsonObject.ParsingMode.START;
@@ -233,6 +242,7 @@ public class MJsonObject extends MJsonValue {
                     break;
             }
         }
+        //
         if ((MJsonObject.ParsingMode.POST_NAME == parsingMode) || (MJsonObject.ParsingMode.POST_NAME_SEPARATOR == parsingMode) || (MJsonObject.ParsingMode.POST_VALUE_SEPARATOR == parsingMode)) {
             parsingMode = MJsonObject.ParsingMode.ERROR;
         }
@@ -246,6 +256,7 @@ public class MJsonObject extends MJsonValue {
     @Override
     public String getJsonValue() {
         StringBuilder s = new StringBuilder("");
+        //
         s.append("{");
         int k = 0;
         for (String key: this.getValues().keySet()) {
@@ -258,6 +269,7 @@ public class MJsonObject extends MJsonValue {
             k++;
         }
         s.append("}");
+        //
         return s.toString();
     }
 
index 2e22d12fe021f7b2949144487ae5391a28b68ef6..1cca57a03904d0a2312c8718002ee49b294d59ab 100644 (file)
@@ -34,11 +34,13 @@ public class MJsonString extends MJsonValue {
     @Override
     public MJsonString clone() {
         MJsonString tmpMJsonString = null;
+        //
         try {
             tmpMJsonString = new MJsonString(this.getJsonValue());
         }
         catch (MInvalidJsonValueException exception) { // cannot happen
         }
+        //
         return tmpMJsonString;
     }
 
@@ -141,6 +143,7 @@ public class MJsonString extends MJsonValue {
                 }
             }
         }
+        //
         return y.toString();
     }
 
@@ -233,6 +236,7 @@ public class MJsonString extends MJsonValue {
                 y.appendCodePoint(c);
             }
         }
+        //
         return y.toString();
     }
 
@@ -249,6 +253,7 @@ public class MJsonString extends MJsonValue {
         if ('"' == x.charAt(1)) {
             return 1 + 1;
         }
+        //
         String y = x.substring(1);
         int quotationMarkPosition = 0;
         while (-1 < (quotationMarkPosition = y.indexOf("\"", quotationMarkPosition + 1))) {
@@ -263,9 +268,11 @@ public class MJsonString extends MJsonValue {
                 break;
             }
         }
+        //
         if (-1 == quotationMarkPosition) {
             return 0;
         }
+        //
         return (quotationMarkPosition + 1) + 1;
     }
 
@@ -277,10 +284,12 @@ public class MJsonString extends MJsonValue {
         if ((2 > x.length()) || ('"' != x.charAt(0)) || ('"' != x.charAt(x.length() - 1))) {
             throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json string.", x));
         }
+        //
         String y = x.substring(1, x.length() - 1);
         if (-1 < y.replaceAll("\\\\\"", "__").indexOf("\"")) {
             throw new MInvalidJsonValueException(String.format("Invalid 'x': %s: not a Json string.", x));
         }
+        //
         this.setValue(MJsonString.getUnescapedString(y));
     }
 
index 07d213ffd877d23c9660ec7ce2bd954c74f50695..f4db045410541f89d53b81e10caaa3c6b7aa0de6 100644 (file)
@@ -102,6 +102,7 @@ public class MLogDatabaseTable extends MLogTarget {
             //
             LinkedHashMap<String, Object> p = new LinkedHashMap<String, Object>();
             p.put(this.getLogDatabaseField(), timestamp + separator + message);
+            //
             (new MSqlTable(databaseConnection, this.getLogDatabaseTable(), this.getLogDatabaseTablePrimaryKey())).setRecord(p, null, false);
             //
             this.getDatabaseConnectionPool().pushDatabaseConnection(databaseConnection);
index 587aaf51498f278361c22f461888fe2aeb773950..8203705f10ffd598b73bc4866054ade3aeca16b0 100644 (file)
@@ -33,6 +33,7 @@ public class MText extends MObject {
         if ((null != x) && ("".equals(x))) {
             return true;
         }
+        //
         return false;
     }
 
@@ -40,6 +41,7 @@ public class MText extends MObject {
         if ((null == x) || ("".equals(x))) {
             return true;
         }
+        //
         return false;
     }
 
@@ -51,9 +53,11 @@ public class MText extends MObject {
         }
         //
         StringBuilder y = new StringBuilder("");
+        //
         for (int i = 0; i < times; i++) {
             y = y.append(x);
         }
+        //
         return y.toString();
     }
 
@@ -63,10 +67,12 @@ public class MText extends MObject {
         }
         //
         StringBuilder y = new StringBuilder("");
+        //
         for (int i = 0; i < length; i++) {
             char c = (char)(65 + (25 * Math.random()));
             y = y.append(c);
         }
+        //
         return y.toString();
     }
 
index 4760d27637dae7b1242e0806987c3a455e688482..a4deecf0ded99b72c5b04ab0fdb51f1398668723 100644 (file)
@@ -80,10 +80,13 @@ public class MTranslator extends MObject {
                     catch (IOException exception) {
                         throw new MTranslationFileParsingException("Could not read file.", exception);
                     }
+                    //
                     if (null == line) {
                         break;
                     }
+                    //
                     line = line.trim();
+                    //
                     if (MText.isEmpty(line)) {
                         message = null;
                         continue;
@@ -96,6 +99,7 @@ public class MTranslator extends MObject {
                         if (this.getMessages().containsKey(message)) {
                             throw new MTranslationFileParsingException(String.format("Invalid line: %s: duplicated message: %s.", buffer.getLineNumber(), message));
                         }
+                        //
                         this.getMessages().put(message, new LinkedHashMap<String, String>());
                     }
                     else {
@@ -103,11 +107,13 @@ public class MTranslator extends MObject {
                         if (-1 == a) {
                             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.getMessages().get(message).containsKey(localeRepresentation)) {
                             throw new MTranslationFileParsingException(String.format("Invalid line: %s: duplicated translation for locale: %s.", buffer.getLineNumber(), message));
                         }
+                        //
                         this.getMessages().get(message).put(localeRepresentation, translation);
                     }
                 }
@@ -135,11 +141,13 @@ public class MTranslator extends MObject {
 
     public String getLenientTranslation(String message, Locale locale) {
         String translation = null;
+        //
         try {
             translation = this.getTranslation(message, locale, false);
         }
         catch (MTranslationValueNotFoundException exception) { // cannot happen
         }
+        //
         return translation;
     }
 
@@ -159,6 +167,7 @@ public class MTranslator extends MObject {
             if (strictMode) {
                 throw new MTranslationValueNotFoundException(String.format("Invalid 'message': %s: not available.", message));
             }
+            //
             return message;
         }
 /*
@@ -172,12 +181,16 @@ public class MTranslator extends MObject {
             if (strictMode) {
                 throw new MTranslationValueNotFoundException(String.format("Invalid 'locale': %s: translation not available for message: %s.", localeRepresentation, message));
             }
+            //
             String localeFallbackRepresentation = locale.getLanguage();
+            //
             if (!messageTranslations.containsKey(localeFallbackRepresentation)) {
                 return message;
             }
+            //
             return messageTranslations.get(localeFallbackRepresentation);
         }
+        //
         return messageTranslations.get(localeRepresentation);
     }