This commit is contained in:
Henry Jen 2018-12-13 11:51:06 -08:00
commit def1ac3acc
200 changed files with 1089 additions and 616 deletions

View file

@ -76,7 +76,7 @@ public class TransferProtocolClient extends NetworkClient {
System.out.print(response);
}
if (response.length() == 0) {
if (response.isEmpty()) {
code = -1;
} else {
try {

View file

@ -433,7 +433,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
logger.finest("Server [" + serverAddr + "] --> " + response);
}
if (response.length() == 0) {
if (response.isEmpty()) {
code = -1;
} else {
try {
@ -1049,7 +1049,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
if (!isConnected()) {
throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE);
}
if (user == null || user.length() == 0) {
if (user == null || user.isEmpty()) {
throw new IllegalArgumentException("User name can't be null or empty");
}
tryLogin(user, password);
@ -1088,7 +1088,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
if (!isConnected()) {
throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE);
}
if (user == null || user.length() == 0) {
if (user == null || user.isEmpty()) {
throw new IllegalArgumentException("User name can't be null or empty");
}
tryLogin(user, password);
@ -1152,7 +1152,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
* @exception <code>FtpProtocolException</code>
*/
public sun.net.ftp.FtpClient changeDirectory(String remoteDirectory) throws sun.net.ftp.FtpProtocolException, IOException {
if (remoteDirectory == null || "".equals(remoteDirectory)) {
if (remoteDirectory == null || remoteDirectory.isEmpty()) {
throw new IllegalArgumentException("directory can't be null or empty");
}
@ -1738,7 +1738,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
* @throws IOException if an error occurs during the transmission.
*/
public long getSize(String path) throws sun.net.ftp.FtpProtocolException, IOException {
if (path == null || path.length() == 0) {
if (path == null || path.isEmpty()) {
throw new IllegalArgumentException("path can't be null or empty");
}
issueCommandCheck("SIZE " + path);

View file

@ -238,7 +238,7 @@ public class DefaultProxySelector extends ProxySelector {
if (phost != null && phost.length() != 0)
break;
}
if (phost == null || phost.length() == 0) {
if (phost == null || phost.isEmpty()) {
/**
* No system property defined for that
* protocol. Let's check System Proxy
@ -267,7 +267,7 @@ public class DefaultProxySelector extends ProxySelector {
nprop.hostsSource = null;
nprop.pattern = null;
}
} else if (nphosts.length() != 0) {
} else if (!nphosts.isEmpty()) {
// add the required default patterns
// but only if property no set. If it
// is empty, leave empty.

View file

@ -226,7 +226,7 @@ public class HeaderParser {
for (int i=0; k.hasNext(); i++) {
String key = k.next();
String val = findValue (i);
if (val != null && "".equals (val)) {
if (val != null && val.isEmpty()) {
val = null;
}
sb.append(" {").append(key).append(val == null ? "" : "," + val)

View file

@ -201,9 +201,7 @@ public class MimeEntry implements Cloneable {
}
private boolean isStarred(String typeName) {
return (typeName != null)
&& (typeName.length() > 0)
&& (typeName.endsWith("/*"));
return typeName != null && typeName.endsWith("/*");
}
/**
@ -300,7 +298,7 @@ public class MimeEntry implements Cloneable {
}
String extensions = getExtensionsAsList();
if (extensions.length() > 0) {
if (!extensions.isEmpty()) {
sj.add("file_extensions=" + extensions);
}

View file

@ -162,7 +162,7 @@ class MimeLauncher extends Thread {
location the application. If a valid path is not found, it
returns false else true. */
private boolean findExecutablePath(String str) {
if (str == null || str.length() == 0) {
if (str == null || str.isEmpty()) {
return false;
}

View file

@ -536,8 +536,7 @@ public final class ParseUtil {
throws URISyntaxException
{
if (scheme != null) {
if ((path != null)
&& ((path.length() > 0) && (path.charAt(0) != '/')))
if (path != null && !path.isEmpty() && path.charAt(0) != '/')
throw new URISyntaxException(s,
"Relative path in absolute URI");
}

View file

@ -603,7 +603,7 @@ public class HttpClient extends NetworkClient {
StringBuilder result = new StringBuilder(128);
result.append(url.getProtocol());
result.append(":");
if (url.getAuthority() != null && url.getAuthority().length() > 0) {
if (url.getAuthority() != null && !url.getAuthority().isEmpty()) {
result.append("//");
result.append(url.getAuthority());
}
@ -619,7 +619,7 @@ public class HttpClient extends NetworkClient {
} else {
fileName = url.getFile();
if ((fileName == null) || (fileName.length() == 0)) {
if ((fileName == null) || (fileName.isEmpty())) {
fileName = "/";
} else if (fileName.charAt(0) == '?') {
/* HTTP/1.1 spec says in 5.1.2. about Request-URI:

View file

@ -341,7 +341,7 @@ public class FtpURLConnection extends URLConnection {
path.charAt(0) == '/') {
path = path.substring(1);
}
if (path == null || path.length() == 0) {
if (path == null || path.isEmpty()) {
path = "./";
}
if (!path.endsWith("/")) {
@ -555,7 +555,7 @@ public class FtpURLConnection extends URLConnection {
}
decodePath(url.getPath());
if (filename == null || filename.length() == 0) {
if (filename == null || filename.isEmpty()) {
throw new IOException("illegal filename for a PUT");
}
try {

View file

@ -248,7 +248,7 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone
this.realm = realm;
String urlPath = url.getPath();
if (urlPath.length() == 0)
if (urlPath.isEmpty())
this.path = urlPath;
else {
this.path = reducePath (urlPath);

View file

@ -279,7 +279,7 @@ class DigestAuthentication extends AuthenticationInfo {
if (s == null || !s.equals("true"))
return false;
String newNonce = p.findValue ("nonce");
if (newNonce == null || "".equals(newNonce)) {
if (newNonce == null || newNonce.isEmpty()) {
return false;
}
params.setNonce (newNonce);
@ -323,7 +323,7 @@ class DigestAuthentication extends AuthenticationInfo {
+ authMethod.substring(1).toLowerCase();
}
String algorithm = p.findValue("algorithm");
if (algorithm == null || "".equals(algorithm)) {
if (algorithm == null || algorithm.isEmpty()) {
algorithm = "MD5"; // The default, accoriding to rfc2069
}
params.setAlgorithm (algorithm);
@ -451,7 +451,7 @@ class DigestAuthentication extends AuthenticationInfo {
}
/* Check if there is a nextnonce field */
String nextnonce = p.findValue ("nextnonce");
if (nextnonce != null && ! "".equals(nextnonce)) {
if (nextnonce != null && !nextnonce.isEmpty()) {
params.setNonce (nextnonce);
}

View file

@ -3026,7 +3026,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
// Filtering only if there is a cookie handler. [Assumption: the
// cookie handler will store/retrieve the HttpOnly cookies]
if (cookieHandler == null || value.length() == 0)
if (cookieHandler == null || value.isEmpty())
return value;
JavaNetHttpCookieAccess access =

View file

@ -143,7 +143,7 @@ final class HttpsClient extends HttpClient
String cipherString =
GetPropertyAction.privilegedGetProperty("https.cipherSuites");
if (cipherString == null || "".equals(cipherString)) {
if (cipherString == null || cipherString.isEmpty()) {
ciphers = null;
} else {
StringTokenizer tokenizer;
@ -167,7 +167,7 @@ final class HttpsClient extends HttpClient
String protocolString =
GetPropertyAction.privilegedGetProperty("https.protocols");
if (protocolString == null || "".equals(protocolString)) {
if (protocolString == null || protocolString.isEmpty()) {
protocols = null;
} else {
StringTokenizer tokenizer;
@ -187,7 +187,7 @@ final class HttpsClient extends HttpClient
private String getUserAgent() {
String userAgent =
GetPropertyAction.privilegedGetProperty("https.agent");
if (userAgent == null || userAgent.length() == 0) {
if (userAgent == null || userAgent.isEmpty()) {
userAgent = "JSSE";
}
return userAgent;

View file

@ -66,7 +66,7 @@ public class JavaRuntimeURLConnection extends URLConnection {
JavaRuntimeURLConnection(URL url) throws IOException {
super(url);
String path = url.getPath();
if (path.length() == 0 || path.charAt(0) != '/')
if (path.isEmpty() || path.charAt(0) != '/')
throw new MalformedURLException(url + " missing path or /");
if (path.length() == 1) {
this.module = null;