Modified code to comply with the guidelines.
authorMarco Zanon <info@marcozanon.com>
Sun, 26 Aug 2012 09:44:24 +0000 (09:44 +0000)
committerMarco Zanon <info@marcozanon.com>
Sun, 26 Aug 2012 09:44:24 +0000 (09:44 +0000)
23 files changed:
2.x/src/java/com/marcozanon/macaco/conversion/MDateConverter.java
2.x/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java
2.x/src/java/com/marcozanon/macaco/json/MJsonArray.java
2.x/src/java/com/marcozanon/macaco/json/MJsonNumber.java
2.x/src/java/com/marcozanon/macaco/json/MJsonObject.java
2.x/src/java/com/marcozanon/macaco/json/MJsonString.java
2.x/src/java/com/marcozanon/macaco/logging/MLogPlainTextFile.java
2.x/src/java/com/marcozanon/macaco/sql/MSqlConnection.java
2.x/src/java/com/marcozanon/macaco/sql/MSqlStatementResults.java
2.x/src/java/com/marcozanon/macaco/text/MText.java
2.x/src/java/com/marcozanon/macaco/text/MTranslator.java
2.x/src/java/com/marcozanon/macaco/web/ui/MWebApplicationServlet.java
2.x/src/java/com/marcozanon/macaco/web/ui/MWebBreadcrumbs.java
2.x/src/java/com/marcozanon/macaco/web/ui/MWebBrowserPage.java
2.x/src/java/com/marcozanon/macaco/web/ui/MWebColor.java
2.x/src/java/com/marcozanon/macaco/web/ui/MWebExtendedTextBox.java
2.x/src/java/com/marcozanon/macaco/web/ui/MWebGridLayout.java
2.x/src/java/com/marcozanon/macaco/web/ui/MWebGridLayoutCell.java
2.x/src/java/com/marcozanon/macaco/web/ui/MWebTable.java
2.x/src/java/com/marcozanon/macaco/web/ui/MWebView.java
2.x/src/resources/css/default.css
2.x/src/resources/javascript/MWebCustomJsonHelper.js
2.x/src/resources/javascript/MWebNotificationArea.js

index 19ac6740f2abdf055cf1a735bedc6e50a00407fb..ceb748c9daf734154151edf05bd046c8092870f8 100644 (file)
@@ -103,12 +103,8 @@ public class MDateConverter extends MObject {
         this.locale = locale;
     }
 
-    protected Locale getLocaleReference() {
-        return this.locale;
-    }
-
     public Locale getLocale() {
-        return (Locale)this.getLocaleReference().clone();
+        return this.locale;
     }
 
     /* Time zone */
