Replaced custom String checks with MText.isBlank() and MText.isEmpty().
authorMarco Zanon <info@marcozanon.com>
Sun, 3 Jun 2012 08:54:47 +0000 (08:54 +0000)
committerMarco Zanon <info@marcozanon.com>
Sun, 3 Jun 2012 08:54:47 +0000 (08:54 +0000)
29 files changed:
src/java/com/marcozanon/macaco/MInformation.java
src/java/com/marcozanon/macaco/attic/configuration/MConfiguration.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebApplicationContext.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebApplicationServlet.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebBrowserPage.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebComboBox.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebDateBox.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebDisplayWidget.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebFont.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebMessage.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebNumberBox.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebTable.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebTableCell.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebVerticalMenu.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebView.java
src/java/com/marcozanon/macaco/attic/web/ui/MWebWidget.java
src/java/com/marcozanon/macaco/conversion/MDateConverter.java
src/java/com/marcozanon/macaco/conversion/MNumberConverter.java
src/java/com/marcozanon/macaco/json/MJsonBoolean.java
src/java/com/marcozanon/macaco/json/MJsonNull.java
src/java/com/marcozanon/macaco/json/MJsonNumber.java
src/java/com/marcozanon/macaco/json/MJsonObject.java
src/java/com/marcozanon/macaco/json/MJsonString.java
src/java/com/marcozanon/macaco/logging/MLogPlainTextFile.java
src/java/com/marcozanon/macaco/sql/MSqlConnection.java
src/java/com/marcozanon/macaco/sql/MSqlConnectionGenerator.java
src/java/com/marcozanon/macaco/sql/MSqlStatementResults.java
src/java/com/marcozanon/macaco/sql/MSqlTable.java
src/java/com/marcozanon/macaco/text/MTranslator.java

index cbe7d05b865582f81343aa569bb82287601b259f..8f28f2fb65d4cea2540603c1a6589804155a70e8 100644 (file)
@@ -6,6 +6,7 @@
 
 package com.marcozanon.macaco;
 
+import com.marcozanon.macaco.text.MText;
 import java.io.BufferedInputStream;
 import java.io.InputStream;
 import java.io.IOException;
