8214971: Replace use of string.equals("") with isEmpty()

Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad
This commit is contained in:
Roger Riggs 2018-12-07 11:51:17 -05:00
parent df5b42f33b
commit 938b844088
95 changed files with 195 additions and 195 deletions

View File

@ -1366,7 +1366,7 @@ class ConstantPool {
}
if (tag == CONSTANT_Utf8) {
// Special case: First Utf8 must always be empty string.
assert(cpMap.length == 0 || cpMap[0].stringValue().equals(""));
assert(cpMap.length == 0 || cpMap[0].stringValue().isEmpty());
}
indexByTag[tag] = ix;
// decache indexes derived from this one:

View File

@ -208,7 +208,7 @@ class Driver {
}
}
if (logFile != null && !logFile.equals("")) {
if (logFile != null && !logFile.isEmpty()) {
if (logFile.equals("-")) {
System.setErr(System.out);
} else {
@ -246,7 +246,7 @@ class Driver {
}
newfile = packfile;
// The optional second argument is the source JAR file.
if (jarfile.equals("")) {
if (jarfile.isEmpty()) {
// If only one file is given, it is the only JAR.
// It serves as both input and output.
jarfile = newfile;
@ -352,7 +352,7 @@ class Driver {
if (Utils.isGZIPMagic(Utils.readMagic(inBuf))) {
in = new GZIPInputStream(in);
}
String outfile = newfile.equals("")? jarfile: newfile;
String outfile = newfile.isEmpty()? jarfile: newfile;
OutputStream fileOut;
if (outfile.equals("-"))
fileOut = System.out;
@ -366,7 +366,7 @@ class Driver {
// At this point, we have a good jarfile (or newfile, if -r)
}
if (!bakfile.equals("")) {
if (!bakfile.isEmpty()) {
// On success, abort jarfile recovery bracket.
new File(bakfile).delete();
bakfile = "";
@ -374,13 +374,13 @@ class Driver {
} finally {
// Close jarfile recovery bracket.
if (!bakfile.equals("")) {
if (!bakfile.isEmpty()) {
File jarFile = new File(jarfile);
jarFile.delete(); // Win32 requires this, see above
new File(bakfile).renameTo(jarFile);
}
// In all cases, delete temporary *.pack.
if (!tmpfile.equals(""))
if (!tmpfile.isEmpty())
new File(tmpfile).delete();
}
}

View File

@ -685,7 +685,7 @@ class Package {
return; // do not choose yet
}
String canonName = canonicalFileName();
if (file.nameString.equals("")) {
if (file.nameString.isEmpty()) {
file.nameString = canonName;
}
if (file.nameString.equals(canonName)) {
@ -706,7 +706,7 @@ class Package {
public java.io.File getFileName(java.io.File parent) {
String name = file.name.stringValue();
if (name.equals(""))
if (name.isEmpty())
name = canonicalFileName();
String fname = name.replace('/', java.io.File.separatorChar);
return new java.io.File(parent, fname);
@ -779,7 +779,7 @@ class Package {
}
public boolean isTrivialClassStub() {
return isClassStub()
&& name.stringValue().equals("")
&& name.stringValue().isEmpty()
&& (modtime == NO_MODTIME || modtime == default_modtime)
&& (options &~ FO_IS_CLASS_STUB) == 0;
}

View File

@ -646,7 +646,7 @@ class PackageWriter extends BandStructure {
return; // nothing to write
// The first element must always be the empty string.
assert(cpMap[0].stringValue().equals(""));
assert(cpMap[0].stringValue().isEmpty());
final int SUFFIX_SKIP_1 = 1;
final int PREFIX_SKIP_2 = 2;

View File

@ -237,7 +237,7 @@ public class PackerImpl extends TLGlobals implements Pack200.Packer {
final long segmentLimit;
{
long limit;
if (props.getProperty(Pack200.Packer.SEGMENT_LIMIT, "").equals(""))
if (props.getProperty(Pack200.Packer.SEGMENT_LIMIT, "").isEmpty())
limit = -1;
else
limit = props.getLong(Pack200.Packer.SEGMENT_LIMIT);

View File

@ -257,7 +257,7 @@ public class File
*/
private File(String child, File parent) {
assert parent.path != null;
assert (!parent.path.equals(""));
assert (!parent.path.isEmpty());
this.path = fs.resolve(parent.path, child);
this.prefixLength = parent.prefixLength;
}
@ -316,7 +316,7 @@ public class File
throw new NullPointerException();
}
if (parent != null) {
if (parent.equals("")) {
if (parent.isEmpty()) {
this.path = fs.resolve(fs.getDefaultParent(),
fs.normalize(child));
} else {
@ -359,7 +359,7 @@ public class File
throw new NullPointerException();
}
if (parent != null) {
if (parent.path.equals("")) {
if (parent.path.isEmpty()) {
this.path = fs.resolve(fs.getDefaultParent(),
fs.normalize(child));
} else {
@ -426,7 +426,7 @@ public class File
if (uri.getRawQuery() != null)
throw new IllegalArgumentException("URI has a query component");
String p = uri.getPath();
if (p.equals(""))
if (p.isEmpty())
throw new IllegalArgumentException("URI path component is empty");
// Okay, now initialize

View File

@ -1201,7 +1201,7 @@ public class SecurityManager {
private static String[] getPackages(String p) {
String packages[] = null;
if (p != null && !p.equals("")) {
if (p != null && !p.isEmpty()) {
java.util.StringTokenizer tok =
new java.util.StringTokenizer(p, ",");
int n = tok.countTokens();

View File

@ -970,7 +970,7 @@ public final class System {
if (key == null) {
throw new NullPointerException("key can't be null");
}
if (key.equals("")) {
if (key.isEmpty()) {
throw new IllegalArgumentException("key can't be empty");
}
}

View File

@ -174,9 +174,9 @@ public final class Parameter implements AnnotatedElement {
*/
public String getName() {
// Note: empty strings as parameter names are now outlawed.
// The .equals("") is for compatibility with current JVM
// The .isEmpty() is for compatibility with current JVM
// behavior. It may be removed at some point.
if(name == null || name.equals(""))
if(name == null || name.isEmpty())
return "arg" + index;
else
return name;

View File

@ -241,7 +241,7 @@ class HostPortrange {
int[] parsePort(String port)
{
if (port == null || port.equals("")) {
if (port == null || port.isEmpty()) {
return defaultPort();
}
@ -260,13 +260,13 @@ class HostPortrange {
String high = port.substring(dash+1);
int l,h;
if (low.equals("")) {
if (low.isEmpty()) {
l = PORT_MIN;
} else {
l = Integer.parseInt(low);
}
if (high.equals("")) {
if (high.isEmpty()) {
h = PORT_MAX;
} else {
h = Integer.parseInt(high);

View File

@ -1009,7 +1009,7 @@ class InetAddress implements java.io.Serializable {
+ " not found ");
}
if ((host == null) || (host.equals("")) || (host.equals(" "))) {
if ((host == null) || (host.isEmpty()) || (host.equals(" "))) {
throw new UnknownHostException("Requested address "
+ addrString
+ " resolves to an invalid entry in hosts file "
@ -1046,7 +1046,7 @@ class InetAddress implements java.io.Serializable {
hostEntry = removeComments(hostEntry);
if (hostEntry.contains(host)) {
addrStr = extractHostAddr(hostEntry, host);
if ((addrStr != null) && (!addrStr.equals(""))) {
if ((addrStr != null) && (!addrStr.isEmpty())) {
addr = createAddressByteArray(addrStr);
if (inetAddresses == null) {
inetAddresses = new ArrayList<>(1);

View File

@ -305,7 +305,7 @@ public final class SocketPermission extends Permission
}
private static String getHost(String host) {
if (host.equals("")) {
if (host.isEmpty()) {
return "localhost";
} else {
/* IPv6 literal address used in this context should follow
@ -344,7 +344,7 @@ public final class SocketPermission extends Permission
throws Exception
{
if (port == null || port.equals("") || port.equals("*")) {
if (port == null || port.isEmpty() || port.equals("*")) {
return new int[] {PORT_MIN, PORT_MAX};
}
@ -358,13 +358,13 @@ public final class SocketPermission extends Permission
String high = port.substring(dash+1);
int l,h;
if (low.equals("")) {
if (low.isEmpty()) {
l = PORT_MIN;
} else {
l = Integer.parseInt(low);
}
if (high.equals("")) {
if (high.isEmpty()) {
h = PORT_MAX;
} else {
h = Integer.parseInt(high);
@ -496,7 +496,7 @@ public final class SocketPermission extends Permission
throw new NullPointerException("action can't be null");
}
if (action.equals("")) {
if (action.isEmpty()) {
throw new IllegalArgumentException("action can't be empty");
}

View File

@ -533,11 +533,11 @@ public final class URLPermission extends Permission {
String thishost = this.p.hostname();
String thathost = that.p.hostname();
if (p.wildcard() && thishost.equals("")) {
if (p.wildcard() && thishost.isEmpty()) {
// this "*" implies all others
return true;
}
if (that.p.wildcard() && thathost.equals("")) {
if (that.p.wildcard() && thathost.isEmpty()) {
// that "*" can only be implied by this "*"
return false;
}

View File

@ -437,7 +437,7 @@ public abstract class URLStreamHandler {
return u.hostAddress;
String host = u.getHost();
if (host == null || host.equals("")) {
if (host == null || host.isEmpty()) {
return null;
} else {
try {

View File

@ -2226,10 +2226,10 @@ public final class Locale implements Cloneable, Serializable {
default:
return Arrays.stream(stringList).reduce("",
(s1, s2) -> {
if (s1.equals("")) {
if (s1.isEmpty()) {
return s2;
}
if (s2.equals("")) {
if (s2.isEmpty()) {
return s1;
}
return MessageFormat.format(pattern, s1, s2);
@ -3069,7 +3069,7 @@ public final class Locale implements Cloneable, Serializable {
private static boolean isSubtagIllFormed(String subtag,
boolean isFirstSubtag) {
if (subtag.equals("") || subtag.length() > 8) {
if (subtag.isEmpty() || subtag.length() > 8) {
return true;
} else if (subtag.equals("*")) {
return false;

View File

@ -704,7 +704,7 @@ public abstract class Pack200 {
if (impl == null) {
// The first time, we must decide which class to use.
implName = GetPropertyAction.privilegedGetProperty(prop,"");
if (implName != null && !implName.equals(""))
if (implName != null && !implName.isEmpty())
impl = Class.forName(implName);
else if (PACK_PROVIDER.equals(prop))
impl = com.sun.java.util.jar.pack.PackerImpl.class;

View File

@ -1290,7 +1290,7 @@ public final class Pattern
// Construct result
int resultSize = matchList.size();
if (limit == 0)
while (resultSize > 0 && matchList.get(resultSize-1).equals(""))
while (resultSize > 0 && matchList.get(resultSize-1).isEmpty())
resultSize--;
String[] result = new String[resultSize];
return matchList.subList(0, resultSize).toArray(result);

View File

@ -531,7 +531,7 @@ public class Cipher {
public static final Cipher getInstance(String transformation)
throws NoSuchAlgorithmException, NoSuchPaddingException
{
if ((transformation == null) || transformation.equals("")) {
if ((transformation == null) || transformation.isEmpty()) {
throw new NoSuchAlgorithmException("Null or empty transformation");
}
List<Transform> transforms = getTransforms(transformation);
@ -631,7 +631,7 @@ public class Cipher {
throws NoSuchAlgorithmException, NoSuchProviderException,
NoSuchPaddingException
{
if ((transformation == null) || transformation.equals("")) {
if ((transformation == null) || transformation.isEmpty()) {
throw new NoSuchAlgorithmException("Null or empty transformation");
}
if ((provider == null) || (provider.length() == 0)) {
@ -698,7 +698,7 @@ public class Cipher {
Provider provider)
throws NoSuchAlgorithmException, NoSuchPaddingException
{
if ((transformation == null) || transformation.equals("")) {
if ((transformation == null) || transformation.isEmpty()) {
throw new NoSuchAlgorithmException("Null or empty transformation");
}
if (provider == null) {
@ -2840,4 +2840,4 @@ public class Cipher {
sb.append(", algorithm from: ").append(getProviderName());
return sb.toString();
}
}
}

View File

@ -668,7 +668,7 @@ public class SSLParameters {
String[] tempProtocols = protocols.clone();
for (String p : tempProtocols) {
if (p == null || p.equals("")) {
if (p == null || p.isEmpty()) {
throw new IllegalArgumentException(
"An element of protocols was null/empty");
}

View File

@ -97,10 +97,10 @@ public class URLClassPath {
JAVA_VERSION = props.getProperty("java.version");
DEBUG = (props.getProperty("sun.misc.URLClassPath.debug") != null);
String p = props.getProperty("sun.misc.URLClassPath.disableJarChecking");
DISABLE_JAR_CHECKING = p != null ? p.equals("true") || p.equals("") : false;
DISABLE_JAR_CHECKING = p != null ? p.equals("true") || p.isEmpty() : false;
p = props.getProperty("jdk.net.URLClassPath.disableRestrictedPermissions");
DISABLE_ACC_CHECKING = p != null ? p.equals("true") || p.equals("") : false;
DISABLE_ACC_CHECKING = p != null ? p.equals("true") || p.isEmpty() : false;
// This property will be removed in a later release
p = props.getProperty("jdk.net.URLClassPath.disableClassPathURLCheck", "true");

View File

@ -111,7 +111,7 @@ public class URLJarFile extends JarFile {
* 'file:' URLs can be accessible through ftp.
*/
String host = url.getHost();
if (host == null || host.equals("") || host.equals("~") ||
if (host == null || host.isEmpty() || host.equals("~") ||
host.equalsIgnoreCase("localhost"))
return true;
}

View File

@ -127,7 +127,7 @@ public class Handler extends URLStreamHandler {
* Let's just make sure we DO have an Email address in the URL.
*/
boolean nogood = false;
if (file == null || file.equals(""))
if (file == null || file.isEmpty())
nogood = true;
else {
boolean allwhites = true;

View File

@ -1608,7 +1608,7 @@ public class PolicyFile extends java.security.Policy {
if (u.getProtocol().equals("file")) {
boolean isLocalFile = false;
String host = u.getHost();
isLocalFile = (host == null || host.equals("") ||
isLocalFile = (host == null || host.isEmpty() ||
host.equals("~") || host.equalsIgnoreCase("localhost"));
if (isLocalFile) {

View File

@ -103,7 +103,7 @@ public class ConsoleCallbackHandler implements CallbackHandler {
System.err.flush();
String result = readLine();
if (result.equals("")) {
if (result.isEmpty()) {
result = nc.getDefaultName();
}
@ -212,7 +212,7 @@ public class ConsoleCallbackHandler implements CallbackHandler {
prompt = "";
}
prompt = prefix + prompt;
if (!prompt.equals("")) {
if (!prompt.isEmpty()) {
System.err.println(prompt);
}

View File

@ -363,7 +363,7 @@ class DomainName {
}
private static int numLabels(String rule) {
if (rule.equals("")) {
if (rule.isEmpty()) {
return 0;
}
int len = rule.length();

View File

@ -103,7 +103,7 @@ class UnixFileSystem extends FileSystem {
}
public String resolve(String parent, String child) {
if (child.equals("")) return parent;
if (child.isEmpty()) return parent;
if (child.charAt(0) == '/') {
if (parent.equals("/")) return child;
return parent + child;

View File

@ -75,7 +75,7 @@ public class Handler extends URLStreamHandler {
public synchronized URLConnection openConnection(URL u, Proxy p)
throws IOException {
String host = u.getHost();
if (host == null || host.equals("") || host.equals("~") ||
if (host == null || host.isEmpty() || host.equals("~") ||
host.equalsIgnoreCase("localhost")) {
File file = new File(ParseUtil.decode(u.getPath()));
return createFileURLConnection(u, file);

View File

@ -55,7 +55,7 @@ public class FileURLMapper {
return file;
}
String host = url.getHost();
if (host != null && !host.equals("") &&
if (host != null && !host.isEmpty() &&
!"localhost".equalsIgnoreCase(host)) {
String rest = url.getFile();
String s = host + ParseUtil.decode (url.getFile());

View File

@ -83,7 +83,7 @@ public class Handler extends URLStreamHandler {
path = path.replace('/', '\\');
path = path.replace('|', ':');
if ((host == null) || host.equals("") ||
if ((host == null) || host.isEmpty() ||
host.equalsIgnoreCase("localhost") ||
host.equals("~")) {
return createFileURLConnection(url, new File(path));

View File

@ -76,7 +76,7 @@ class JarFileFactory implements URLJarFile.URLJarFileCloseController {
// Deal with UNC pathnames specially. See 4180841
String host = url.getHost();
if (host != null && !host.equals("") &&
if (host != null && !host.isEmpty() &&
!host.equalsIgnoreCase("localhost")) {
url = new URL("file", "", "//" + host + url.getPath());

View File

@ -128,12 +128,12 @@ class WindowsUriSupport {
if (uri.getRawQuery() != null)
throw new IllegalArgumentException("URI has a query component");
String path = uri.getPath();
if (path.equals(""))
if (path.isEmpty())
throw new IllegalArgumentException("URI path component is empty");
// UNC
String auth = uri.getRawAuthority();
if (auth != null && !auth.equals("")) {
if (auth != null && !auth.isEmpty()) {
String host = uri.getHost();
if (host == null)
throw new IllegalArgumentException("URI authority component has undefined host");

View File

@ -890,7 +890,7 @@ public class LogManager {
// Gets a node in our tree of logger nodes.
// If necessary, create it.
LogNode getNode(String name) {
if (name == null || name.equals("")) {
if (name == null || name.isEmpty()) {
return root;
}
LogNode node = root;
@ -1486,7 +1486,7 @@ public class LogManager {
// Reset Logger level
String name = logger.getName();
if (name != null && name.equals("")) {
if (name != null && name.isEmpty()) {
// This is the root logger.
logger.setLevel(defaultLevel);
} else {

View File

@ -289,7 +289,7 @@ public class RMIConnectorServer extends JMXConnectorServer {
throw new MalformedURLException(msg);
}
final String urlPath = url.getURLPath();
if (!urlPath.equals("")
if (!urlPath.isEmpty()
&& !urlPath.equals("/")
&& !urlPath.startsWith("/jndi/")) {
final String msg = "URL path must be empty or start with " +
@ -746,7 +746,7 @@ public class RMIConnectorServer extends JMXConnectorServer {
port = 0;
} else {
protocol = address.getProtocol();
host = (address.getHost().equals("")) ? null : address.getHost();
host = (address.getHost().isEmpty()) ? null : address.getHost();
port = address.getPort();
}

View File

@ -114,7 +114,7 @@ public class ServerNotifForwarder {
// 6238731: set the default domain if no domain is set.
ObjectName nn = name;
if (name.getDomain() == null || name.getDomain().equals("")) {
if (name.getDomain() == null || name.getDomain().isEmpty()) {
try {
nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
name.getKeyPropertyList());

View File

@ -110,7 +110,7 @@ public class ImmutableDescriptor implements Descriptor {
new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
for (Map.Entry<String, ?> entry : fields.entrySet()) {
String name = entry.getKey();
if (name == null || name.equals(""))
if (name == null || name.isEmpty())
throw new IllegalArgumentException("Empty or null field name");
if (map.containsKey(name))
throw new IllegalArgumentException("Duplicate name: " + name);
@ -166,7 +166,7 @@ public class ImmutableDescriptor implements Descriptor {
new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
for (int i = 0; i < fieldNames.length; i++) {
String name = fieldNames[i];
if (name == null || name.equals(""))
if (name == null || name.isEmpty())
throw new IllegalArgumentException("Empty or null field name");
Object old = map.put(name, fieldValues[i]);
if (old != null) {
@ -333,7 +333,7 @@ public class ImmutableDescriptor implements Descriptor {
Object[] result = new Object[fieldNames.length];
for (int i = 0; i < fieldNames.length; i++) {
String name = fieldNames[i];
if (name != null && !name.equals(""))
if (name != null && !name.isEmpty())
result[i] = getFieldValue(name);
}
return result;
@ -543,7 +543,7 @@ public class ImmutableDescriptor implements Descriptor {
}
private static void checkIllegalFieldName(String name) {
if (name == null || name.equals(""))
if (name == null || name.isEmpty())
illegal("Null or empty field name");
}

View File

@ -256,7 +256,7 @@ public class MBeanPermission extends Permission {
if (actions == null)
throw new IllegalArgumentException("MBeanPermission: " +
"actions can't be null");
if (actions.equals(""))
if (actions.isEmpty())
throw new IllegalArgumentException("MBeanPermission: " +
"actions can't be empty");
@ -279,7 +279,7 @@ public class MBeanPermission extends Permission {
throw new IllegalArgumentException("MBeanPermission name " +
"cannot be null");
if (name.equals(""))
if (name.isEmpty())
throw new IllegalArgumentException("MBeanPermission name " +
"cannot be empty");
@ -310,7 +310,7 @@ public class MBeanPermission extends Permission {
//
String on = name.substring(openingBracket + 1,
name.length() - 1);
if (on.equals(""))
if (on.isEmpty())
objectName = ObjectName.WILDCARD;
else if (on.equals("-"))
objectName = null;
@ -359,7 +359,7 @@ public class MBeanPermission extends Permission {
if (className == null || className.equals("-")) {
classNamePrefix = null;
classNameExactMatch = false;
} else if (className.equals("") || className.equals("*")) {
} else if (className.isEmpty() || className.equals("*")) {
classNamePrefix = "";
classNameExactMatch = false;
} else if (className.endsWith(".*")) {
@ -375,7 +375,7 @@ public class MBeanPermission extends Permission {
private void setMember(String member) {
if (member == null || member.equals("-"))
this.member = null;
else if (member.equals(""))
else if (member.isEmpty())
this.member = "*";
else
this.member = member;

View File

@ -443,7 +443,7 @@ public class DescriptorSupport
init(null);
for (int i=0; i < fields.length; i++) {
if ((fields[i] == null) || (fields[i].equals(""))) {
if ((fields[i] == null) || (fields[i].isEmpty())) {
continue;
}
int eq_separator = fields[i].indexOf('=');
@ -467,7 +467,7 @@ public class DescriptorSupport
fieldValue = fields[i].substring(eq_separator+1);
}
if (fieldName.equals("")) {
if (fieldName.isEmpty()) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE,
"Descriptor(String... fields) " +
@ -500,7 +500,7 @@ public class DescriptorSupport
public synchronized Object getFieldValue(String fieldName)
throws RuntimeOperationsException {
if ((fieldName == null) || (fieldName.equals(""))) {
if ((fieldName == null) || (fieldName.isEmpty())) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE,
"Illegal arguments: null field name");
@ -522,7 +522,7 @@ public class DescriptorSupport
throws RuntimeOperationsException {
// field name cannot be null or empty
if ((fieldName == null) || (fieldName.equals(""))) {
if ((fieldName == null) || (fieldName.isEmpty())) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE,
"Illegal arguments: null or empty field name");
@ -664,7 +664,7 @@ public class DescriptorSupport
responseFields[i++] = value;
} else {
for (i=0; i < fieldNames.length; i++) {
if ((fieldNames[i] == null) || (fieldNames[i].equals(""))) {
if ((fieldNames[i] == null) || (fieldNames[i].isEmpty())) {
responseFields[i] = null;
} else {
responseFields[i] = getFieldValue(fieldNames[i]);
@ -700,7 +700,7 @@ public class DescriptorSupport
}
for (int i=0; i < fieldNames.length; i++) {
if (( fieldNames[i] == null) || (fieldNames[i].equals(""))) {
if (( fieldNames[i] == null) || (fieldNames[i].isEmpty())) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE,
"Null field name encountered at element " + i);
@ -733,7 +733,7 @@ public class DescriptorSupport
}
public synchronized void removeField(String fieldName) {
if ((fieldName == null) || (fieldName.equals(""))) {
if ((fieldName == null) || (fieldName.isEmpty())) {
return;
}
@ -862,7 +862,7 @@ public class DescriptorSupport
String thisDescType = (String)(getFieldValue("descriptorType"));
if ((thisName == null) || (thisDescType == null) ||
(thisName.equals("")) || (thisDescType.equals(""))) {
(thisName.isEmpty()) || (thisDescType.isEmpty())) {
return false;
}
@ -912,7 +912,7 @@ public class DescriptorSupport
private boolean validateField(String fldName, Object fldValue) {
if ((fldName == null) || (fldName.equals("")))
if ((fldName == null) || (fldName.isEmpty()))
return false;
String SfldValue = "";
boolean isAString = false;
@ -931,7 +931,7 @@ public class DescriptorSupport
fldName.equalsIgnoreCase("Class")) {
if (fldValue == null || !isAString)
return false;
if (nameOrDescriptorType && SfldValue.equals(""))
if (nameOrDescriptorType && SfldValue.isEmpty())
return false;
return true;
} else if (fldName.equalsIgnoreCase("visibility")) {

View File

@ -367,7 +367,7 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo {
MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
}
if ((inDescriptorType == null) || (inDescriptorType.equals(""))) {
if ((inDescriptorType == null) || (inDescriptorType.isEmpty())) {
inDescriptorType = "all";
}
@ -600,7 +600,7 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo {
inDescriptor = new DescriptorSupport();
}
if ((inDescriptorType == null) || (inDescriptorType.equals(""))) {
if ((inDescriptorType == null) || (inDescriptorType.isEmpty())) {
inDescriptorType =
(String) inDescriptor.getFieldValue("descriptorType");

View File

@ -171,7 +171,7 @@ public class CompositeType extends OpenType<CompositeData> {
private static void checkForEmptyString(String[] arg, String argName) {
for (int i=0; i<arg.length; i++) {
if (arg[i].trim().equals("")) {
if (arg[i].trim().isEmpty()) {
throw new IllegalArgumentException("Argument's element "+ argName +"["+ i +"] cannot be an empty string.");
}
}

View File

@ -456,11 +456,11 @@ public class OpenMBeanAttributeInfoSupport
throw new IllegalArgumentException("OpenType cannot be null");
if (info.getName() == null ||
info.getName().trim().equals(""))
info.getName().trim().isEmpty())
throw new IllegalArgumentException("Name cannot be null or empty");
if (info.getDescription() == null ||
info.getDescription().trim().equals(""))
info.getDescription().trim().isEmpty())
throw new IllegalArgumentException("Description cannot be null or empty");
// Check and initialize defaultValue

View File

@ -124,11 +124,11 @@ public class OpenMBeanConstructorInfoSupport
// check parameters that should not be null or empty
// (unfortunately it is not done in superclass :-( ! )
//
if (name == null || name.trim().equals("")) {
if (name == null || name.trim().isEmpty()) {
throw new IllegalArgumentException("Argument name cannot be " +
"null or empty");
}
if (description == null || description.trim().equals("")) {
if (description == null || description.trim().isEmpty()) {
throw new IllegalArgumentException("Argument description cannot " +
"be null or empty");
}

View File

@ -163,11 +163,11 @@ public class OpenMBeanOperationInfoSupport
// check parameters that should not be null or empty
// (unfortunately it is not done in superclass :-( ! )
//
if (name == null || name.trim().equals("")) {
if (name == null || name.trim().isEmpty()) {
throw new IllegalArgumentException("Argument name cannot " +
"be null or empty");
}
if (description == null || description.trim().equals("")) {
if (description == null || description.trim().isEmpty()) {
throw new IllegalArgumentException("Argument description cannot " +
"be null or empty");
}

View File

@ -268,7 +268,7 @@ public abstract class OpenType<T> implements Serializable {
/* Return argValue.trim() provided argValue is neither null nor empty;
otherwise throw IllegalArgumentException. */
private static String valid(String argName, String argValue) {
if (argValue == null || (argValue = argValue.trim()).equals(""))
if (argValue == null || (argValue = argValue.trim()).isEmpty())
throw new IllegalArgumentException("Argument " + argName +
" cannot be null or empty");
return argValue;

View File

@ -165,7 +165,7 @@ public class TabularType extends OpenType<TabularData> {
*/
private static void checkForEmptyString(String[] arg, String argName) {
for (int i=0; i<arg.length; i++) {
if (arg[i].trim().equals("")) {
if (arg[i].trim().isEmpty()) {
throw new IllegalArgumentException("Argument's element "+ argName +"["+ i +"] cannot be an empty string.");
}
}

View File

@ -405,7 +405,7 @@ public class JMXConnectorFactory {
}
final String pkgs = (String) pkgsObject;
if (pkgs.trim().equals(""))
if (pkgs.trim().isEmpty())
return null;
// pkgs may not contain an empty element

View File

@ -663,7 +663,7 @@ public abstract class MappedMXBeanType {
continue;
}
if (rest.equals("") ||
if (rest.isEmpty() ||
method.getParameterTypes().length > 0 ||
type == void.class ||
rest.equals("Class")) {

View File

@ -53,7 +53,7 @@ final class Filter {
static void encodeFilterString(BerEncoder ber, String filterStr,
boolean isLdapv3) throws IOException, NamingException {
if ((filterStr == null) || (filterStr.equals(""))) {
if ((filterStr == null) || (filterStr.isEmpty())) {
throw new InvalidSearchFilterException("Empty filter");
}
byte[] filter;

View File

@ -915,7 +915,7 @@ final public class LdapCtx extends ComponentDirContext
boolean directUpdate) throws NamingException {
// Handle the empty name
if (dn.equals("")) {
if (dn.isEmpty()) {
return attrs;
}
@ -1271,7 +1271,7 @@ final public class LdapCtx extends ComponentDirContext
int prefixLast = prefix.size() - 1;
if (name.isEmpty() || prefix.isEmpty() ||
name.get(0).equals("") || prefix.get(prefixLast).equals("")) {
name.get(0).isEmpty() || prefix.get(prefixLast).isEmpty()) {
return super.composeName(name, prefix);
}
@ -1300,9 +1300,9 @@ final public class LdapCtx extends ComponentDirContext
// used by LdapSearchEnumeration
private static String concatNames(String lesser, String greater) {
if (lesser == null || lesser.equals("")) {
if (lesser == null || lesser.isEmpty()) {
return greater;
} else if (greater == null || greater.equals("")) {
} else if (greater == null || greater.isEmpty()) {
return lesser;
} else {
return (lesser + "," + greater);
@ -3036,7 +3036,7 @@ final public class LdapCtx extends ComponentDirContext
}
// extract SLAPD-style referrals from errorMessage
if ((res.errorMessage != null) && (!res.errorMessage.equals(""))) {
if ((res.errorMessage != null) && (!res.errorMessage.isEmpty())) {
res.referrals = extractURLs(res.errorMessage);
} else {
e = new PartialResultException(msg);

View File

@ -182,7 +182,7 @@ final class LdapReferralContext implements DirContext, LdapContext {
if (urlString == null) {
urlName = null;
} else {
urlName = urlString.equals("") ? new CompositeName() :
urlName = urlString.isEmpty() ? new CompositeName() :
new CompositeName().add(urlString);
}
}
@ -888,7 +888,7 @@ final class LdapReferralContext implements DirContext, LdapContext {
// ---------------------- Private methods ---------------------
private Name toName(String name) throws InvalidNameException {
return name.equals("") ? new CompositeName() :
return name.isEmpty() ? new CompositeName() :
new CompositeName().add(name);
}

View File

@ -97,13 +97,13 @@ final class LdapSearchEnumeration
// Name relative to search context
CompositeName cn = new CompositeName();
if (!relStart.equals("")) {
if (!relStart.isEmpty()) {
cn.add(relStart);
}
// Name relative to homeCtx
CompositeName rcn = new CompositeName();
if (!relHome.equals("")) {
if (!relHome.isEmpty()) {
rcn.add(relHome);
}
//System.err.println("relStart: " + cn);

View File

@ -197,7 +197,7 @@ final public class LdapURL extends Uri {
// path begins with a '/' or is empty
if (path.equals("")) {
if (path.isEmpty()) {
return;
}

View File

@ -115,7 +115,7 @@ final class NamingEventNotifier implements Runnable {
try {
Continuation cont = new Continuation();
cont.setError(this, info.name);
Name nm = (info.name == null || info.name.equals("")) ?
Name nm = (info.name == null || info.name.isEmpty()) ?
new CompositeName() : new CompositeName().add(info.name);
results = context.searchAux(nm, info.filter, info.controls,

View File

@ -243,7 +243,7 @@ public abstract class AtomicContext extends ComponentContext {
protected boolean isEmpty(String name) {
return name == null || name.equals("");
return name == null || name.isEmpty();
}
// ------ implementations of c_ and c_*_nns methods using
@ -510,7 +510,7 @@ public abstract class AtomicContext extends ComponentContext {
*/
protected void a_processJunction_nns(String name, Continuation cont)
throws NamingException {
if (name.equals("")) {
if (name.isEmpty()) {
NameNotFoundException e = new NameNotFoundException();
cont.setErrorNNS(this, name);
throw cont.fillInException(e);

View File

@ -105,7 +105,7 @@ public abstract class ComponentContext extends PartialCompositeContext {
throws NamingException {
int separator;
// if no name to parse, or if we're already at boundary
if (name.isEmpty() || name.get(0).equals("")) {
if (name.isEmpty() || name.get(0).isEmpty()) {
separator = 0;
} else {
separator = 1;
@ -379,7 +379,7 @@ public abstract class ComponentContext extends PartialCompositeContext {
if (tail == null || tail.isEmpty()) {
//System.out.println("terminal : " + head);
ret = TERMINAL_COMPONENT;
} else if (!tail.get(0).equals("")) {
} else if (!tail.get(0).isEmpty()) {
// tail does not begin with "/"
/*
if (head.isEmpty()) {
@ -468,7 +468,7 @@ public abstract class ComponentContext extends PartialCompositeContext {
void checkAndAdjustRemainingName(Name rname) throws InvalidNameException {
int count;
if (rname != null && (count=rname.size()) > 1 &&
rname.get(count-1).equals("")) {
rname.get(count-1).isEmpty()) {
rname.remove(count-1);
}
}
@ -477,7 +477,7 @@ public abstract class ComponentContext extends PartialCompositeContext {
protected boolean isAllEmpty(Name n) {
int count = n.size();
for (int i =0; i < count; i++ ) {
if (!n.get(i).equals("")) {
if (!n.get(i).isEmpty()) {
return false;
}
}

View File

@ -203,7 +203,7 @@ public class Continuation extends ResolveResult {
public void setErrorNNS(Object resObj, String remain) {
CompositeName rname = new CompositeName();
try {
if (remain != null && !remain.equals(""))
if (remain != null && !remain.isEmpty())
rname.add(remain);
rname.add("");
@ -247,7 +247,7 @@ public class Continuation extends ResolveResult {
*/
public void setError(Object resObj, String remain) {
CompositeName rname = new CompositeName();
if (remain != null && !remain.equals("")) {
if (remain != null && !remain.isEmpty()) {
try {
rname.add(remain);
} catch (InvalidNameException e) {
@ -375,14 +375,14 @@ public class Continuation extends ResolveResult {
public void setContinue(Object obj, String relResName,
Context currCtx, String remain) {
CompositeName relname = new CompositeName();
if (!relResName.equals("")) {
if (!relResName.isEmpty()) {
try {
relname.add(relResName);
} catch (NamingException e){}
}
CompositeName rname = new CompositeName();
if (!remain.equals("")) {
if (!remain.isEmpty()) {
try {
rname.add(remain);
} catch (NamingException e) {

View File

@ -477,9 +477,9 @@ public abstract class PartialCompositeContext implements Context, Resolver {
int len = prefix.size();
if (!allEmpty(prefix) && !allEmpty(name)) {
if (res.get(len - 1).equals("")) {
if (res.get(len - 1).isEmpty()) {
res.remove(len - 1);
} else if (res.get(len).equals("")) {
} else if (res.get(len).isEmpty()) {
res.remove(len);
}
}

View File

@ -138,7 +138,7 @@ public class ContextEnumerator implements NamingEnumeration<Binding> {
// if the name is relative, we need to add it to the name of this
// context to keep it relative w.r.t. the root context we are
// enumerating
if(oldBinding.isRelative() && !contextName.equals("")) {
if(oldBinding.isRelative() && !contextName.isEmpty()) {
NameParser parser = root.getNameParser("");
Name newName = parser.parse(contextName);
newName.add(oldBinding.getName());

View File

@ -476,9 +476,9 @@ abstract public class GenericURLContext implements Context {
public String composeName(String name, String prefix)
throws NamingException {
if (prefix.equals("")) {
if (prefix.isEmpty()) {
return name;
} else if (name.equals("")) {
} else if (name.isEmpty()) {
return prefix;
} else {
return (prefix + "/" + name);

View File

@ -201,13 +201,13 @@ class Http1Request {
private String getPathAndQuery(URI uri) {
String path = uri.getRawPath();
String query = uri.getRawQuery();
if (path == null || path.equals("")) {
if (path == null || path.isEmpty()) {
path = "/";
}
if (query == null) {
query = "";
}
if (query.equals("")) {
if (query.isEmpty()) {
return Utils.encode(path);
} else {
return Utils.encode(path + "?" + query);

View File

@ -190,7 +190,7 @@ public class HttpRequestBuilderImpl implements HttpRequest.Builder {
@Override
public HttpRequest.Builder method(String method, BodyPublisher body) {
requireNonNull(method);
if (method.equals(""))
if (method.isEmpty())
throw newIAE("illegal method <empty string>");
if (method.equals("CONNECT"))
throw newIAE("method CONNECT is not supported");
@ -205,7 +205,7 @@ public class HttpRequestBuilderImpl implements HttpRequest.Builder {
private HttpRequest.Builder method0(String method, BodyPublisher body) {
assert method != null;
assert !method.equals("");
assert !method.isEmpty();
this.method = method;
this.bodyPublisher = body;
return this;

View File

@ -84,7 +84,7 @@ class ResponseContent {
if (contentLength == -1) {
String tc = headers.firstValue("Transfer-Encoding")
.orElse("");
if (!tc.equals("")) {
if (!tc.isEmpty()) {
if (tc.equalsIgnoreCase("chunked")) {
chunkedContent = true;
} else {

View File

@ -97,7 +97,7 @@ public class SSLFlowDelegate {
private static final ByteBuffer NOTHING = ByteBuffer.allocate(0);
private static final String monProp = Utils.getProperty("jdk.internal.httpclient.monitorFlowDelegate");
private static final boolean isMonitored =
monProp != null && (monProp.equals("") || monProp.equalsIgnoreCase("true"));
monProp != null && (monProp.isEmpty() || monProp.equalsIgnoreCase("true"));
final Executor exec;
final Reader reader;

View File

@ -203,7 +203,7 @@ public abstract class AbstractPreferences extends Preferences {
*/
protected AbstractPreferences(AbstractPreferences parent, String name) {
if (parent==null) {
if (!name.equals(""))
if (!name.isEmpty())
throw new IllegalArgumentException("Root name '"+name+
"' must be \"\"");
this.absolutePath = "/";
@ -212,7 +212,7 @@ public abstract class AbstractPreferences extends Preferences {
if (name.indexOf('/') != -1)
throw new IllegalArgumentException("Name '" + name +
"' contains '/'");
if (name.equals(""))
if (name.isEmpty())
throw new IllegalArgumentException("Illegal name: empty string");
root = parent.root;
@ -848,7 +848,7 @@ public abstract class AbstractPreferences extends Preferences {
synchronized(lock) {
if (removed)
throw new IllegalStateException("Node has been removed.");
if (path.equals(""))
if (path.isEmpty())
return this;
if (path.equals("/"))
return root;
@ -911,7 +911,7 @@ public abstract class AbstractPreferences extends Preferences {
throws BackingStoreException
{
synchronized(lock) {
if (path.equals(""))
if (path.isEmpty())
return !removed;
if (removed)
throw new IllegalStateException("Node has been removed.");

View File

@ -189,7 +189,7 @@ public final class ExecOptionPermission extends Permission
if (name == null)
throw new NullPointerException("name can't be null");
if (name.equals("")) {
if (name.isEmpty()) {
throw new IllegalArgumentException("name can't be empty");
}

View File

@ -199,7 +199,7 @@ public final class Naming {
Registry registry = getRegistry(parsed);
String prefix = "";
if (parsed.port > 0 || !parsed.host.equals(""))
if (parsed.port > 0 || !parsed.host.isEmpty())
prefix += "//" + parsed.host;
if (parsed.port > 0)
prefix += ":" + parsed.port;

View File

@ -370,7 +370,7 @@ public class ActivatableRef implements RemoteRef {
ref = null;
String className = in.readUTF();
if (className.equals("")) return;
if (className.isEmpty()) return;
try {
Class<?> refClass = Class.forName(RemoteRef.packagePrefix + "." +

View File

@ -1857,7 +1857,7 @@ public class Activation implements Serializable {
checkPermission(perms,
new ExecOptionPermission(option));
} catch (AccessControlException e) {
if (value.equals("")) {
if (value.isEmpty()) {
checkPermission(perms,
new ExecOptionPermission("-D" + name));
} else {
@ -2101,7 +2101,7 @@ public class Activation implements Serializable {
* Initialize method for activation exec policy.
*/
if (!execPolicyClassName.equals("none")) {
if (execPolicyClassName.equals("") ||
if (execPolicyClassName.isEmpty() ||
execPolicyClassName.equals("default"))
{
execPolicyClassName = DefaultExecPolicy.class.getName();

View File

@ -738,7 +738,7 @@ public class TCPEndpoint implements Endpoint {
}
hostName = f.getHost();
if ((hostName == null) || (hostName.equals(""))
if ((hostName == null) || (hostName.isEmpty())
|| (hostName.indexOf('.') < 0 )) {
hostName = hostAddress;

View File

@ -114,7 +114,7 @@ public class Main {
System.setProperty(value.substring(0, eq),
value.substring(eq + 1));
} else {
if (!value.equals("")) {
if (!value.isEmpty()) {
System.setProperty(value, "");
} else {
// do not allow empty property name

View File

@ -593,7 +593,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
super.setCommand(cmd);
if(!buildTableName(cmd).equals("")) {
if(!buildTableName(cmd).isEmpty()) {
this.setTableName(buildTableName(cmd));
}
}
@ -7069,7 +7069,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
public void setMatchColumn(String[] columnNames) throws SQLException {
for(int j = 0; j < columnNames.length; j++) {
if( columnNames[j] == null || columnNames[j].equals("")) {
if( columnNames[j] == null || columnNames[j].isEmpty()) {
throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.matchcols2").toString());
}
}
@ -7124,7 +7124,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
*/
public void setMatchColumn(String columnName) throws SQLException {
// validate, if col is ok to be set
if(columnName == null || (columnName= columnName.trim()).equals("") ) {
if(columnName == null || (columnName= columnName.trim()).isEmpty() ) {
throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.matchcols2").toString());
} else {
// set strMatchColumn

View File

@ -624,7 +624,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
(getDataSourceName());
//return ds.getConnection(getUsername(),getPassword());
if(getUsername() != null && !getUsername().equals("")) {
if(getUsername() != null && !getUsername().isEmpty()) {
return ds.getConnection(getUsername(),getPassword());
} else {
return ds.getConnection();
@ -3873,7 +3873,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
public void setMatchColumn(String[] columnNames) throws SQLException {
for(int j = 0; j < columnNames.length; j++) {
if( columnNames[j] == null || columnNames[j].equals("")) {
if( columnNames[j] == null || columnNames[j].isEmpty()) {
throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString());
}
}
@ -3928,7 +3928,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
*/
public void setMatchColumn(String columnName) throws SQLException {
// validate, if col is ok to be set
if(columnName == null || (columnName= columnName.trim()).equals("")) {
if(columnName == null || (columnName= columnName.trim()).isEmpty()) {
throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString());
} else {
// set strMatchColumn

View File

@ -537,7 +537,7 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable {
private void writeStringData(String s) throws java.io.IOException {
if (s == null) {
writeNull();
} else if (s.equals("")) {
} else if (s.isEmpty()) {
writeEmptyString();
} else {

View File

@ -852,7 +852,7 @@ public abstract class BaseRowSet implements Serializable, Cloneable {
if (name == null) {
dataSource = null;
} else if (name.equals("")) {
} else if (name.isEmpty()) {
throw new SQLException("DataSource name cannot be empty string");
} else {
dataSource = name;

View File

@ -622,7 +622,7 @@ public class DriverManager {
println("DriverManager.initialize: jdbc.drivers = " + drivers);
if (drivers != null && !drivers.equals("")) {
if (drivers != null && !drivers.isEmpty()) {
String[] driversList = drivers.split(":");
println("number of Drivers:" + driversList.length);
for (String aDriver : driversList) {

View File

@ -85,7 +85,7 @@ public class AttributeImpl extends DummyEvent implements Attribute
init();
fQName = qname ;
fValue = value ;
if(type != null && !type.equals(""))
if(type != null && !type.isEmpty())
fAttributeType = type;
fNonNormalizedvalue = nonNormalizedvalue;

View File

@ -73,7 +73,7 @@ implements StartDocument {
this.fEncodingScheam = encoding;
this.fVersion = version;
this.fStandalone = standalone;
if (encoding != null && !encoding.equals(""))
if (encoding != null && !encoding.isEmpty())
this.fEncodingSchemeSet = true;
else {
this.fEncodingSchemeSet = false;

View File

@ -219,7 +219,7 @@ public class XMLDOMWriterImpl implements XMLStreamWriterBase {
}
String qualifiedName = null;
if(prefix.equals("")){
if(prefix.isEmpty()){
qualifiedName = localName;
}else{
qualifiedName = getQName(prefix,localName);
@ -254,7 +254,7 @@ public class XMLDOMWriterImpl implements XMLStreamWriterBase {
throw new XMLStreamException("prefix cannot be null");
}
String qualifiedName = null;
if(prefix.equals("")){
if(prefix.isEmpty()){
qualifiedName = localName;
}else{
@ -502,7 +502,7 @@ public class XMLDOMWriterImpl implements XMLStreamWriterBase {
String qname = null;
if (prefix.equals("")) {
if (prefix.isEmpty()) {
qname = XMLConstants.XMLNS_ATTRIBUTE;
} else {
qname = getQName(XMLConstants.XMLNS_ATTRIBUTE,prefix);
@ -669,7 +669,7 @@ public class XMLDOMWriterImpl implements XMLStreamWriterBase {
throw new XMLStreamException("Prefix cannot be null");
}
if(prefix.equals("")){
if(prefix.isEmpty()){
qname = localName;
}else{
qname = getQName(prefix,localName);

View File

@ -628,8 +628,8 @@ public final class XMLStreamWriterImpl extends AbstractMap<Object, Object>
}
if (!fIsRepairingNamespace) {
if (prefix == null || prefix.equals("")){
if (!namespaceURI.equals("")) {
if (prefix == null || prefix.isEmpty()){
if (!namespaceURI.isEmpty()) {
throw new XMLStreamException("prefix cannot be null or empty");
} else {
writeAttributeWithPrefix(null, localName, value);
@ -908,7 +908,7 @@ public final class XMLStreamWriterImpl extends AbstractMap<Object, Object>
} else {
fWriter.write(OPEN_END_TAG);
if ((elem.prefix != null) && !(elem.prefix).equals("")) {
if ((elem.prefix != null) && !(elem.prefix).isEmpty()) {
fWriter.write(elem.prefix);
fWriter.write(":");
}
@ -945,7 +945,7 @@ public final class XMLStreamWriterImpl extends AbstractMap<Object, Object>
fWriter.write(OPEN_END_TAG);
if ((currentElement.prefix != null) &&
!(currentElement.prefix).equals("")) {
!(currentElement.prefix).isEmpty()) {
fWriter.write(currentElement.prefix);
fWriter.write(":");
}
@ -1180,19 +1180,19 @@ public final class XMLStreamWriterImpl extends AbstractMap<Object, Object>
}
// Verify the encoding before writing anything
if (encoding != null && !encoding.equals("")) {
if (encoding != null && !encoding.isEmpty()) {
verifyEncoding(encoding);
}
fWriter.write("<?xml version=\"");
if ((version == null) || version.equals("")) {
if ((version == null) || version.isEmpty()) {
fWriter.write(DEFAULT_XML_VERSION);
} else {
fWriter.write(version);
}
if (encoding != null && !encoding.equals("")) {
if (encoding != null && !encoding.isEmpty()) {
fWriter.write("\" encoding=\"");
fWriter.write(encoding);
}
@ -1584,7 +1584,7 @@ public final class XMLStreamWriterImpl extends AbstractMap<Object, Object>
attr = fAttributeCache.get(j);
if ((attr.prefix != null) && (attr.uri != null)) {
if (!attr.prefix.equals("") && !attr.uri.equals("") ) {
if (!attr.prefix.isEmpty() && !attr.uri.isEmpty() ) {
String tmp = fInternalNamespaceContext.getPrefix(attr.uri);
if ((tmp == null) || (!tmp.equals(attr.prefix))) {
@ -1765,7 +1765,7 @@ public final class XMLStreamWriterImpl extends AbstractMap<Object, Object>
for(int i=0 ; i< fAttributeCache.size();i++){
attr = fAttributeCache.get(i);
if((attr.prefix != null && !attr.prefix.equals("")) || (attr.uri != null && !attr.uri.equals(""))) {
if((attr.prefix != null && !attr.prefix.isEmpty()) || (attr.uri != null && !attr.uri.isEmpty())) {
correctPrefix(currentElement,attr);
}
}
@ -1773,7 +1773,7 @@ public final class XMLStreamWriterImpl extends AbstractMap<Object, Object>
if (!isDeclared(currentElement)) {
if ((currentElement.prefix != null) &&
(currentElement.uri != null)) {
if ((!currentElement.prefix.equals("")) && (!currentElement.uri.equals(""))) {
if ((!currentElement.prefix.isEmpty()) && (!currentElement.uri.isEmpty())) {
fNamespaceDecls.add(currentElement);
}
}
@ -1798,7 +1798,7 @@ public final class XMLStreamWriterImpl extends AbstractMap<Object, Object>
/* If 'attr' is an attribute and it is in no namespace(which means that prefix="", uri=""), attr's
namespace should not be redinded. See [http://www.w3.org/TR/REC-xml-names/#defaulting].
*/
if (attr.prefix != null && attr.prefix.equals("") && attr.uri != null && attr.uri.equals("")){
if (attr.prefix != null && attr.prefix.isEmpty() && attr.uri != null && attr.uri.isEmpty()){
repairNamespaceDecl(attr);
}
}

View File

@ -619,13 +619,13 @@ public class CatalogFeatures {
private boolean getSystemProperty(Feature cf, String sysPropertyName) {
if (cf.hasSystemProperty()) {
String value = SecuritySupport.getSystemProperty(sysPropertyName);
if (value != null && !value.equals("")) {
if (value != null && !value.isEmpty()) {
setProperty(cf, State.SYSTEMPROPERTY, value);
return true;
}
value = SecuritySupport.readJAXPProperty(sysPropertyName);
if (value != null && !value.equals("")) {
if (value != null && !value.isEmpty()) {
setProperty(cf, State.JAXPDOTPROPERTIES, value);
return true;
}

View File

@ -221,7 +221,7 @@ class Util {
*/
static String[] getCatalogFiles(String sysPropertyName) {
String value = SecuritySupport.getJAXPSystemProperty(sysPropertyName);
if (value != null && !value.equals("")) {
if (value != null && !value.isEmpty()) {
return value.split(";");
}
return null;

View File

@ -383,13 +383,13 @@ public class JdkXmlFeatures {
private boolean getSystemProperty(XmlFeature feature, String sysPropertyName) {
try {
String value = SecuritySupport.getSystemProperty(sysPropertyName);
if (value != null && !value.equals("")) {
if (value != null && !value.isEmpty()) {
setFeature(feature, State.SYSTEMPROPERTY, Boolean.parseBoolean(value));
return true;
}
value = SecuritySupport.readJAXPProperty(sysPropertyName);
if (value != null && !value.equals("")) {
if (value != null && !value.isEmpty()) {
setFeature(feature, State.JAXPDOTPROPERTIES, Boolean.parseBoolean(value));
return true;
}

View File

@ -1180,7 +1180,7 @@ public class Main {
String name = entry.name;
boolean isDir = entry.isDir;
if (name.equals("") || name.equals(".") || name.equals(zname)) {
if (name.isEmpty() || name.equals(".") || name.equals(zname)) {
return;
} else if ((name.equals(MANIFEST_DIR) || name.equals(MANIFEST_NAME))
&& !Mflag) {
@ -1886,7 +1886,7 @@ public class Main {
.map(ModuleInfoEntry::name)
.map(Main::versionFromEntryName)
.collect(joining(" "));
if (!releases.equals(""))
if (!releases.isEmpty())
output("releases: " + releases + "\n");
// Describe the operative descriptor for the specified --release, if any
@ -1955,7 +1955,7 @@ public class Main {
sb.append(md.toNameAndVersion());
if (!uriString.equals(""))
if (!uriString.isEmpty())
sb.append(" ").append(uriString);
if (md.isOpen())
sb.append(" open");

View File

@ -420,7 +420,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
} else {
String n = "";
for ( ; c != null; c = c.owner.enclClass()) {
n = c.name + (n.equals("") ? "" : ".") + n;
n = c.name + (n.isEmpty() ? "" : ".") + n;
}
return n;
}

View File

@ -114,18 +114,18 @@ public class SearchIndexItem {
item.append("\"m\":\"").append(containingModule).append("\",");
}
item.append("\"l\":\"").append(label).append("\"");
if (!url.equals("")) {
if (!url.isEmpty()) {
item.append(",\"url\":\"").append(url).append("\"");
}
item.append("}");
break;
case TYPES:
item.append("{");
if (!containingPackage.equals("")) {
if (!containingPackage.isEmpty()) {
item.append("\"p\":\"").append(containingPackage).append("\",");
}
item.append("\"l\":\"").append(label).append("\"");
if (!url.equals("")) {
if (!url.isEmpty()) {
item.append(",\"url\":\"").append(url).append("\"");
}
item.append("}");
@ -135,7 +135,7 @@ public class SearchIndexItem {
.append("\"p\":\"").append(containingPackage).append("\",")
.append("\"c\":\"").append(containingClass).append("\",")
.append("\"l\":\"").append(label).append("\"");
if (!url.equals("")) {
if (!url.isEmpty()) {
item.append(",\"url\":\"").append(url).append("\"");
}
item.append("}");
@ -144,7 +144,7 @@ public class SearchIndexItem {
item.append("{")
.append("\"l\":\"").append(label).append("\",")
.append("\"h\":\"").append(holder).append("\",");
if (!description.equals("")) {
if (!description.isEmpty()) {
item.append("\"d\":\"").append(description).append("\",");
}
item.append("\"u\":\"").append(url).append("\"")

View File

@ -149,7 +149,7 @@ public class JMap {
throws AttachNotSupportedException, IOException,
UnsupportedEncodingException {
String liveopt = "-all";
if (options.equals("") || options.equals("all")) {
if (options.isEmpty() || options.equals("all")) {
// pass
}
else if (options.equals("live")) {

View File

@ -313,9 +313,9 @@ public class ConnectDialog extends InternalDialog
if (remoteRadioButton.isSelected()) {
String txt = remoteTF.getText().trim();
String userName = userNameTF.getText().trim();
userName = userName.equals("") ? null : userName;
userName = userName.isEmpty() ? null : userName;
String password = passwordTF.getText();
password = password.equals("") ? null : password;
password = password.isEmpty() ? null : password;
try {
if (txt.startsWith(JConsole.ROOT_URL)) {
String url = txt;

View File

@ -665,7 +665,7 @@ class ThreadTab extends Tab implements ActionListener, DocumentListener, ListSel
}
public void focusLost(FocusEvent e) {
if (promptRemoved && getText().equals("")) {
if (promptRemoved && getText().isEmpty()) {
setText(prompt);
setForeground(Color.gray);
promptRemoved = false;

View File

@ -265,7 +265,7 @@ public class Agent {
// return empty property set
private static Properties parseString(String args) {
Properties argProps = new Properties();
if (args != null && !args.trim().equals("")) {
if (args != null && !args.trim().isEmpty()) {
for (String option : args.split(",")) {
String s[] = option.split("=", 2);
String name = s[0].trim();

View File

@ -537,8 +537,8 @@ public class DnsContext extends ComponentDirContext {
int prefixLast = prefixC.size() - 1;
// Let toolkit do the work at namespace boundaries.
if (nameC.isEmpty() || nameC.get(0).equals("") ||
prefixC.isEmpty() || prefixC.get(prefixLast).equals("")) {
if (nameC.isEmpty() || nameC.get(0).isEmpty() ||
prefixC.isEmpty() || prefixC.get(prefixLast).isEmpty()) {
return super.composeName(nameC, prefixC);
}
@ -687,7 +687,7 @@ public class DnsContext extends ComponentDirContext {
private static CT fromAttrId(String attrId)
throws InvalidAttributeIdentifierException {
if (attrId.equals("")) {
if (attrId.isEmpty()) {
throw new InvalidAttributeIdentifierException(
"Attribute ID cannot be empty");
}

View File

@ -368,7 +368,7 @@ public final class DnsName implements Name {
boolean hasRootLabel() {
return (!isEmpty() &&
get(0).equals(""));
get(0).isEmpty());
}
/*
@ -442,7 +442,7 @@ public final class DnsName implements Name {
// label of the name. Those two are special cases in that for
// all other domain names, the number of labels is one greater
// than the number of dot separators.
if (!name.equals("") && !name.equals(".")) {
if (!name.isEmpty() && !name.equals(".")) {
add(0, label.toString());
}

View File

@ -89,7 +89,7 @@ public class DnsUrl extends Uri {
domain = path.startsWith("/")
? path.substring(1)
: path;
domain = domain.equals("")
domain = domain.isEmpty()
? "."
: UrlUtil.decode(domain);

View File

@ -200,7 +200,7 @@ public class ResourceRecord {
}
private static int nameToValue(String name, String[] names) {
if (name.equals("")) {
if (name.isEmpty()) {
return -1; // invalid name
} else if (name.equals("*")) {
return QTYPE_STAR; // QTYPE_STAR == QCLASS_STAR

View File

@ -124,7 +124,7 @@ class ZoneNode extends NameNode {
* name and its resource records. Returns the zone's new contents.
*/
NameNode populate(DnsName zone, ResourceRecords rrs) {
// assert zone.get(0).equals(""); // zone has root label
// assert zone.get(0).isEmpty(); // zone has root label
// assert (zone.size() == (depth() + 1)); // +1 due to root label
NameNode newContents = new NameNode(null);

View File

@ -230,7 +230,7 @@ class ClassPath {
int i = name.lastIndexOf(File.separatorChar);
subdir = name.substring(0, i + 1);
basename = name.substring(i + 1);
} else if (!subdir.equals("")
} else if (!subdir.isEmpty()
&& !subdir.endsWith(fileSeparatorChar)) {
// zip files are picky about "foo" vs. "foo/".
// also, the getFiles caches are keyed with a trailing /

View File

@ -115,7 +115,7 @@ class Package {
}
private String makeName(String fileName) {
return pkg.equals("") ? fileName : pkg + File.separator + fileName;
return pkg.isEmpty() ? fileName : pkg + File.separator + fileName;
}
/**
@ -153,7 +153,7 @@ class Package {
}
public String toString() {
if (pkg.equals("")) {
if (pkg.isEmpty()) {
return "unnamed package";
}
return "package " + pkg;