< prev index next >
src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java
Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad
@@ -441,11 +441,11 @@
return;
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('=');
if (eq_separator < 0) {
// illegal if no = or is first character
@@ -465,11 +465,11 @@
if (eq_separator < fields[i].length()) {
// = is not in last character
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) " +
"Illegal arguments: fieldName is empty");
}
@@ -498,11 +498,11 @@
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");
}
final String msg = "Fieldname requested is null";
@@ -520,11 +520,11 @@
public synchronized void setField(String fieldName, Object fieldValue)
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");
}
@@ -662,11 +662,11 @@
if (fieldNames == null) {
for (Object value : descriptorMap.values())
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]);
}
}
@@ -698,11 +698,11 @@
final RuntimeException iae = new IllegalArgumentException(msg);
throw new RuntimeOperationsException(iae, msg);
}
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);
}
final String msg = "fieldNames is null or invalid";
@@ -731,11 +731,11 @@
}
return(new DescriptorSupport(this));
}
public synchronized void removeField(String fieldName) {
- if ((fieldName == null) || (fieldName.equals(""))) {
+ if ((fieldName == null) || (fieldName.isEmpty())) {
return;
}
descriptorMap.remove(fieldName);
}
@@ -860,11 +860,11 @@
// must have a name and descriptor type field
String thisName = (String)(this.getFieldValue("name"));
String thisDescType = (String)(getFieldValue("descriptorType"));
if ((thisName == null) || (thisDescType == null) ||
- (thisName.equals("")) || (thisDescType.equals(""))) {
+ (thisName.isEmpty()) || (thisDescType.isEmpty())) {
return false;
}
// According to the descriptor type we validate the fields contained
@@ -910,11 +910,11 @@
// class is not null
// lastReturnedTimeStamp is numeric
private boolean validateField(String fldName, Object fldValue) {
- if ((fldName == null) || (fldName.equals("")))
+ if ((fldName == null) || (fldName.isEmpty()))
return false;
String SfldValue = "";
boolean isAString = false;
if ((fldValue != null) && (fldValue instanceof java.lang.String)) {
SfldValue = (String) fldValue;
@@ -929,11 +929,11 @@
fldName.equalsIgnoreCase("GetMethod") ||
fldName.equalsIgnoreCase("Role") ||
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")) {
long v;
if ((fldValue != null) && (isAString)) {
< prev index next >