@@ -59,7 +60,7 @@ public class MInformation extends MObject {
     /* Resources */
 
     public static byte[] getCoreResource(String resource) throws IOException {
-        if ((null == resource) || ("".equals(resource))) {
+        if (MText.isBlank(resource)) {
             throw new IllegalArgumentException("Invalid 'resource': null or empty.");
         }
         // modified from http://articles.techrepublic.com.com/5100-10878_11-1046714.html
index dfd4e65ad3d9ae3b456769ef4da4edfd41466aea..e06677774141f4edcd5473539f5c8d5dd6faa257 100644 (file)
@@ -8,6 +8,7 @@ package com.marcozanon.macaco.attic.configuration;
 
 import com.marcozanon.macaco.MInformation;
 import com.marcozanon.macaco.MObject;
+import com.marcozanon.macaco.text.MText;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.InputStreamReader;
@@ -37,7 +38,7 @@ public class MConfiguration extends MObject {
     /* Strings management */
 
     public void parseFile(String file) throws MFileParsingConfigurationException {
-        if ((null == file) || ("".equals(file))) {
+        if (MText.isBlank(file)) {
             throw new IllegalArgumentException("Invalid 'file': null or empty.");
         }
         //
@@ -63,7 +64,7 @@ public class MConfiguration extends MObject {
                     break;
                 }
                 line = line.trim();
-                if ((line.startsWith("#")) || (line.startsWith(";")) || ("".equals(line))) {
+                if ((line.startsWith("#")) || (line.startsWith(";")) || (MText.isEmpty(line))) {
                     continue;
                 }
                 else {
@@ -95,7 +96,7 @@ public class MConfiguration extends MObject {
     }
 
     public String getValue(String key) throws MValueNotFoundConfigurationException {
-        if ((null == key) || ("".equals(key))) {
+        if (MText.isBlank(key)) {
             throw new IllegalArgumentException("Invalid 'key': null or empty.");
         }
         //
index 0d8879e07b958d4474a2543b4180ed0d79915c73..523daaf9872380482d8e365d09ab7c9e57724e9a 100644 (file)
@@ -83,7 +83,7 @@ public abstract class MWebApplicationContext extends MObject {
     /* Response content */
 
     protected void setResponseContentType(String responseContentType) {
-        if ((null == responseContentType) || ("".equals(responseContentType))) {
+        if (MText.isBlank(responseContentType)) {
             throw new IllegalArgumentException("Invalid 'responseContentType': null or empty.");
         }
         //
@@ -100,7 +100,7 @@ public abstract class MWebApplicationContext extends MObject {
     }
 
     protected void addPlainTextResponseContent(String responseContent) throws MResponseWebException {
-        if ((null == responseContent) || ("".equals(responseContent))) {
+        if (MText.isBlank(responseContent)) {
             throw new IllegalArgumentException("Invalid 'responseContent': null or empty.");
         }
         //
@@ -122,7 +122,7 @@ public abstract class MWebApplicationContext extends MObject {
     }
 
     protected void setXhtmlResponseContent(String responseContent) throws MResponseWebException {
-        if ((null == responseContent) || ("".equals(responseContent))) {
+        if (MText.isBlank(responseContent)) {
             throw new IllegalArgumentException("Invalid 'responseContent': null or empty.");
         }
         //
@@ -178,7 +178,7 @@ public abstract class MWebApplicationContext extends MObject {
     }
 
     public void addNotificationAreaMessage(boolean error, String message, boolean framedOutput) throws MResponseWebException {
-        if ((null == message) || ("".equals(message))) {
+        if (MText.isBlank(message)) {
             throw new IllegalArgumentException("Invalid 'message': null or empty.");
         }
         //
index 22c27893907b221897de4a57dcb1f93e8cfd2a47..c62f74705886903463a3b5b2a73448efe5dbd544 100644 (file)
@@ -14,6 +14,7 @@ import com.marcozanon.macaco.json.MJsonObject;
 import com.marcozanon.macaco.json.MJsonString;
 import com.marcozanon.macaco.logging.MLogFilter;
 import com.marcozanon.macaco.logging.MLoggingException;
+import com.marcozanon.macaco.text.MText;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import javax.servlet.http.HttpServletRequest;
@@ -176,7 +177,7 @@ public abstract class MWebApplicationServlet extends MHttpServlet {
     /* Responses */
 
     protected void returnStandardResponse(HttpServletResponse response, String contentType, byte[] content, boolean ajaxMode) throws IOException {
-        if ((null == contentType) || ("".equals(contentType))) {
+        if (MText.isBlank(contentType)) {
             contentType = MInformation.HttpContentType.PLAIN.toString();
         }
         // prepare response content
@@ -277,7 +278,7 @@ public abstract class MWebApplicationServlet extends MHttpServlet {
         if (null == response) {
             throw new IllegalArgumentException("Invalid 'response': null.");
         }
-        if ((null == contentType) || ("".equals(contentType))) {
+        if (MText.isBlank(contentType)) {
             throw new IllegalArgumentException("Invalid 'contentType': null or empty.");
         }
         if (null == content) {
index 783a72cf84b0702d72f26380338b9d17b1940607..50e5ddeca9b73278d155440f81d7519419169db5 100644 (file)
@@ -279,7 +279,7 @@ public abstract class MWebBrowserPage extends MObject {
     /* Redirection */
 
     public void redirect(String url) throws MResponseWebException {
-        if ((null == url) || ("".equals(url))) {
+        if (MText.isBlank(url)) {
             throw new IllegalArgumentException("Invalid 'url': null or empty.");
         }
         //
index 1e8a52767fe113c73805b4f5d6f015d416544f0f..e314e0847abd5b3acbc27c937c6b71a99c8cc140 100644 (file)
@@ -71,7 +71,7 @@ public class MWebComboBox extends MWebDirectWidget {
         }
         else {
             for (String k: items.keySet()) {
-                if ((null == k) || ("".equals(k))) {
+                if (MText.isBlank(k)) {
                     throw new IllegalArgumentException("Invalid 'items': item key null or empty.");
                 }
                 else if (null == items.get(k)) {
@@ -127,7 +127,7 @@ public class MWebComboBox extends MWebDirectWidget {
         if (null == selectedItemKey) {
             throw new IllegalArgumentException("Invalid 'selectedItemKey': null.");
         }
-        else if ((!"".equals(selectedItemKey)) && (!this.getItemsReference().containsKey(selectedItemKey))) {
+        else if ((!MText.isEmpty(selectedItemKey)) && (!this.getItemsReference().containsKey(selectedItemKey))) {
             throw new IllegalArgumentException(String.format("Invalid 'selectedItemKey': %s: not available.", selectedItemKey));
         }
         //
@@ -155,7 +155,7 @@ public class MWebComboBox extends MWebDirectWidget {
     public int getSelectedItemIndex() {
         String selectedItemKey = this.getSelectedItemKey();
         int selectedItemIndex = 0;
-        if ("".equals(selectedItemKey)) {
+        if (MText.isEmpty(selectedItemKey)) {
             return selectedItemIndex;
         }
         for (String k: this.getItemsReference().keySet()) {
@@ -305,7 +305,7 @@ public class MWebComboBox extends MWebDirectWidget {
             if (null == selectedItemKey) {
                 throw new MUnexpectedMessageWebException("Invalid message: selected item key parameter not available.");
             }
-            else if ((!"".equals(selectedItemKey)) && (!this.getItemsReference().keySet().contains(selectedItemKey))) {
+            else if ((!MText.isEmpty(selectedItemKey)) && (!this.getItemsReference().keySet().contains(selectedItemKey))) {
                 throw new MUnexpectedMessageWebException(String.format("Invalid message: %s: selected item key parameter not recognized.", selectedItemKey));
             }
             this.onBlur(selectedItemKey);
@@ -318,7 +318,7 @@ public class MWebComboBox extends MWebDirectWidget {
             if (null == selectedItemKey) {
                 throw new MUnexpectedMessageWebException("Invalid message: selected item key parameter not available.");
             }
-            else if ((!"".equals(selectedItemKey)) && (!this.getItemsReference().keySet().contains(selectedItemKey))) {
+            else if ((!MText.isEmpty(selectedItemKey)) && (!this.getItemsReference().keySet().contains(selectedItemKey))) {
                 throw new MUnexpectedMessageWebException(String.format("Invalid message: %s: selected item key parameter not recognized.", selectedItemKey));
             }
             this.onChange(selectedItemKey);
index 2504e4a6861fc7d811c84020b137cf862c8144f9..1c750d5bb44e8f1f439ce7b5ea1201df7513fc5a 100644 (file)
@@ -63,7 +63,7 @@ public class MWebDateBox extends MWebTextBox {
     public Date getDate() throws MFormatConversionException {
         Date date = null;
         String text = this.getText();
-        if (!"".equals(text)) {
+        if (!MText.isEmpty(text)) {
             return this.getDateConverterReference().getDateFromString(text);
         }
         return date;
@@ -73,7 +73,7 @@ public class MWebDateBox extends MWebTextBox {
 
     public void validate() throws MValidationWebException {
         String text = this.getText();
-        if (!"".equals(text)) {
+        if (!MText.isEmpty(text)) {
             try {
                 MDateConverter dateConverter = this.getDateConverterReference();
                 this.setText(dateConverter.getStringFromDate(dateConverter.getDateFromString(text)));
index f0c12ed20f7eedd0043935a6d53eea2e0465bb97..bf69ef09e7a3bc094e59191a6526733b81a16d8b 100644 (file)
@@ -6,6 +6,8 @@
 
 package com.marcozanon.macaco.attic.web.ui;
 
+import com.marcozanon.macaco.text.MText;
+
 public abstract class MWebDisplayWidget extends MWebWidget {
 
     public static enum Side {
@@ -84,7 +86,7 @@ public abstract class MWebDisplayWidget extends MWebWidget {
     }
 
     protected void setCustomClasses(String customClasses, boolean refreshMode) {
-        if ("".equals(customClasses)) {
+        if (MText.isEmpty(customClasses)) {
             throw new IllegalArgumentException("Invalid 'customClasses': empty.");
         }
         //
@@ -693,7 +695,7 @@ public abstract class MWebDisplayWidget extends MWebWidget {
     /* Display widgets */
 
     protected MWebDisplayWidget getDisplayWidgetReferenceById(String id) throws MDisplayWidgetNotFoundWebException {
-        if ((null == id) || ("".equals(id))) {
+        if (MText.isBlank(id)) {
             throw new IllegalArgumentException("Invalid 'id': null or empty.");
         }
         //
index 9d3407c3e9dbd8f09d8c4cbf3d6e8b6c8bb679af..a219a5eb6f47363f50a60dda3f4ce0550da5aa58 100644 (file)
@@ -7,6 +7,7 @@
 package com.marcozanon.macaco.attic.web.ui;
 
 import com.marcozanon.macaco.MObject;
+import com.marcozanon.macaco.text.MText;
 
 public class MWebFont extends MObject {
 
@@ -92,7 +93,7 @@ public class MWebFont extends MObject {
         if (null == size) {
             throw new IllegalArgumentException("Invalid 'size': null.");
         }
-        if ((null == family) || ("".equals(family))) {
+        if (MText.isBlank(family)) {
             throw new IllegalArgumentException("Invalid 'family': null or empty.");
         }
         if (null == decoration) {
index a43182a1d6f80a1dcfbe086bb2c70c74cf272c3b..fd8ccc52a1ad99580a6cb1fece9f9862ac67ca53 100644 (file)
@@ -10,6 +10,7 @@ import com.marcozanon.macaco.MObject;
 import com.marcozanon.macaco.json.MInvalidValueJsonException;
 import com.marcozanon.macaco.json.MJsonObject;
 import com.marcozanon.macaco.json.MJsonString;
+import com.marcozanon.macaco.text.MText;
 import java.util.LinkedHashMap;
 
 public class MWebMessage extends MObject {
@@ -23,7 +24,7 @@ public class MWebMessage extends MObject {
     public MWebMessage(String message) throws MMessagingWebException {
         super();
         //
-        if ((null == message) || "".equals(message)) {
+        if (MText.isBlank(message)) {
             throw new IllegalArgumentException("Invalid 'message': null or empty.");
         }
         //
@@ -50,7 +51,7 @@ public class MWebMessage extends MObject {
         }
         try {
             String temporaryEvent = ((MJsonString)jsonMessage.getValue("event")).getValue();
-            if ("".equals(temporaryEvent)) {
+            if (MText.isEmpty(temporaryEvent)) {
                 throw new MMessagingWebException("Invalid 'message': event empty.");
             }
             this.event = temporaryEvent;
index 22a949db957afdf689c6b4579f03bb6d79a8b51c..917fc03731feb42d72a3d02ebca81227e24f2a17 100644 (file)
@@ -63,7 +63,7 @@ public class MWebNumberBox extends MWebTextBox {
     public BigDecimal getNumber() throws MFormatConversionException {
         BigDecimal number = null;
         String text = this.getText();
-        if (!"".equals(text)) {
+        if (!MText.isEmpty(text)) {
             return this.getNumberConverterReference().getNumberFromString(text);
         }
         return number;
@@ -73,7 +73,7 @@ public class MWebNumberBox extends MWebTextBox {
 
     public void validate() throws MValidationWebException {
         String text = this.getText();
-        if (!"".equals(text)) {
+        if (!MText.isEmpty(text)) {
             try {
                 MNumberConverter numberConverter = this.getNumberConverterReference();
                 this.setText(numberConverter.getStringFromNumber(numberConverter.getNumberFromString(text)));
index f5eaed85c44bc86f7950865c7e4a3fab69017127..2332d943fd64e59c07a97ac95144f902e6f08045 100644 (file)
@@ -40,7 +40,7 @@ public abstract class MWebTable extends MWebDirectWidget {
         }
         else {
             for (String columnKey: columnHeaders.keySet()) {
-                if ((null == columnKey) || ("".equals(columnKey))) {
+                if (MText.isBlank(columnKey)) {
                     throw new IllegalArgumentException("Invalid 'columnHeaders': column key null or empty.");
                 }
                 else if (null == columnHeaders.get(columnKey)) {
@@ -48,7 +48,7 @@ public abstract class MWebTable extends MWebDirectWidget {
                 }
             }
         }
-        if ((null == primaryKey) || ("".equals(primaryKey))) {
+        if (MText.isBlank(primaryKey)) {
             throw new IllegalArgumentException("Invalid 'primaryKey': null or empty.");
         }
         //
@@ -92,7 +92,7 @@ public abstract class MWebTable extends MWebDirectWidget {
     }
 
     protected void setSortKey(String sortKey, boolean ascendingSortMode, boolean refreshMode) {
-        if ("".equals(sortKey)) {
+        if (MText.isEmpty(sortKey)) {
             throw new IllegalArgumentException("Invalid 'sortKey': empty.");
         }
         //
@@ -234,7 +234,7 @@ public abstract class MWebTable extends MWebDirectWidget {
                     throw new IllegalArgumentException("Invalid 'rows': row null.");
                 }
                 for (String columnKey: row.keySet()) {
-                    if ((null == columnKey) || ("".equals(columnKey))) {
+                    if (MText.isBlank(columnKey)) {
                         throw new IllegalArgumentException("Invalid 'rows': column key null or empty.");
                     }
                 }
@@ -397,7 +397,7 @@ public abstract class MWebTable extends MWebDirectWidget {
     }
 
     protected void setRowSelectedMode(String primaryKeyValue, boolean selectedMode, boolean refreshMode) {
-        if ((null == primaryKeyValue) || ("".equals(primaryKeyValue))) {
+        if (MText.isBlank(primaryKeyValue)) {
             throw new IllegalArgumentException("Invalid 'primaryKeyValue': null or empty.");
         }
         //
@@ -426,7 +426,7 @@ public abstract class MWebTable extends MWebDirectWidget {
     }
 
     public boolean getRowSelectedMode(String primaryKeyValue) {
-        if ((null == primaryKeyValue) || ("".equals(primaryKeyValue))) {
+        if (MText.isBlank(primaryKeyValue)) {
             throw new IllegalArgumentException("Invalid 'primaryKeyValue': null or empty.");
         }
         //
@@ -537,7 +537,7 @@ public abstract class MWebTable extends MWebDirectWidget {
         }
         for (String columnKey: columnHeaders.keySet()) {
             String onSortFunction = "";
-            if (!"".equals(columnHeaders.get(columnKey).getText())) {
+            if (!MText.isEmpty(columnHeaders.get(columnKey).getText())) {
                 onSortFunction = String.format("javascript: m_messageInterface.fireMessage('%s', 'onSort', {'sortKey': '%s'});", this.getId(), MText.getJavascriptEscapedString(columnKey));
             }
             content.append(String.format("<th class=\"MWebTableColumnHeaderCell %s\" onclick=\"%s\" id=\"%s\"></th>", customClasses, MText.getXhtmlEscapedString(onSortFunction), columnHeaders.get(columnKey).getId()));
@@ -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 ((!"".equals(selectedPage)) && ((Integer.parseInt(selectedPage) < 1) || (Integer.parseInt(selectedPage) > (int)Math.ceil((float)this.getRowCount() / (float)this.getRowsPerPage())))) {
+            else if ((!MText.isEmpty(selectedPage)) && ((Integer.parseInt(selectedPage) < 1) || (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);
@@ -709,7 +709,7 @@ public abstract class MWebTable extends MWebDirectWidget {
     }
 
     public void onPageSelection(String selectedPage) {
-        if ("".equals(selectedPage)) {
+        if (MText.isEmpty(selectedPage)) {
             this.setSelectedPage(null);
         }
         else {
index b628c8a0fc3b246499e4a1d136e273167770502d..73e70f09468abd492922d3570f893bb83cfeb2a7 100644 (file)
@@ -102,7 +102,7 @@ public class MWebTableCell extends MWebCellWidget {
     }
 
     protected void setExternalLinkPrefix(String externalLinkPrefix, boolean refreshMode) {
-        if ("".equals(externalLinkPrefix)) {
+        if (MText.isEmpty(externalLinkPrefix)) {
             throw new IllegalArgumentException("Invalid 'externalLinkPrefix': empty.");
         }
         //
index a83abb7595f76c8ec4ec9897480d08c7597c8cc6..17a7e30dba2f5a059aa90d821f3138b6d87947ff 100644 (file)
@@ -81,7 +81,7 @@ public class MWebVerticalMenu extends MWebDirectWidget {
         }
         else {
             for (String k: items.keySet()) {
-                if ((null == k) || ("".equals(k))) {
+                if (MText.isBlank(k)) {
                     throw new IllegalArgumentException("Invalid 'items': item key null or empty.");
                 }
                 else if (null == items.get(k)) {
@@ -136,7 +136,7 @@ public class MWebVerticalMenu extends MWebDirectWidget {
     }
 
     protected void setSelectedItem(String selectedItemKey, boolean refreshMode) {
-        if ("".equals(selectedItemKey)) {
+        if (MText.isEmpty(selectedItemKey)) {
             throw new IllegalArgumentException("Invalid 'selectedItemKey': empty.");
         }
         else if ((null != selectedItemKey) && (!this.getItemsReference().containsKey(selectedItemKey))) {
@@ -169,7 +169,7 @@ public class MWebVerticalMenu extends MWebDirectWidget {
     /* Refresh */
 
     protected String getItemContent(String parentItemKey) throws MNoWidgetIdWebException { // code partly taken from http://www.codecodex.com/wiki/Count_the_number_of_occurrences_of_a_specific_character_in_a_string
-        if ("".equals(parentItemKey)) {
+        if (MText.isEmpty(parentItemKey)) {
             throw new IllegalArgumentException("Invalid 'parentItemKey': empty.");
         }
         //
@@ -199,7 +199,7 @@ public class MWebVerticalMenu extends MWebDirectWidget {
             }
             itemContent.append(String.format("<tr class=\"MWebVerticalMenuRow %s\">", customClasses));
             String text = this.getItemsReference().get(itemKey).getText();
-            if (!"".equals(text)) {
+            if (!MText.isEmpty(text)) {
                 String imageSource = this.getItemsReference().get(itemKey).getImageSource();
                 if (null == imageSource) {
                     imageSource = String.format("%s/null", this.getApplicationContextReference().getRequestReference().getRequestURL());
@@ -221,7 +221,7 @@ public class MWebVerticalMenu extends MWebDirectWidget {
             //
             if ((!this.getAccordionMode()) || (this.getAccordionMode() && (null != this.getSelectedItemKey()) && (this.getSelectedItemKey().startsWith(itemKey)))) {
                 String childItemContent = this.getItemContent(itemKey);
-                if (!"".equals(childItemContent.toString())) {
+                if (!MText.isEmpty(childItemContent.toString())) {
                     itemContent.append(String.format("<tr class=\"MWebVerticalMenuRow %s\">", customClasses));
                     itemContent.append(String.format("<td class=\"MWebVerticalMenuImageCell\" />", customClasses));
                     itemContent.append(String.format("<td class=\"MWebVerticalMenuChildTableCell %s\" id=\"%s\">%s</td>", customClasses, this.getId() + MText.getXhtmlEscapedString(itemKey) + "-childCell", childItemContent));
@@ -231,8 +231,8 @@ public class MWebVerticalMenu extends MWebDirectWidget {
         }
         //
         StringBuilder content = new StringBuilder("");
-        if (!"".equals(itemContent.toString())) {
-            if ("".equals(parentItemKey)) {
+        if (!MText.isEmpty(itemContent.toString())) {
+            if (MText.isEmpty(parentItemKey)) {
                 content.append(String.format("<table class=\"MWebVerticalMenuTable %s\" style=\"display: inline-table;\" id=\"%s\">", customClasses, this.getId()));
             }
             else {
@@ -248,7 +248,7 @@ public class MWebVerticalMenu extends MWebDirectWidget {
         this.checkPresence();
         //
         String content = this.getItemContent(null);
-        if ("".equals(content)) {
+        if (MText.isEmpty(content)) {
             content = String.format("<div id=\"%s\"></div>", this.getId());
         }
         this.getApplicationContextReference().addPlainTextResponseContent(String.format("if ($('%s')) { $('%s').parentNode.innerHTML = '%s'; }", this.getId(), this.getId(), MText.getJavascriptEscapedString(content)));
index 76c7d4f24550016b1019e0956ed9a70bdc14e13e..db18708aa10ef29db95f5c511483fd488dac7b57 100644 (file)
@@ -35,7 +35,7 @@ public class MWebView extends MObject implements Runnable {
         if (null == applicationContext) {
             throw new IllegalArgumentException("Invalid 'applicationContext': null.");
         }
-        if ((null == breadcrumb) || ("".equals(breadcrumb))) {
+        if (MText.isBlank(breadcrumb)) {
             throw new IllegalArgumentException("Invalid 'breadcrumb': null or empty.");
         }
         //
@@ -202,7 +202,7 @@ public class MWebView extends MObject implements Runnable {
     }
 
     public MWebDownloader getDownloaderReferenceById(String id) throws MDownloaderNotFoundWebException {
-        if ((null == id) || ("".equals(id))) {
+        if (MText.isBlank(id)) {
             throw new IllegalArgumentException("Invalid 'id': null or empty.");
         }
         //
@@ -381,7 +381,7 @@ public class MWebView extends MObject implements Runnable {
         String widgetId = message.getWidgetId();
         String event = message.getEvent();
         LinkedHashMap<String, String> parameters = message.getParameters();
-        if ("".equals(widgetId)) { // no widget id = view
+        if (MText.isEmpty(widgetId)) { // no widget id = view
             if ("onRefresh".equals(event)) {
                 this.onRefresh();
             }
index 80f593307ecabe568a04f9856da1e4af2efa994a..2dcb690f9f5d3bed8062ffec3654ebdcdf29f4be 100644 (file)
@@ -7,6 +7,7 @@
 package com.marcozanon.macaco.attic.web.ui;
 
 import com.marcozanon.macaco.MObject;
+import com.marcozanon.macaco.text.MText;
 import java.util.LinkedHashMap;
 
 public abstract class MWebWidget extends MObject {
@@ -77,7 +78,7 @@ public abstract class MWebWidget extends MObject {
     /* Messages */
 
     protected void processMessage(String event, LinkedHashMap<String, String> parameters) throws MUnexpectedMessageWebException {
-        if ((null == event) || ("".equals(event))) {
+        if (MText.isBlank(event)) {
             throw new IllegalArgumentException("Invalid 'event': null or empty.");
         }
         if (null == parameters) {
index 65da9ecda371b6b81907d54ca708b5ab61d0886f..b85cabf8925dab2b74c8884c59a22b74adb145ec 100644 (file)
@@ -7,6 +7,7 @@
 package com.marcozanon.macaco.conversion;
 
 import com.marcozanon.macaco.MObject;
+import com.marcozanon.macaco.text.MText;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -130,7 +131,7 @@ public class MDateConverter extends MObject {
     /* Conversion */
 
     protected static void checkDateFormat(String dateFormat) {
-        if ((null == dateFormat) || ("".equals(dateFormat))) {
+        if (MText.isBlank(dateFormat)) {
             throw new IllegalArgumentException("Invalid 'dateFormat': null or empty.");
         }
         //
@@ -143,7 +144,7 @@ public class MDateConverter extends MObject {
     }
 
     protected static Date getDateFromStringByParameters(String x, String inputDateFormat, Locale inputLocale, TimeZone inputTimeZone) throws MFormatConversionException {
-        if ((null == x) || ("".equals(x))) {
+        if (MText.isBlank(x)) {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         MDateConverter.checkDateFormat(inputDateFormat);
index a152da199a49879f5d7575d297e9b3c1380fcad9..6b61ce62809d9d5cdb09ecef48c43f0d7275a32e 100644 (file)
@@ -7,6 +7,7 @@
 package com.marcozanon.macaco.conversion;
 
 import com.marcozanon.macaco.MObject;
+import com.marcozanon.macaco.text.MText;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
@@ -104,7 +105,7 @@ public class MNumberConverter extends MObject {
     /* Conversion */
 
     protected static void checkNumberFormat(String numberFormat) {
-        if ((null == numberFormat) || ("".equals(numberFormat))) {
+        if (MText.isBlank(numberFormat)) {
             throw new IllegalArgumentException("Invalid 'numberFormat': null or empty.");
         }
         //
@@ -117,7 +118,7 @@ public class MNumberConverter extends MObject {
     }
 
     protected static BigDecimal getNumberFromStringByParameters(String x, String inputNumberFormat, Locale inputLocale) throws MFormatConversionException {
-        if ((null == x) || ("".equals(x))) {
+        if (MText.isBlank(x)) {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         MNumberConverter.checkNumberFormat(inputNumberFormat);
index b6db40d1426b6a5502566d19561b9beb4a329420..ca288fbda849005e8c211a49e01a0cefc370869d 100644 (file)
@@ -6,6 +6,8 @@
 
 package com.marcozanon.macaco.json;
 
+import com.marcozanon.macaco.text.MText;
+
 public class MJsonBoolean extends MJsonValue {
 
     protected Boolean value = null;
@@ -63,7 +65,7 @@ public class MJsonBoolean extends MJsonValue {
     }
 
     public void parseString(String x) throws MInvalidValueJsonException {
-        if ((null == x) || ("".equals(x))) {
+        if (MText.isBlank(x)) {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
index a8bc959ccc926da3c56a0843bfd45aee9e2a9df2..af6d5498acf8951e2b0f9560b4ffc345680c9ce7 100644 (file)
@@ -6,6 +6,8 @@
 
 package com.marcozanon.macaco.json;
 
+import com.marcozanon.macaco.text.MText;
+
 public class MJsonNull extends MJsonValue {
 
     /* */
@@ -44,7 +46,7 @@ public class MJsonNull extends MJsonValue {
     }
 
     public void parseString(String x) throws MInvalidValueJsonException {
-        if ((null == x) || ("".equals(x))) {
+        if (MText.isBlank(x)) {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
index b8c468265ba074b21057b647cdd1ebc3d0b5eb32..886e8545f6bb8ae64a58e1eaacba777cd3153891 100644 (file)
@@ -6,6 +6,7 @@
 
 package com.marcozanon.macaco.json;
 
+import com.marcozanon.macaco.text.MText;
 import java.math.BigDecimal;
 
 public class MJsonNumber extends MJsonValue {
@@ -84,7 +85,7 @@ public class MJsonNumber extends MJsonValue {
     }
 
     public void parseString(String x) throws MInvalidValueJsonException {
-        if ((null == x) || ("".equals(x))) {
+        if (MText.isBlank(x)) {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
index 3e5fa56fc482d4335cb4b4610655f9202f06a150..29e9830d8ce26c5c141de06e1826b2c2c482d289 100644 (file)
@@ -6,6 +6,7 @@
 
 package com.marcozanon.macaco.json;
 
+import com.marcozanon.macaco.text.MText;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 
@@ -47,7 +48,7 @@ public class MJsonObject extends MJsonValue {
     /* Values handlers */
 
     public void setValue(String key, MJsonValue x) {
-        if ((null == key) || ("".equals(key))) {
+        if (MText.isBlank(key)) {
             throw new IllegalArgumentException("Invalid 'key': null or empty.");
         }
         if (null == x) {
@@ -62,7 +63,7 @@ public class MJsonObject extends MJsonValue {
     }
 
     public MJsonValue getValue(String key) {
-        if ((null == key) || ("".equals(key))) {
+        if (MText.isBlank(key)) {
             throw new IllegalArgumentException("Invalid 'key': null or empty.");
         }
         //
@@ -77,7 +78,7 @@ public class MJsonObject extends MJsonValue {
     }
 
     public void removeValue(String key) {
-        if ((null == key) || ("".equals(key))) {
+        if (MText.isBlank(key)) {
             throw new IllegalArgumentException("Invalid 'key': null or empty.");
         }
         //
@@ -92,7 +93,7 @@ public class MJsonObject extends MJsonValue {
     }
 
     public boolean containsKey(String key) {
-        if ((null == key) || ("".equals(key))) {
+        if (MText.isBlank(key)) {
             throw new IllegalArgumentException("Invalid 'key': null or empty.");
         }
         //
index 5662a74d1cedee9fda8ad3f1275e8f9186abddcc..af913a060dc91da0d587279babb9a4f4381ef4e8 100644 (file)
@@ -6,6 +6,8 @@
 
 package com.marcozanon.macaco.json;
 
+import com.marcozanon.macaco.text.MText;
+
 public class MJsonString extends MJsonValue {
 
     protected boolean extendedEscapeMode = false;
@@ -267,7 +269,7 @@ public class MJsonString extends MJsonValue {
     }
 
     public void parseString(String x) throws MInvalidValueJsonException {
-        if ((null == x) || ("".equals(x))) {
+        if (MText.isBlank(x)) {
             throw new IllegalArgumentException("Invalid 'x': null or empty.");
         }
         //
index ad795f744d3c9588c30ca3dacd65236118281fe1..a5c0d0e99916224241b4a24478bd4665070e6a7a 100644 (file)
@@ -7,6 +7,7 @@
 package com.marcozanon.macaco.logging;
 
 import com.marcozanon.macaco.MInformation;
+import com.marcozanon.macaco.text.MText;
 import java.io.BufferedWriter;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -27,7 +28,7 @@ public class MLogPlainTextFile extends MLogTarget {
     public MLogPlainTextFile(String file) throws MLoggingException {
         super();
         //
-        if ((null == file) || ("".equals(file))) {
+        if (MText.isBlank(file)) {
             throw new IllegalArgumentException("Invalid 'file': null or empty.");
         }
         //
index d6eff4b81eec90f5eb5b462d262cb89d51eee6d9..bdcf5309056411b3092cee614f5285829f3bb6b9 100644 (file)
@@ -7,6 +7,7 @@
 package com.marcozanon.macaco.sql;
 
 import com.marcozanon.macaco.MObject;
+import com.marcozanon.macaco.text.MText;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
@@ -35,10 +36,10 @@ public class MSqlConnection extends MObject {
     public MSqlConnection(String driver, String url, String username, String password) throws MConnectionSqlException {
         super();
         //
-        if ((null == driver) || ("".equals(driver))) {
+        if (MText.isBlank(driver)) {
             throw new IllegalArgumentException("Invalid 'driver': null or empty.");
         }
-        if ((null == url) || ("".equals(url))) {
+        if (MText.isBlank(url)) {
             throw new IllegalArgumentException("Invalid 'url': null or empty.");
         }
         if (null == username) {
@@ -199,7 +200,7 @@ public class MSqlConnection extends MObject {
     }
 
     public MSqlStatementResults executePreparedStatement(String statement, LinkedList<Object> parameters) throws MStatementSqlException {
-        if ((null == statement) || ("".equals(statement))) {
+        if (MText.isBlank(statement)) {
             throw new IllegalArgumentException("Invalid 'statement': null or empty.");
         }
         if (null == parameters) {
index d8676e615353c83a97f6e849a8c5bd9cfdd08bf1..ce9dbd04b4d396c7c762b1c67c8f59b046e5728c 100644 (file)
@@ -7,6 +7,7 @@
 package com.marcozanon.macaco.sql;
 
 import com.marcozanon.macaco.MObject;
+import com.marcozanon.macaco.text.MText;
 
 public class MSqlConnectionGenerator extends MObject {
 
@@ -20,10 +21,10 @@ public class MSqlConnectionGenerator extends MObject {
     public MSqlConnectionGenerator(String driver, String url, String username, String password) {
         super();
         //
-        if ((null == driver) || ("".equals(driver))) {
+        if (MText.isBlank(driver)) {
             throw new IllegalArgumentException("Invalid 'driver': null or empty.");
         }
-        if ((null == url) || ("".equals(url))) {
+        if (MText.isBlank(url)) {
             throw new IllegalArgumentException("Invalid 'url': null or empty.");
         }
         if (null == username) {
index a013eb9c61fd34a4db7cb342e988bc4988b71ac9..fb085a8903b7695420b87978f7eceafb70fd9bea 100644 (file)
@@ -7,6 +7,7 @@
 package com.marcozanon.macaco.sql;
 
 import com.marcozanon.macaco.MObject;
+import com.marcozanon.macaco.text.MText;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
@@ -115,7 +116,7 @@ public class MSqlStatementResults extends MObject {
     }
 
     public LinkedList<Object> getRecordsByField(String field) {
-        if ((null == field) || ("".equals(field))) {
+        if (MText.isBlank(field)) {
             throw new IllegalArgumentException("Invalid 'field': null or empty.");
         }
         //
index 64914abb17e9d8cbda1f6d3ca8fc2c5f7021fbee..f7bfd149f939cb72a5a5b71d0a48486fa30a0369 100644 (file)
@@ -7,6 +7,7 @@
 package com.marcozanon.macaco.sql;
 
 import com.marcozanon.macaco.MObject;
+import com.marcozanon.macaco.text.MText;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 
@@ -24,10 +25,10 @@ public class MSqlTable extends MObject {
         if (null == connection) {
             throw new IllegalArgumentException("Invalid 'connection': null.");
         }
-        if ((null == table) || ("".equals(table))) {
+        if (MText.isBlank(table)) {
             throw new IllegalArgumentException("Invalid 'table': null or empty.");
         }
-        if ((null == primaryKey) || ("".equals(primaryKey))) {
+        if (MText.isBlank(primaryKey)) {
             throw new IllegalArgumentException("Invalid 'primaryKey': null or empty.");
         }
         //
index 06ee12a44e113097a254db7a5ada6d1b8d10b026..24f6330e098d2cc7afec37957b0cb270b5b09d2c 100644 (file)
@@ -49,7 +49,7 @@ public class MTranslator extends MObject {
     }
 
     public void parseFile(String file) throws MTranslationFileParsingTextException {
-        if ((null == file) || ("".equals(file))) {
+        if (MText.isBlank(file)) {
             throw new IllegalArgumentException("Invalid 'file': null or empty.");
         }
         //
@@ -76,7 +76,7 @@ public class MTranslator extends MObject {
                     break;
                 }
                 line = line.trim();
-                if ("".equals(line)) {
+                if (MText.isEmpty(line)) {
                     message = null;
                     continue;
                 }
@@ -130,7 +130,7 @@ public class MTranslator extends MObject {
     }
 
     protected String getTranslation(String message, Locale locale, boolean strictMode) throws MTranslationValueNotFoundTextException {
-        if ((null == message) || ("".equals(message))) {
+        if (MText.isBlank(message)) {
             throw new IllegalArgumentException("Invalid 'message': null or empty.");
         }
         if (null == locale) {