@@ -201,7 +197,7 @@ public class MDateConverter extends MObject {
         Date y = null;
         for (String dateFormat: this.getDateFormatsReference()) {
             try {
-                y = this.getDateFromStringByParameters(x, dateFormat, this.getLocaleReference(), this.getTimeZoneReference());
+                y = this.getDateFromStringByParameters(x, dateFormat, this.getLocale(), this.getTimeZoneReference());
                 return y;
             }
             catch (MFormatConversionException exception) {
@@ -214,7 +210,7 @@ public class MDateConverter extends MObject {
     }
 
     public String getStringFromDate(Date x) {
-        return this.getStringFromDateByParameters(x, this.getDefaultDateFormat(), this.getLocaleReference(), this.getTimeZoneReference());
+        return this.getStringFromDateByParameters(x, this.getDefaultDateFormat(), this.getLocale(), this.getTimeZoneReference());
     }
 
     /* Helper methods */
index 6b61ce62809d9d5cdb09ecef48c43f0d7275a32e..7200cc6d289a75ed08ffb84ef156ca690b37d3c8 100644 (file)
@@ -94,12 +94,8 @@ public class MNumberConverter extends MObject {
         this.locale = locale;
     }
 
-    protected Locale getLocaleReference() {
-        return this.locale;
-    }
-
     public Locale getLocale() {
-        return (Locale)this.getLocaleReference().clone();
+        return this.locale;
     }
 
     /* Conversion */
@@ -155,7 +151,7 @@ public class MNumberConverter extends MObject {
         BigDecimal y = null;
         for (String numberFormat: this.getNumberFormatsReference()) {
             try {
-                y = this.getNumberFromStringByParameters(x, numberFormat, this.getLocaleReference());
+                y = this.getNumberFromStringByParameters(x, numberFormat, this.getLocale());
                 return y;
             }
             catch (MFormatConversionException exception) {
@@ -168,7 +164,7 @@ public class MNumberConverter extends MObject {
     }
 
     public String getStringFromNumber(BigDecimal x) {
-        return this.getStringFromNumberByParameters(x, this.getDefaultNumberFormat(), this.getLocaleReference());
+        return this.getStringFromNumberByParameters(x, this.getDefaultNumberFormat(), this.getLocale());
     }
 
 }
index fae55522dfb1d42b21828db1d0c9556b5ef45f04..8c1cc88641ac5ce570a4ee51fb28edfefd9926fa 100644 (file)
@@ -6,6 +6,7 @@
 
 package com.marcozanon.macaco.json;
 
+import com.marcozanon.macaco.text.MText;
 import java.util.LinkedList;
 
 public class MJsonArray extends MJsonValue {
@@ -52,7 +53,7 @@ public class MJsonArray extends MJsonValue {
     }
 
     public void setValue(int index, MJsonValue x) {
-        if ((index < 0) || (index > (this.getValueCount() - 1))) {
+        if ((0 > index) || ((this.getValueCount() - 1) < index)) {
             throw new IllegalArgumentException(String.format("Invalid 'index': %s: out of range.", index));
         }
         if (null == x) {
@@ -67,7 +68,7 @@ public class MJsonArray extends MJsonValue {
     }
 
     public MJsonValue getValue(int index) {
-        if ((index < 0) || (index > (this.getValueCount() - 1))) {
+        if ((0 > index) || ((this.getValueCount() - 1) < index)) {
             throw new IllegalArgumentException(String.format("Invalid 'index': %s: out of range.", index));
         }
         //
@@ -79,7 +80,7 @@ public class MJsonArray extends MJsonValue {
     }
 
     public void removeValue(int index) {
-        if ((index < 0) || (index > (this.getValueCount() - 1))) {
+        if ((0 > index) || ((this.getValueCount() - 1) < index)) {
             throw new IllegalArgumentException(String.format("Invalid 'index': %s: out of range.", index));
         }
         //
@@ -97,11 +98,11 @@ public class MJsonArray extends MJsonValue {
             throw new IllegalArgumentException("Invalid 'x': null.");
         }
         //
-        if ((x.length() < 2) || ('[' != x.charAt(0))) {
+        if ((2 > x.length()) || ('[' != x.charAt(0))) {
             return 0;
         }
         int position = x.indexOf("]", 1);
-        while (position > -1) {
+        while (-1 < position) {
             try {
                 MJsonArray testValue = new MJsonArray();
                 testValue.parseString(x.substring(0, position + 1));
@@ -115,17 +116,17 @@ public class MJsonArray extends MJsonValue {
     }
 
     public void parseString(String x) throws MInvalidValueJsonException {
-        if (null == x) {
-            throw new IllegalArgumentException("Invalid 'x': null.");
+        if (MText.isBlank(x)) {
+            throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
-        if ((x.length() < 2) || ('[' != x.charAt(0)) || (']' != x.charAt(x.length() - 1))) {
+        if ((2 > x.length()) || ('[' != x.charAt(0)) || (']' != x.charAt(x.length() - 1))) {
             throw new MInvalidValueJsonException(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;
-        while ((parsingPosition < y.length()) && (MJsonArray.ParsingMode.ERROR != parsingMode)) {
+        while ((y.length() > parsingPosition) && (MJsonArray.ParsingMode.ERROR != parsingMode)) {
             int c = y.codePointAt(parsingPosition);
             switch (parsingMode) {
                 case START:
@@ -138,25 +139,25 @@ public class MJsonArray extends MJsonValue {
                     }
                     else {
                         int offset = 0;
-                        if ((offset = MJsonNull.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        if (0 < (offset = MJsonNull.getTokenLength(y.substring(parsingPosition)))) {
                             this.addValue(new MJsonNull(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        else if ((offset = MJsonBoolean.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        else if (0 < (offset = MJsonBoolean.getTokenLength(y.substring(parsingPosition)))) {
                             this.addValue(new MJsonBoolean(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        else if ((offset = MJsonNumber.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        else if (0 < (offset = MJsonNumber.getTokenLength(y.substring(parsingPosition)))) {
                             this.addValue(new MJsonNumber(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        else if ((offset = MJsonString.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        else if (0 < (offset = MJsonString.getTokenLength(y.substring(parsingPosition)))) {
                             this.addValue(new MJsonString(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        else if ((offset = MJsonArray.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        else if (0 < (offset = MJsonArray.getTokenLength(y.substring(parsingPosition)))) {
                             this.addValue(new MJsonArray(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        else if ((offset = MJsonObject.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        else if (0 < (offset = MJsonObject.getTokenLength(y.substring(parsingPosition)))) {
                             this.addValue(new MJsonObject(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        if (offset > 0) {
+                        if (0 < offset) {
                             parsingPosition += offset;
                             parsingMode = MJsonArray.ParsingMode.POST_VALUE;
                         }
@@ -194,8 +195,8 @@ public class MJsonArray extends MJsonValue {
     public String getJsonValue() {
         StringBuilder s = new StringBuilder("");
         s.append("[");
-        for (int i = 0; i < this.getValueCount(); i++) {
-            if (i > 0) {
+        for (int i = 0; this.getValueCount() > i; i++) {
+            if (0 < i) {
                 s.append(", ");
             }
             s.append(this.getValuesReference().get(i).getJsonValue());
index 886e8545f6bb8ae64a58e1eaacba777cd3153891..401be4e580b2b08219019802d02b3e048b6f52bf 100644 (file)
@@ -45,12 +45,8 @@ public class MJsonNumber extends MJsonValue {
         this.value = new BigDecimal(x.toString());
     }
 
-    protected BigDecimal getValueReference() {
-        return this.value;
-    }
-
     public BigDecimal getValue() {
-        return new BigDecimal(this.getValueReference().toString());
+        return this.value;
     }
 
     /* Parsers */
@@ -66,7 +62,7 @@ public class MJsonNumber extends MJsonValue {
         int position = 0;
         int validPosition = 0;
         BigDecimal y = null;
-        while (position < x.length()) {
+        while (x.length() > position) {
             if (' ' == x.charAt(position)) {
                 break;
             }
@@ -102,7 +98,7 @@ public class MJsonNumber extends MJsonValue {
     /* Formatter */
 
     public String getJsonValue() {
-        return this.getValueReference().toString();
+        return this.getValue().toString();
     }
 
 }
index 29e9830d8ce26c5c141de06e1826b2c2c482d289..a64056c480d72f8a8fd24cebac0cffb45b842298 100644 (file)
@@ -115,11 +115,11 @@ public class MJsonObject extends MJsonValue {
             throw new IllegalArgumentException("Invalid 'x': null.");
         }
         //
-        if ((x.length() < 2) || ('{' != x.charAt(0))) {
+        if ((2 > x.length()) || ('{' != x.charAt(0))) {
             return 0;
         }
         int position = x.indexOf("}", 1);
-        while (position > -1) {
+        while (-1 < position) {
             try {
                 MJsonObject testValue = new MJsonObject();
                 testValue.parseString(x.substring(0, position + 1));
@@ -133,18 +133,18 @@ public class MJsonObject extends MJsonValue {
     }
 
     public void parseString(String x) throws MInvalidValueJsonException {
-        if (null == x) {
-            throw new IllegalArgumentException("Invalid 'x': null.");
+        if (MText.isBlank(x)) {
+            throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
-        if ((x.length() < 2) || ('{' != x.charAt(0)) || ('}' != x.charAt(x.length() - 1))) {
+        if ((2 > x.length()) || ('{' != x.charAt(0)) || ('}' != x.charAt(x.length() - 1))) {
             throw new MInvalidValueJsonException(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;
         String lastKey = "";
-        while ((parsingPosition < y.length()) && (MJsonObject.ParsingMode.ERROR != parsingMode)) {
+        while ((y.length() > parsingPosition) && (MJsonObject.ParsingMode.ERROR != parsingMode)) {
             int c = y.codePointAt(parsingPosition);
             switch (parsingMode) {
                 case START:
@@ -157,7 +157,7 @@ public class MJsonObject extends MJsonValue {
                     }
                     else {
                         int offset = MJsonString.getTokenLength(y.substring(parsingPosition));
-                        if (offset > 0) {
+                        if (0 < offset) {
                             lastKey = (new MJsonString(y.substring(parsingPosition, parsingPosition + offset))).getValue();
                             parsingPosition += offset;
                             parsingMode = MJsonObject.ParsingMode.POST_NAME;
@@ -188,25 +188,25 @@ public class MJsonObject extends MJsonValue {
                     }
                     else {
                         int offset = 0;
-                        if ((offset = MJsonNull.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        if (0 < (offset = MJsonNull.getTokenLength(y.substring(parsingPosition)))) {
                             this.setValue(lastKey, new MJsonNull(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        else if ((offset = MJsonBoolean.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        else if (0 < (offset = MJsonBoolean.getTokenLength(y.substring(parsingPosition)))) {
                             this.setValue(lastKey, new MJsonBoolean(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        else if ((offset = MJsonNumber.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        else if (0 < (offset = MJsonNumber.getTokenLength(y.substring(parsingPosition)))) {
                             this.setValue(lastKey, new MJsonNumber(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        else if ((offset = MJsonString.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        else if (0 < (offset = MJsonString.getTokenLength(y.substring(parsingPosition)))) {
                             this.setValue(lastKey, new MJsonString(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        else if ((offset = MJsonArray.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        else if (0 < (offset = MJsonArray.getTokenLength(y.substring(parsingPosition)))) {
                             this.setValue(lastKey, new MJsonArray(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        else if ((offset = MJsonObject.getTokenLength(y.substring(parsingPosition))) > 0) {
+                        else if (0 < (offset = MJsonObject.getTokenLength(y.substring(parsingPosition)))) {
                             this.setValue(lastKey, new MJsonObject(y.substring(parsingPosition, parsingPosition + offset)));
                         }
-                        if (offset > 0) {
+                        if (0 < offset) {
                             lastKey = "";
                             parsingPosition += offset;
                             parsingMode = MJsonObject.ParsingMode.POST_VALUE;
@@ -247,7 +247,7 @@ public class MJsonObject extends MJsonValue {
         s.append("{");
         int k = 0;
         for (String key: this.getValuesReference().keySet()) {
-            if (k > 0) {
+            if (0 < k) {
                 s.append(", ");
             }
             s.append("\"" + MJsonString.getEscapedString(key, false) + "\"");
index af913a060dc91da0d587279babb9a4f4381ef4e8..226953000516e21b0c2e341d60b50faa95fa9d19 100644 (file)
@@ -73,13 +73,13 @@ public class MJsonString extends MJsonValue {
         }
         //
         StringBuilder y = new StringBuilder();
-        for (int i = 0; i < x.length(); i++) {
+        for (int i = 0; x.length() > i; i++) {
             int c = x.codePointAt(i);
             if (extendedEscapeMode) {
-                if (c <= 0x00001F) { // control Ascii character (0x000000-0x00001F)
+                if (0x00001F >= c) { // control Ascii character (0x000000-0x00001F)
                     y.append("\\u" + String.format("%4H", c).replace(" ", "0"));
                 }
-                else if (c <= 0x00007F) { // non-control Ascii character (0x000020-0x00007F)
+                else if (0x00007F >= c) { // non-control Ascii character (0x000020-0x00007F)
                     if ('"' == c) {
                         y.append("\\\"");
                     }
@@ -93,7 +93,7 @@ public class MJsonString extends MJsonValue {
                         y.appendCodePoint(c);
                     }
                 }
-                else if (c <= 0x00FFFF) { // non-Ascii Bmp character (0x000080-0x00FFFF)
+                else if (0x00FFFF >= c) { // non-Ascii Bmp character (0x000080-0x00FFFF)
                     y.append("\\u" + String.format("%4H", c).replace(" ", "0"));
                 }
                 else { // non-Bmp character (0x010000-0x10FFFF)
@@ -129,12 +129,12 @@ public class MJsonString extends MJsonValue {
                 else if ('\t' == c) {
                     y.append("\\t");
                 }
-                else if (c <= 0x00001F) { // non-special control Ascii character (0x000000-0x00001F)
+                else if (0x00001F >= c) { // non-special control Ascii character (0x000000-0x00001F)
                     y.append("\\u" + String.format("%4H", c).replace(" ", "0"));
                 }
                 else {
                     y.appendCodePoint(c);
-                    if (c >= 0x010000) {
+                    if (0x010000 <= c) {
                         i++;
                     }
                 }
@@ -149,7 +149,7 @@ public class MJsonString extends MJsonValue {
         }
         //
         StringBuilder y = new StringBuilder();
-        for (int i = 0; i < x.length(); i++) {
+        for (int i = 0; x.length() > i; i++) {
             if (x.indexOf("\\\"", i) == i) {
                 y.append("\"");
                 i++;
@@ -191,7 +191,7 @@ public class MJsonString extends MJsonValue {
                     try {
                         ch = Integer.parseInt(x.substring(i + 2, i + 2 + 4), 16);
                         i += 5;
-                        if ((ch >= 0xD800) && (ch <= 0xDBFF)) {
+                        if ((0xD800 <= ch) && (0xDBFF >= ch)) {
                             i++;
                             if (x.indexOf("\\u", i) != i) {
                                 throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x));
@@ -204,10 +204,10 @@ public class MJsonString extends MJsonValue {
                                 try {
                                     cl = Integer.parseInt(x.substring(i + 2, i + 2 + 4), 16);
                                     i += 5;
-                                    if ((cl <= 0xDC00) || (cl >= 0xDFFF)) {
+                                    if ((0xDC00 >= cl) || (0xDFFF <= cl)) {
                                         throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x));
                                     }
-                                    int c = ((ch -0xD800) << 10) + (cl - 0xDC00) + 0x010000;
+                                    int c = ((ch - 0xD800) << 10) + (cl - 0xDC00) + 0x010000;
                                     y.appendCodePoint(c);
                                 }
                                 catch (NumberFormatException exception) {
@@ -226,7 +226,7 @@ public class MJsonString extends MJsonValue {
             }
             else {
                 int c = x.codePointAt(i);
-                if (c >= 0x010000) {
+                if (0x010000 <= c) {
                     i++;
                 }
                 y.appendCodePoint(c);
@@ -242,7 +242,7 @@ public class MJsonString extends MJsonValue {
             throw new IllegalArgumentException("Invalid 'x': null.");
         }
         //
-        if ((x.length() < 2) || ('"' != x.charAt(0))) {
+        if ((2 > x.length()) || ('"' != x.charAt(0))) {
             return 0;
         }
         if ('"' == x.charAt(1)) {
@@ -250,7 +250,7 @@ public class MJsonString extends MJsonValue {
         }
         String y = x.substring(1);
         int quotationMarkPosition = 0;
-        while ((quotationMarkPosition = y.indexOf("\"", quotationMarkPosition + 1)) > -1) {
+        while (-1 < (quotationMarkPosition = y.indexOf("\"", quotationMarkPosition + 1))) {
             int c = 0;
             StringBuilder s = new StringBuilder("");
             while ((c <= quotationMarkPosition) && (y.substring(quotationMarkPosition - c, quotationMarkPosition).equals(s.toString()))) {
@@ -273,11 +273,11 @@ public class MJsonString extends MJsonValue {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
-        if ((x.length() < 2) || ('"' != x.charAt(0)) || ('"' != x.charAt(x.length() - 1))) {
+        if ((2 > x.length()) || ('"' != x.charAt(0)) || ('"' != x.charAt(x.length() - 1))) {
             throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x));
         }
         String y = x.substring(1, x.length() - 1);
-        if (y.replaceAll("\\\\\"", "__").indexOf("\"") > -1) {
+        if (-1 < y.replaceAll("\\\\\"", "__").indexOf("\"")) {
             throw new MInvalidValueJsonException(String.format("Invalid 'x': %s: not a Json string.", x));
         }
         this.setValue(MJsonString.getUnescapedString(y));
index a5c0d0e99916224241b4a24478bd4665070e6a7a..0e3d16dd512acae9dc03c9ddbd1b2ab9982ac209 100644 (file)
@@ -62,7 +62,7 @@ public class MLogPlainTextFile extends MLogTarget {
 
     /* File */
 
-    public String getFile() {
+    protected String getFile() {
         return this.file;
     }
 
index bdcf5309056411b3092cee614f5285829f3bb6b9..9047a905d39c2c50641d53e163b325c8a50b3ae6 100644 (file)
@@ -212,7 +212,7 @@ public class MSqlConnection extends MObject {
         try {
             // prepare the statement
             preparedStatement = this.getConnectionReference().prepareStatement(statement, PreparedStatement.RETURN_GENERATED_KEYS);
-            for (int p = 0; p < parameters.size(); p++) {
+            for (int p = 0; parameters.size() > p; p++) {
                 preparedStatement.setObject(p + 1, parameters.get(p));
             }
             // execute the statement and parse the results
index fb085a8903b7695420b87978f7eceafb70fd9bea..0bad777f92a08d42c7d27afc2244ad10358a5b27 100644 (file)
@@ -43,7 +43,7 @@ public class MSqlStatementResults extends MObject {
                 while (this.getResultSetReference().next()) {
                     ResultSetMetaData resultSetMetaData = this.getResultSetReference().getMetaData();
                     LinkedHashMap<String, Object> record = new LinkedHashMap<String, Object>();
-                    for (int f = 0; f < resultSetMetaData.getColumnCount(); f++) {
+                    for (int f = 0; resultSetMetaData.getColumnCount() > f; f++) {
                         String field = resultSetMetaData.getColumnLabel(f + 1);
                         record.put(field, this.getResultSetReference().getObject(field));
                     }
index c2629609e2abea177fc57167f8728bdcbec9126d..e22f343725886a3404cd864c426985f1f1c3e322 100644 (file)
@@ -45,7 +45,7 @@ public class MText extends MObject {
     /* Utility methods */
 
     public static String repeat(String x, int times) {
-        if (times < 1) {
+        if (1 > times) {
             throw new IllegalArgumentException(String.format("Invalid 'times': %s.", times));
         }
         //
@@ -384,7 +384,7 @@ public class MText extends MObject {
                     if ("script".equalsIgnoreCase(tagName)) {
                         throw new SAXException(String.format("Tag not allowed: %s.", tagName));
                     }
-                    for (int a = 0; a < attributes.getLength(); a++) {
+                    for (int a = 0; attributes.getLength() > a; a++) {
                         if (attributes.getLocalName(a).toLowerCase().startsWith("on")) {
                             throw new SAXException(String.format("Attribute not allowed: %s.", attributes.getLocalName(a)));
                         }
@@ -417,7 +417,7 @@ public class MText extends MObject {
         }
         catch (UnsupportedEncodingException exception) { // cannot happen
         }
-        catch (IOException exception) { // cannot happen, put here not to bypass UnsupportedEncodingException
+        catch (IOException exception) { // cannot happen; put here not to bypass UnsupportedEncodingException
         }
         // also convert named entities to numeric entities
         return MText.getXhtmlNumericEntitiesString(text);
index d8bcc6d0f80343ef0708dadb547cad8360a1131d..86ec598d9430be8b859de913399f64b2c18225b4 100644 (file)
@@ -51,13 +51,13 @@ public class MTranslator extends MObject {
 
     /* File */
 
-    public String getFile() {
+    protected String getFile() {
         return this.file;
     }
 
     /* Locale */
 
-    public Locale getBasicLocale() {
+    protected Locale getBasicLocale() {
         return this.basicLocale;
     }
 
index 459ecfcdc37a2d81f8ba190d8c19e86a6f3ed104..031b2019e0c65deb6b59b2d834cea280ae7957e3 100644 (file)
@@ -182,8 +182,7 @@ public abstract class MWebApplicationServlet extends MHttpServlet {
         byte[] responseContent = null;
         if (ajaxMode) {
             try {
-                MJsonObject returnValue = null;
-                returnValue = new MJsonObject();
+                MJsonObject returnValue = new MJsonObject();
                 returnValue.setValue("errorMode", new MJsonNumber("" + MWebApplicationServlet.ErrorMode.CLEAN.ordinal()));
                 MJsonString jsonParameter = new MJsonString();
                 jsonParameter.setValue(new String(content, MInformation.TEXT_ENCODING));
@@ -222,8 +221,7 @@ public abstract class MWebApplicationServlet extends MHttpServlet {
             if (MWebApplicationServlet.ErrorMode.DEBUG == errorMode) {
                 if (ajaxMode) {
                     try {
-                        MJsonObject returnValue = null;
-                        returnValue = new MJsonObject();
+                        MJsonObject returnValue = new MJsonObject();
                         returnValue.setValue("errorMode", new MJsonNumber("" + errorMode.ordinal()));
                         MJsonString jsonParameter = new MJsonString();
                         if (null != content.getMessage()) {
index f00949f96a675fa2439fa5bdae3cee4dcb28967d..5d285eb5b4e83915e7bbb6004dbd0d3f6730adb2 100644 (file)
@@ -72,12 +72,12 @@ public class MWebBreadcrumbs extends MWebDirectWidget {
         StringBuilder content = new StringBuilder("");
         content.append(String.format("<span class=\"MWebBreadcrumbPrefix %s\">%s</span>", customClasses, MText.getXhtmlEscapedString(this.getPrefix())));
         LinkedList<String> viewBreadcrumbs = this.getViewReference().getBrowserPageReference().getViewBreadcrumbs();
-        for (int t = 0; t < viewBreadcrumbs.size(); t++) {
+        for (int t = 0; viewBreadcrumbs.size() > t; t++) {
             content.append(" ");
-            if (t > 0) {
+            if (0 < t) {
                 content.append("» ");
             }
-            if (t < (viewBreadcrumbs.size() - 1))  {
+            if ((viewBreadcrumbs.size() - 1) > t)  {
                 String onItemSelectionFunction = String.format("javascript: m_messageInterface.fireMessage('%s', 'onItemSelection', {'viewCount': '%s'});", this.getId(), viewBreadcrumbs.size() - 1 - t);
                 content.append(String.format("<span class=\"MWebBreadcrumbItem %s\" onclick=\"%s\">%s</span>", customClasses, onItemSelectionFunction, MText.getXhtmlEscapedString(viewBreadcrumbs.get(t))));
             }
index b8d8bc872dbb0713959c5d3782e8604ef7d739e7..0c1f0e29ed0832daf01b868c8720d6e7a41c1f1a 100644 (file)
@@ -12,8 +12,6 @@ import com.marcozanon.macaco.text.MText;
 import java.util.Date;
 import java.util.LinkedList;
 import java.util.Random;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 public abstract class MWebBrowserPage extends MObject {
 
@@ -135,7 +133,7 @@ public abstract class MWebBrowserPage extends MObject {
     }
 
     protected void setStoppingViewThreadCount(int stoppingViewThreadCount) {
-        if (stoppingViewThreadCount < 0) {
+        if (0 > stoppingViewThreadCount) {
             throw new IllegalArgumentException(String.format("Invalid 'stoppingViewThreadCount': %s.", stoppingViewThreadCount));
         }
         //
@@ -198,10 +196,10 @@ public abstract class MWebBrowserPage extends MObject {
     }
 
     protected void unloadViewThreads(Object lastViewThreadReturnValue, int viewThreadCount, MWebView replacingView) throws MViewNotUnloadableWebException {
-        if ((null == lastViewThreadReturnValue) && (viewThreadCount < 1) && (null == replacingView)) {
+        if ((null == lastViewThreadReturnValue) && (1 > viewThreadCount) && (null == replacingView)) {
             throw new IllegalArgumentException("Invalid call mode: (null, < 1, null).");
         }
-        if (viewThreadCount < 1) {
+        if (1 > viewThreadCount) {
             throw new IllegalArgumentException(String.format("Invalid 'viewThreadCount': %s.", viewThreadCount));
         }
         else if ((this.getViewThreadCount() <= viewThreadCount) && (null == replacingView)) {
index 3d27614cc6ebb8521a9958ea30ac72fb7e29f810..837deaa89ab7a21fc5d52ae64d4785bb238f342a 100644 (file)
@@ -20,7 +20,7 @@ public class MWebColor extends MObject {
         if (null == color) {
             throw new IllegalArgumentException("Invalid 'color': null.");
         }
-        else if ((color.intValue() < 0) || (color.intValue() > 0xFFFFFF)) {
+        else if ((0 > color.intValue()) || (0xFFFFFF < color.intValue())) {
             throw new IllegalArgumentException(String.format("Invalid 'color': %s.", color));
         }
         //
index 7e5dd97c28d6020540ef4ad0615966fd1d2c3642..1f5b2219384d390cd75a8d6cf77345a2fcb3af80 100644 (file)
@@ -7,7 +7,6 @@
 package com.marcozanon.macaco.web.ui;
 
 import com.marcozanon.macaco.text.MText;
-import java.util.LinkedHashMap;
 
 public class MWebExtendedTextBox extends MWebTextBox {
 
index 5b8bfee708c93e6e8ab06d74ddf9d7a84a987f28..fb2aa7127eb897e075a2836e65dc784811da3e40 100644 (file)
@@ -20,10 +20,10 @@ public class MWebGridLayout extends MWebDirectWidget {
         //
         this.setWidth(new MWebMeasure(100, MWebMeasure.Unit.PERCENT)); // manual override
         //
-        if (rowCount < 1) {
+        if (1 > rowCount) {
             throw new IllegalArgumentException(String.format("Invalid 'rowCount': %s.", rowCount));
         }
-        if (columnCount < 1) {
+        if (1 > columnCount) {
             throw new IllegalArgumentException(String.format("Invalid 'columnCount': %s.", columnCount));
         }
         //
@@ -56,10 +56,10 @@ public class MWebGridLayout extends MWebDirectWidget {
     }
 
     public MWebGridLayoutCell getCellReference(int rowIndex, int columnIndex) {
-        if ((rowIndex < 0) || (rowIndex > (this.getCellsReference().length - 1))) {
+        if ((0 > rowIndex) || ((this.getCellsReference().length - 1) < rowIndex)) {
             throw new IllegalArgumentException(String.format("Invalid 'rowIndex': %s.", rowIndex));
         }
-        if ((columnIndex < 0) || (columnIndex > (this.getCellsReference()[0].length - 1))) {
+        if ((0 > columnIndex) || ((this.getCellsReference()[0].length - 1) < columnIndex)) {
             throw new IllegalArgumentException(String.format("Invalid 'columnIndex': %s.", columnIndex));
         }
         //
@@ -71,8 +71,8 @@ public class MWebGridLayout extends MWebDirectWidget {
     protected void setView(MWebView view) throws MUniqueWidgetIdNotAvailableWebException {
         super.setView(view);
         //
-        for (int r = 0; r < this.getRowCount(); r++) {
-            for (int c = 0; c < this.getColumnCount(); c++) {
+        for (int r = 0; this.getRowCount() > r; r++) {
+            for (int c = 0; this.getColumnCount() > c; c++) {
                 this.getCellReference(r, c).setView(view);
             }
         }
@@ -85,8 +85,8 @@ public class MWebGridLayout extends MWebDirectWidget {
             return super.getDisplayWidgetReferenceById(id);
         }
         catch (MDisplayWidgetNotFoundWebException exception) {
-            for (int r = 0; r < this.getRowCount(); r++) {
-                for (int c = 0; c < this.getColumnCount(); c++) {
+            for (int r = 0; this.getRowCount() > r; r++) {
+                for (int c = 0; this.getColumnCount() > c; c++) {
                     try {
                         return this.getCellReference(r, c).getDisplayWidgetReferenceById(id);
                     }
@@ -101,10 +101,10 @@ public class MWebGridLayout extends MWebDirectWidget {
     /* Refresh */
 
     protected boolean isCellRefreshable(int rowIndex, int columnIndex) {
-        if ((rowIndex < 0) || (rowIndex > (this.getCellsReference().length - 1))) {
+        if ((0 > rowIndex) || ((this.getCellsReference().length - 1) < rowIndex)) {
             throw new IllegalArgumentException(String.format("Invalid 'rowIndex': %s.", rowIndex));
         }
-        if ((columnIndex < 0) || (columnIndex > (this.getCellsReference()[0].length - 1))) {
+        if ((0 > columnIndex) || ((this.getCellsReference()[0].length - 1) < columnIndex)) {
             throw new IllegalArgumentException(String.format("Invalid 'columnIndex': %s.", columnIndex));
         }
         //
@@ -117,9 +117,9 @@ public class MWebGridLayout extends MWebDirectWidget {
                 cellsRefreshableMode[r][c] = 1;
                 int rs = this.getCellReference(r, c).getRowSpan();
                 int cs = this.getCellReference(r, c).getColumnSpan();
-                if ((rs > 1) || (cs > 1)) {
-                    for (int rsi = r + 1; rsi <= Math.min(rowIndex, r + rs - 1); rsi++) {
-                        for (int csi = c + 1; csi <= Math.min(columnIndex, c + cs - 1); csi++) {
+                if ((1 < rs) || (1 < cs)) {
+                    for (int rsi = r + 1; Math.min(rowIndex, r + rs - 1) >= rsi; rsi++) {
+                        for (int csi = c + 1; Math.min(columnIndex, c + cs - 1) >= csi; csi++) {
                             cellsRefreshableMode[rsi][csi] = -1;
                         }
                     }
@@ -145,9 +145,9 @@ public class MWebGridLayout extends MWebDirectWidget {
         }
         StringBuilder content = new StringBuilder("");
         content.append(String.format("<table class=\"MWebGridLayoutTable %s\" style=\"display: inline-table;\" id=\"%s\">", customClasses, this.getId()));
-        for (int r = 0; r < this.getRowCount(); r++) {
+        for (int r = 0; this.getRowCount() > r; r++) {
             content.append(String.format("<tr class=\"MWebGridLayoutRow %s\">", customClasses));
-            for (int c = 0; c < this.getColumnCount(); c++) {
+            for (int c = 0; this.getColumnCount() > c; c++) {
                 String displayedMode = "";
                 if (!this.isCellRefreshable(r, c)) {
                     displayedMode = "display: none;";
@@ -160,8 +160,8 @@ public class MWebGridLayout extends MWebDirectWidget {
         content.append("</table>");
         this.getApplicationContextReference().addPlainTextResponseContent(String.format("if ($('%s')) { $('%s').parentNode.innerHTML = '%s'; }", this.getId(), this.getId(), MText.getJavascriptEscapedString(content.toString())));
         //
-        for (int r = 0; r < this.getRowCount(); r++) {
-            for (int c = 0; c < this.getColumnCount(); c++) {
+        for (int r = 0; this.getRowCount() > r; r++) {
+            for (int c = 0; this.getColumnCount() > c; c++) {
                 this.getCellReference(r, c).onRefresh();
             }
         }
index 2b556b6c0423bca00bb606386e1d64ba97981438..359f152592c01f92e188121dd0b546eb9f9f6dbf 100644 (file)
@@ -101,7 +101,7 @@ public class MWebGridLayoutCell extends MWebCellWidget {
     /* Span */
 
     public void setRowSpan(int rowSpan) {
-        if (rowSpan < 1) {
+        if (1 > rowSpan) {
             throw new IllegalArgumentException("Invalid 'rowSpan': must be > 1.");
         }
         //
@@ -127,7 +127,7 @@ public class MWebGridLayoutCell extends MWebCellWidget {
     }
 
     public void setColumnSpan(int columnSpan) {
-        if (columnSpan < 1) {
+        if (1 > columnSpan) {
             throw new IllegalArgumentException("Invalid 'columnSpan': must be > 1.");
         }
         //
index 139170e5f4fbfee67649705497085fb34588af7e..d51da3b160339e70381d2a69ff85f605f2ee5b31 100644 (file)
@@ -137,7 +137,7 @@ public abstract class MWebTable extends MWebDirectWidget {
     }
 
     protected void setRowsPerPage(int rowsPerPage, boolean refreshMode) {
-        if (rowsPerPage < 1) {
+        if (1 > rowsPerPage) {
             throw new IllegalArgumentException(String.format("Invalid 'rowsPerPage': %s: must be positive.", rowsPerPage));
         }
         //
@@ -173,7 +173,7 @@ public abstract class MWebTable extends MWebDirectWidget {
             this.selectedPage = 1;
             return;
         }
-        else if ((null != selectedPage) && ((selectedPage.intValue() < 1) || (selectedPage.intValue() > (int)Math.ceil((float)this.getRowCount() / (float)this.getRowsPerPage())))) {
+        else if ((null != selectedPage) && ((1 > selectedPage.intValue()) || (selectedPage.intValue() > (int)Math.ceil((float)this.getRowCount() / (float)this.getRowsPerPage())))) {
             throw new IllegalArgumentException(String.format("Invalid 'selectedPage': %s: out of range.", selectedPage));
         }
         //
@@ -492,9 +492,9 @@ public abstract class MWebTable extends MWebDirectWidget {
             return super.getDisplayWidgetReferenceById(id);
         }
         catch (MDisplayWidgetNotFoundWebException exception) {
-            for (MWebTableCell columnHeadersCell: this.getColumnHeadersReference().values()) {
+            for (MWebTableCell columnHeaderCell: this.getColumnHeadersReference().values()) {
                 try {
-                    return columnHeadersCell.getDisplayWidgetReferenceById(id);
+                    return columnHeaderCell.getDisplayWidgetReferenceById(id);
                 }
                 catch (MDisplayWidgetNotFoundWebException exception2) {
                 }
@@ -575,11 +575,11 @@ public abstract class MWebTable extends MWebDirectWidget {
         content.append(String.format("<option value=\"\" %s>*</option>", selectedMode));
         int rowCount = this.getRowCount();
         int rowsPerPage = this.getRowsPerPage();
-        if (rowCount > 0) {
+        if (0 < rowCount) {
             int p = 0;
             int firstRow = 0;
             int lastRow = 0;
-            for (p = 1; p <= (int)Math.ceil((float)rowCount / (float)rowsPerPage); p++) {
+            for (p = 1; (int)Math.ceil((float)rowCount / (float)rowsPerPage) >= p; p++) {
                 firstRow = (p - 1) * rowsPerPage;
                 lastRow = Math.min((p * rowsPerPage) - 1, rowCount - 1);
                 if ((null != selectedPage) && (selectedPage.intValue() == p)) {
@@ -660,7 +660,7 @@ public abstract class MWebTable extends MWebDirectWidget {
             if (null == selectedPage) {
                 throw new MUnexpectedMessageWebException("Invalid message: selected page parameter not available.");
             }
-            else if ((!MText.isEmpty(selectedPage)) && ((Integer.parseInt(selectedPage) < 1) || (Integer.parseInt(selectedPage) > (int)Math.ceil((float)this.getRowCount() / (float)this.getRowsPerPage())))) {
+            else if ((!MText.isEmpty(selectedPage)) && ((1 > Integer.parseInt(selectedPage)) || (Integer.parseInt(selectedPage) > (int)Math.ceil((float)this.getRowCount() / (float)this.getRowsPerPage())))) {
                 throw new MUnexpectedMessageWebException(String.format("Invalid message: %s: selected page parameter out of range.", selectedPage));
             }
             this.onPageSelection(selectedPage);
index 06b5a6d54f29517a89b90a11e2aed35548ca3305..f072c4ada4e19009474096ebc2be02194a10fd9e 100644 (file)
@@ -51,7 +51,7 @@ public class MWebView extends MObject implements Runnable {
             catch (MViewThreadStoppingWebRuntimeException exception) {
                 break;
             }
-            catch (Exception exception) { // any other exception, put here not to bypass MViewThreadStoppingWebRuntimeException
+            catch (Exception exception) { // any other exception; put here not to bypass MViewThreadStoppingWebRuntimeException
                 try {
                     this.getBrowserPageReference().setLastViewThreadException(exception);
                 }
@@ -178,7 +178,7 @@ public class MWebView extends MObject implements Runnable {
     }
 
     public void setDownloader(int index, MWebDownloader downloader) throws MUniqueWidgetIdNotAvailableWebException {
-        if ((index < 0) || (index > (this.getDownloadersReference().size() - 1))) {
+        if ((0 > index) || ((this.getDownloadersReference().size() - 1) < index)) {
             throw new IllegalArgumentException(String.format("Invalid 'index': %s: out of range.", index));
         }
         if (null == downloader) {
@@ -194,7 +194,7 @@ public class MWebView extends MObject implements Runnable {
     }
 
     public MWebDownloader getDownloaderReference(int index) {
-        if ((index < 0) || (index > (this.getDownloadersReference().size() - 1))) {
+        if ((0 > index) || ((this.getDownloadersReference().size() - 1) < index)) {
             throw new IllegalArgumentException(String.format("Invalid 'index': %s: out of range.", index));
         }
         //
@@ -223,7 +223,7 @@ public class MWebView extends MObject implements Runnable {
     }
 
     public void removeDownloader(int index) {
-        if ((index < 0) || (index > (this.getDownloadersReference().size() - 1))) {
+        if ((0 > index) || ((this.getDownloadersReference().size() - 1) < index)) {
             throw new IllegalArgumentException(String.format("Invalid 'index': %s: out of range.", index));
         }
         //
index f86a911f0400ec35989d256a19427b3fedef4384..fee6d1c2a3ec150ff5444dab2f99bc1300f66e43 100644 (file)
@@ -86,19 +86,6 @@ html, body {
     border: 1px solid #8a8a8a;
 }
 
-/* Datetime box */
-
-.MWebDatetimeBox {
-    color: #444444;
-    background-color: #ffffff;
-    border: 1px solid #444444;
-}
-.MWebDatetimeBox[disabled] {
-    color: #8a8a8a;
-    background-color: #cccccc;
-    border: 1px solid #8a8a8a;
-}
-
 /* Extended text box */
 
 .MWebExtendedTextBox {
@@ -327,19 +314,6 @@ html, body {
     border: 1px solid #444444;
 }
 
-/* Time box */
-
-.MWebTimeBox {
-    color: #444444;
-    background-color: #ffffff;
-    border: 1px solid #444444;
-}
-.MWebTimeBox[disabled] {
-    color: #8a8a8a;
-    background-color: #cccccc;
-    border: 1px solid #8a8a8a;
-}
-
 /* Uploader */
 
 .MWebUploader {
index 256d10041869972f85fb7afceb6ad7798dc1d3f3..774578ac233ac96c777c4828a37d48327739cc6b 100644 (file)
@@ -11,7 +11,7 @@ function MWebCustomJsonHelper() { // CAUTION: partial Json implementation (for M
         var n = 0;
         for (p in x) {
             n++;
-            if (n > 1) {
+            if (1 < n) {
                 string += ', ';
             }
             string += this.encode(x[p]);
@@ -36,7 +36,7 @@ function MWebCustomJsonHelper() { // CAUTION: partial Json implementation (for M
         var n = 0;
         for (var p in x) {
             n++;
-            if (n > 1) {
+            if (1 < n) {
                 string += ', ';
             }
             string += this.encodeString(p) + ': ' + this.encode(x[p]);
@@ -71,9 +71,9 @@ function MWebCustomJsonHelper() { // CAUTION: partial Json implementation (for M
             else if ('\t' == x[c]) {
                 string += '\\t';
             }
-            else if (x[c] <= 0x001F) { // non-special control Ascii character
+            else if (0x001F >= x[c]) { // non-special control Ascii character
                 var s = x.charCodeAt(c).toString(16).toUpperCase();
-                while (s.length < 4) {
+                while (4 > s.length) {
                     s = '0' + s;
                 }
                 string += '\\u' + s;
index d289fb05b05bc93af78f8885107d48e04a5f7af1..870a25febb33c83999092989c1fa41a674a52d2b 100644 (file)
@@ -59,7 +59,7 @@ function MWebNotificationArea() {
         }
         var i = $('m_notificationArea');
         if (null != i) {
-            if (i.style.opacity < 0.1) {
+            if (0.1 > i.style.opacity) {
                 clearInterval(this.interval);
                 this.interval = null;
                 i.style.display = 'none';