From 3bad6898fc21324d2fc7a5a49b41de7ff362c241 Mon Sep 17 00:00:00 2001 From: Dirk Stenger Date: Thu, 4 Jan 2024 14:38:56 +0100 Subject: [PATCH] #591 - Use String.isEmpty() --- .../src/main/java/com/occamlab/te/TECore.java | 12 ++++++------ .../main/java/com/occamlab/te/parsers/ZipParser.java | 4 ++-- .../src/main/java/com/occamlab/te/util/LogUtils.java | 2 +- .../com/occamlab/te/spi/util/TEStatisticsUtil.java | 2 +- .../main/java/com/occamlab/te/web/TestServlet.java | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/teamengine-core/src/main/java/com/occamlab/te/TECore.java b/teamengine-core/src/main/java/com/occamlab/te/TECore.java index 946e86d5..e31bc09a 100644 --- a/teamengine-core/src/main/java/com/occamlab/te/TECore.java +++ b/teamengine-core/src/main/java/com/occamlab/te/TECore.java @@ -1598,7 +1598,7 @@ public NodeList soap_request(Document ctlRequest, String id) static public URLConnection build_soap_request(Node xml) throws Exception { String sUrl = null; String method = "POST"; - String charset = ((Element) xml).getAttribute("charset").equals("") ? ((Element) xml) + String charset = ((Element) xml).getAttribute("charset").isEmpty() ? ((Element) xml) .getAttribute("charset") : "UTF-8"; String version = ((Element) xml).getAttribute("version"); String action = ""; @@ -1654,7 +1654,7 @@ static public URLConnection build_soap_request(Node xml) throws Exception { uc.setRequestProperty("Accept", "text/xml"); uc.setRequestProperty("SOAPAction", action); contentType = "text/xml"; - if (!charset.equals("")) { + if (!charset.isEmpty()) { contentType = contentType + "; charset=" + charset; } uc.setRequestProperty("Content-Type", contentType); @@ -1662,10 +1662,10 @@ static public URLConnection build_soap_request(Node xml) throws Exception { // Handle HTTP binding for SOAP 1.2 uc.setRequestProperty("Accept", "application/soap+xml"); contentType = "application/soap+xml"; - if (!charset.equals("")) { + if (!charset.isEmpty()) { contentType = contentType + "; charset=" + charset; } - if (!action.equals("")) { + if (!action.isEmpty()) { contentType = contentType + "; action=" + action; } uc.setRequestProperty("Content-Type", contentType); @@ -1946,7 +1946,7 @@ public URLConnection build_request(Node xml) throws Exception { if (contentType.equals("application/xml")) { contentType = "application/xml; charset=" + charset; } - if (contentType == null || contentType.equals("")) { + if (contentType == null || contentType.isEmpty()) { contentType = "application/octet-stream"; } @@ -2015,7 +2015,7 @@ public URLConnection build_request(Node xml) throws Exception { // Set headers if (body != null) { String mid = ((Element) body).getAttribute("mid"); - if (mid != null && !mid.equals("")) { + if (mid != null && !mid.isEmpty()) { if (mid.indexOf("mid:") != -1) { mid = mid.substring(mid.indexOf("mid:") + "mid:".length()); diff --git a/teamengine-core/src/main/java/com/occamlab/te/parsers/ZipParser.java b/teamengine-core/src/main/java/com/occamlab/te/parsers/ZipParser.java index adb1bb0a..e8999041 100644 --- a/teamengine-core/src/main/java/com/occamlab/te/parsers/ZipParser.java +++ b/teamengine-core/src/main/java/com/occamlab/te/parsers/ZipParser.java @@ -11,7 +11,7 @@ */ package com.occamlab.te.parsers; -import java.io.*; +import java.io.*; import java.net.URLConnection; import java.util.logging.Level; @@ -73,7 +73,7 @@ public static String getMediaType(String ext) { } // Give the media type default of "application/octet-stream" - if (mediaType.equals("")) { + if (mediaType.isEmpty()) { mediaType = "application/octet-stream"; } diff --git a/teamengine-core/src/main/java/com/occamlab/te/util/LogUtils.java b/teamengine-core/src/main/java/com/occamlab/te/util/LogUtils.java index 3d69313c..732a5d37 100644 --- a/teamengine-core/src/main/java/com/occamlab/te/util/LogUtils.java +++ b/teamengine-core/src/main/java/com/occamlab/te/util/LogUtils.java @@ -203,7 +203,7 @@ public static String stripNonValidXMLCharacters(String in) { StringBuffer out = new StringBuffer(); char current; - if (in == null || ("".equals(in))) + if (in == null || (in.isEmpty())) return ""; for (int i = 0; i < in.length(); i++) { current = in.charAt(i); diff --git a/teamengine-spi/src/main/java/com/occamlab/te/spi/util/TEStatisticsUtil.java b/teamengine-spi/src/main/java/com/occamlab/te/spi/util/TEStatisticsUtil.java index 9d459463..7297359a 100644 --- a/teamengine-spi/src/main/java/com/occamlab/te/spi/util/TEStatisticsUtil.java +++ b/teamengine-spi/src/main/java/com/occamlab/te/spi/util/TEStatisticsUtil.java @@ -155,7 +155,7 @@ public static Integer getSessionResult(File logFile) { } else { Element resultStatus = (Element) testResult.item(0); - if (resultStatus.hasAttribute("result") && !resultStatus.getAttribute("result").equals("")) { + if (resultStatus.hasAttribute("result") && !resultStatus.getAttribute("result").isEmpty()) { return Integer.parseInt(resultStatus.getAttribute("result")); } else { throw new RuntimeException("The 'result' attribute not found or having the NULL value in log file."); diff --git a/teamengine-web/src/main/java/com/occamlab/te/web/TestServlet.java b/teamengine-web/src/main/java/com/occamlab/te/web/TestServlet.java index a3eda335..45bfbcfd 100644 --- a/teamengine-web/src/main/java/com/occamlab/te/web/TestServlet.java +++ b/teamengine-web/src/main/java/com/occamlab/te/web/TestServlet.java @@ -431,7 +431,7 @@ public void process(HttpServletRequest request, HttpServletResponse response) Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); - if (!item.isFormField() && !item.getName().equals("")) { + if (!item.isFormField() && !item.getName().isEmpty()) { File tempDir = new File(URI.create(core .getTestRunDirectory())); File uploadedFile = new File(tempDir,