< 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,451 ****
return;
init(null);
for (int i=0; i < fields.length; i++) {
! if ((fields[i] == null) || (fields[i].equals(""))) {
continue;
}
int eq_separator = fields[i].indexOf('=');
if (eq_separator < 0) {
// illegal if no = or is first character
--- 441,451 ----
return;
init(null);
for (int i=0; i < fields.length; i++) {
! 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,475 ****
if (eq_separator < fields[i].length()) {
// = is not in last character
fieldValue = fields[i].substring(eq_separator+1);
}
! if (fieldName.equals("")) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE,
"Descriptor(String... fields) " +
"Illegal arguments: fieldName is empty");
}
--- 465,475 ----
if (eq_separator < fields[i].length()) {
// = is not in last character
fieldValue = fields[i].substring(eq_separator+1);
}
! if (fieldName.isEmpty()) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE,
"Descriptor(String... fields) " +
"Illegal arguments: fieldName is empty");
}
*** 498,508 ****
public synchronized Object getFieldValue(String fieldName)
throws RuntimeOperationsException {
! if ((fieldName == null) || (fieldName.equals(""))) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE,
"Illegal arguments: null field name");
}
final String msg = "Fieldname requested is null";
--- 498,508 ----
public synchronized Object getFieldValue(String fieldName)
throws RuntimeOperationsException {
! 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,530 ****
public synchronized void setField(String fieldName, Object fieldValue)
throws RuntimeOperationsException {
// field name cannot be null or empty
! if ((fieldName == null) || (fieldName.equals(""))) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE,
"Illegal arguments: null or empty field name");
}
--- 520,530 ----
public synchronized void setField(String fieldName, Object fieldValue)
throws RuntimeOperationsException {
// field name cannot be null or empty
! if ((fieldName == null) || (fieldName.isEmpty())) {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE,
"Illegal arguments: null or empty field name");
}
*** 662,672 ****
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(""))) {
responseFields[i] = null;
} else {
responseFields[i] = getFieldValue(fieldNames[i]);
}
}
--- 662,672 ----
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].isEmpty())) {
responseFields[i] = null;
} else {
responseFields[i] = getFieldValue(fieldNames[i]);
}
}
*** 698,708 ****
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 (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";
--- 698,708 ----
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].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,741 ****
}
return(new DescriptorSupport(this));
}
public synchronized void removeField(String fieldName) {
! if ((fieldName == null) || (fieldName.equals(""))) {
return;
}
descriptorMap.remove(fieldName);
}
--- 731,741 ----
}
return(new DescriptorSupport(this));
}
public synchronized void removeField(String fieldName) {
! if ((fieldName == null) || (fieldName.isEmpty())) {
return;
}
descriptorMap.remove(fieldName);
}
*** 860,870 ****
// 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(""))) {
return false;
}
// According to the descriptor type we validate the fields contained
--- 860,870 ----
// 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.isEmpty()) || (thisDescType.isEmpty())) {
return false;
}
// According to the descriptor type we validate the fields contained
*** 910,920 ****
// class is not null
// lastReturnedTimeStamp is numeric
private boolean validateField(String fldName, Object fldValue) {
! if ((fldName == null) || (fldName.equals("")))
return false;
String SfldValue = "";
boolean isAString = false;
if ((fldValue != null) && (fldValue instanceof java.lang.String)) {
SfldValue = (String) fldValue;
--- 910,920 ----
// class is not null
// lastReturnedTimeStamp is numeric
private boolean validateField(String fldName, Object fldValue) {
! if ((fldName == null) || (fldName.isEmpty()))
return false;
String SfldValue = "";
boolean isAString = false;
if ((fldValue != null) && (fldValue instanceof java.lang.String)) {
SfldValue = (String) fldValue;
*** 929,939 ****
fldName.equalsIgnoreCase("GetMethod") ||
fldName.equalsIgnoreCase("Role") ||
fldName.equalsIgnoreCase("Class")) {
if (fldValue == null || !isAString)
return false;
! if (nameOrDescriptorType && SfldValue.equals(""))
return false;
return true;
} else if (fldName.equalsIgnoreCase("visibility")) {
long v;
if ((fldValue != null) && (isAString)) {
--- 929,939 ----
fldName.equalsIgnoreCase("GetMethod") ||
fldName.equalsIgnoreCase("Role") ||
fldName.equalsIgnoreCase("Class")) {
if (fldValue == null || !isAString)
return false;
! if (nameOrDescriptorType && SfldValue.isEmpty())
return false;
return true;
} else if (fldName.equalsIgnoreCase("visibility")) {
long v;
if ((fldValue != null) && (isAString)) {
< prev index next >