From: Marco Zanon Date: Sun, 26 Aug 2012 09:44:24 +0000 (+0000) Subject: Modified code to comply with the guidelines. X-Git-Tag: 2.0~7 X-Git-Url: https://gitweb.marcozanon.com/?a=commitdiff_plain;h=f1765a85b9b87454060881e55bf2541892b6e562;p=Macaco Modified code to comply with the guidelines. --- diff --git a/src/java/com/marcozanon/macaco/conversion/MDateConverter.java b/src/java/com/marcozanon/macaco/conversion/MDateConverter.java index 19ac674..ceb748c 100644 --- a/src/java/com/marcozanon/macaco/conversion/MDateConverter.java +++ b/src/java/com/marcozanon/macaco/conversion/MDateConverter.java @@ -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 */ diff --git a/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java b/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java index 6b61ce6..7200cc6 100644 --- a/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java +++ b/src/java/com/marcozanon/macaco/conversion/MNumberConverter.java @@ -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()); } } diff --git a/src/java/com/marcozanon/macaco/json/MJsonArray.java b/src/java/com/marcozanon/macaco/json/MJsonArray.java index fae5552..8c1cc88 100644 --- a/src/java/com/marcozanon/macaco/json/MJsonArray.java +++ b/src/java/com/marcozanon/macaco/json/MJsonArray.java @@ -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()); diff --git a/src/java/com/marcozanon/macaco/json/MJsonNumber.java b/src/java/com/marcozanon/macaco/json/MJsonNumber.java index 886e854..401be4e 100644 --- a/src/java/com/marcozanon/macaco/json/MJsonNumber.java +++ b/src/java/com/marcozanon/macaco/json/MJsonNumber.java @@ -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(); } } diff --git a/src/java/com/marcozanon/macaco/json/MJsonObject.java b/src/java/com/marcozanon/macaco/json/MJsonObject.java index 29e9830..a64056c 100644 --- a/src/java/com/marcozanon/macaco/json/MJsonObject.java +++ b/src/java/com/marcozanon/macaco/json/MJsonObject.java @@ -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) + "\""); diff --git a/src/java/com/marcozanon/macaco/json/MJsonString.java b/src/java/com/marcozanon/macaco/json/MJsonString.java index af913a0..2269530 100644 --- a/src/java/com/marcozanon/macaco/json/MJsonString.java +++ b/src/java/com/marcozanon/macaco/json/MJsonString.java @@ -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)); diff --git a/src/java/com/marcozanon/macaco/logging/MLogPlainTextFile.java b/src/java/com/marcozanon/macaco/logging/MLogPlainTextFile.java index a5c0d0e..0e3d16d 100644 --- a/src/java/com/marcozanon/macaco/logging/MLogPlainTextFile.java +++ b/src/java/com/marcozanon/macaco/logging/MLogPlainTextFile.java @@ -62,7 +62,7 @@ public class MLogPlainTextFile extends MLogTarget { /* File */ - public String getFile() { + protected String getFile() { return this.file; } diff --git a/src/java/com/marcozanon/macaco/sql/MSqlConnection.java b/src/java/com/marcozanon/macaco/sql/MSqlConnection.java index bdcf530..9047a90 100644 --- a/src/java/com/marcozanon/macaco/sql/MSqlConnection.java +++ b/src/java/com/marcozanon/macaco/sql/MSqlConnection.java @@ -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 diff --git a/src/java/com/marcozanon/macaco/sql/MSqlStatementResults.java b/src/java/com/marcozanon/macaco/sql/MSqlStatementResults.java index fb085a8..0bad777 100644 --- a/src/java/com/marcozanon/macaco/sql/MSqlStatementResults.java +++ b/src/java/com/marcozanon/macaco/sql/MSqlStatementResults.java @@ -43,7 +43,7 @@ public class MSqlStatementResults extends MObject { while (this.getResultSetReference().next()) { ResultSetMetaData resultSetMetaData = this.getResultSetReference().getMetaData(); LinkedHashMap record = new LinkedHashMap(); - 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)); } diff --git a/src/java/com/marcozanon/macaco/text/MText.java b/src/java/com/marcozanon/macaco/text/MText.java index c262960..e22f343 100644 --- a/src/java/com/marcozanon/macaco/text/MText.java +++ b/src/java/com/marcozanon/macaco/text/MText.java @@ -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); diff --git a/src/java/com/marcozanon/macaco/text/MTranslator.java b/src/java/com/marcozanon/macaco/text/MTranslator.java index d8bcc6d..86ec598 100644 --- a/src/java/com/marcozanon/macaco/text/MTranslator.java +++ b/src/java/com/marcozanon/macaco/text/MTranslator.java @@ -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; } diff --git a/src/java/com/marcozanon/macaco/web/ui/MWebApplicationServlet.java b/src/java/com/marcozanon/macaco/web/ui/MWebApplicationServlet.java index 459ecfc..031b201 100644 --- a/src/java/com/marcozanon/macaco/web/ui/MWebApplicationServlet.java +++ b/src/java/com/marcozanon/macaco/web/ui/MWebApplicationServlet.java @@ -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()) { diff --git a/src/java/com/marcozanon/macaco/web/ui/MWebBreadcrumbs.java b/src/java/com/marcozanon/macaco/web/ui/MWebBreadcrumbs.java index f00949f..5d285eb 100644 --- a/src/java/com/marcozanon/macaco/web/ui/MWebBreadcrumbs.java +++ b/src/java/com/marcozanon/macaco/web/ui/MWebBreadcrumbs.java @@ -72,12 +72,12 @@ public class MWebBreadcrumbs extends MWebDirectWidget { StringBuilder content = new StringBuilder(""); content.append(String.format("%s", customClasses, MText.getXhtmlEscapedString(this.getPrefix()))); LinkedList 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("%s", customClasses, onItemSelectionFunction, MText.getXhtmlEscapedString(viewBreadcrumbs.get(t)))); } diff --git a/src/java/com/marcozanon/macaco/web/ui/MWebBrowserPage.java b/src/java/com/marcozanon/macaco/web/ui/MWebBrowserPage.java index b8d8bc8..0c1f0e2 100644 --- a/src/java/com/marcozanon/macaco/web/ui/MWebBrowserPage.java +++ b/src/java/com/marcozanon/macaco/web/ui/MWebBrowserPage.java @@ -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)) { diff --git a/src/java/com/marcozanon/macaco/web/ui/MWebColor.java b/src/java/com/marcozanon/macaco/web/ui/MWebColor.java index 3d27614..837deaa 100644 --- a/src/java/com/marcozanon/macaco/web/ui/MWebColor.java +++ b/src/java/com/marcozanon/macaco/web/ui/MWebColor.java @@ -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)); } // diff --git a/src/java/com/marcozanon/macaco/web/ui/MWebExtendedTextBox.java b/src/java/com/marcozanon/macaco/web/ui/MWebExtendedTextBox.java index 7e5dd97..1f5b221 100644 --- a/src/java/com/marcozanon/macaco/web/ui/MWebExtendedTextBox.java +++ b/src/java/com/marcozanon/macaco/web/ui/MWebExtendedTextBox.java @@ -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 { diff --git a/src/java/com/marcozanon/macaco/web/ui/MWebGridLayout.java b/src/java/com/marcozanon/macaco/web/ui/MWebGridLayout.java index 5b8bfee..fb2aa71 100644 --- a/src/java/com/marcozanon/macaco/web/ui/MWebGridLayout.java +++ b/src/java/com/marcozanon/macaco/web/ui/MWebGridLayout.java @@ -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("", customClasses, this.getId())); - for (int r = 0; r < this.getRowCount(); r++) { + for (int r = 0; this.getRowCount() > r; r++) { content.append(String.format("", 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("
"); 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(); } } diff --git a/src/java/com/marcozanon/macaco/web/ui/MWebGridLayoutCell.java b/src/java/com/marcozanon/macaco/web/ui/MWebGridLayoutCell.java index 2b556b6..359f152 100644 --- a/src/java/com/marcozanon/macaco/web/ui/MWebGridLayoutCell.java +++ b/src/java/com/marcozanon/macaco/web/ui/MWebGridLayoutCell.java @@ -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."); } // diff --git a/src/java/com/marcozanon/macaco/web/ui/MWebTable.java b/src/java/com/marcozanon/macaco/web/ui/MWebTable.java index 139170e..d51da3b 100644 --- a/src/java/com/marcozanon/macaco/web/ui/MWebTable.java +++ b/src/java/com/marcozanon/macaco/web/ui/MWebTable.java @@ -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("", 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); diff --git a/src/java/com/marcozanon/macaco/web/ui/MWebView.java b/src/java/com/marcozanon/macaco/web/ui/MWebView.java index 06b5a6d..f072c4a 100644 --- a/src/java/com/marcozanon/macaco/web/ui/MWebView.java +++ b/src/java/com/marcozanon/macaco/web/ui/MWebView.java @@ -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)); } // diff --git a/src/resources/css/default.css b/src/resources/css/default.css index f86a911..fee6d1c 100644 --- a/src/resources/css/default.css +++ b/src/resources/css/default.css @@ -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 { diff --git a/src/resources/javascript/MWebCustomJsonHelper.js b/src/resources/javascript/MWebCustomJsonHelper.js index 256d100..774578a 100644 --- a/src/resources/javascript/MWebCustomJsonHelper.js +++ b/src/resources/javascript/MWebCustomJsonHelper.js @@ -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; diff --git a/src/resources/javascript/MWebNotificationArea.js b/src/resources/javascript/MWebNotificationArea.js index d289fb0..870a25f 100644 --- a/src/resources/javascript/MWebNotificationArea.js +++ b/src/resources/javascript/MWebNotificationArea.js @@ -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';