Skip to content

Commit

Permalink
Use String#isEmpty()
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Nov 28, 2023
1 parent 020a5d3 commit bf7c051
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public String getNamespaceURI() {
@Override
public Object getValue() {
final String value = attr.getValue();
if (value == null || value.equals("") && !attr.getSpecified()) {
if (value == null || value.isEmpty() && !attr.getSpecified()) {
return null;
}
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public synchronized NamespaceResolver getNamespaceResolver() {

@Override
public String getNamespaceURI(final String prefix) {
if (prefix == null || prefix.equals("")) {
if (prefix == null || prefix.isEmpty()) {
return getDefaultNamespaceURI();
}

Expand Down Expand Up @@ -263,7 +263,7 @@ public String getNamespaceURI(final String prefix) {
}
aNode = aNode.getParentNode();
}
if (namespace == null || namespace.equals("")) {
if (namespace == null || namespace.isEmpty()) {
namespace = NodePointer.UNKNOWN_NAMESPACE;
}
}
Expand Down Expand Up @@ -299,7 +299,7 @@ public String getDefaultNamespaceURI() {
defaultNamespace = "";
}
// TBD: We are supposed to resolve relative URIs to absolute ones.
return defaultNamespace.equals("") ? null : defaultNamespace;
return defaultNamespace.isEmpty() ? null : defaultNamespace;
}

@Override
Expand Down Expand Up @@ -358,7 +358,7 @@ protected static String findEnclosingAttribute(Node n, final String attrName) {
if (n.getNodeType() == Node.ELEMENT_NODE) {
final Element e = (Element) n;
final String attr = e.getAttribute(attrName);
if (attr != null && !attr.equals("")) {
if (attr != null && !attr.isEmpty()) {
return attr;
}
}
Expand Down Expand Up @@ -387,7 +387,7 @@ public void setValue(final Object value) {
if (node.getNodeType() == Node.TEXT_NODE
|| node.getNodeType() == Node.CDATA_SECTION_NODE) {
final String string = (String) TypeUtils.convert(value, String.class);
if (string != null && !string.equals("")) {
if (string != null && !string.isEmpty()) {
node.setNodeValue(string);
}
else {
Expand Down Expand Up @@ -418,7 +418,7 @@ public void setValue(final Object value) {
}
else {
final String string = (String) TypeUtils.convert(value, String.class);
if (string != null && !string.equals("")) {
if (string != null && !string.isEmpty()) {
final Node textNode =
node.getOwnerDocument().createTextNode(string);
node.appendChild(textNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public QName getName() {
@Override
public String getNamespaceURI() {
String uri = attr.getNamespaceURI();
if (uri != null && uri.equals("")) {
if (uri != null && uri.isEmpty()) {
uri = null;
}
return uri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public QName getName() {
String ln = null;
if (node instanceof Element) {
ns = ((Element) node).getNamespacePrefix();
if (ns != null && ns.equals("")) {
if (ns != null && ns.isEmpty()) {
ns = null;
}
ln = ((Element) node).getName();
Expand Down Expand Up @@ -298,7 +298,7 @@ public Object getValue() {
public void setValue(final Object value) {
if (node instanceof Text) {
final String string = (String) TypeUtils.convert(value, String.class);
if (string != null && !string.equals("")) {
if (string != null && !string.isEmpty()) {
((Text) node).setText(string);
}
else {
Expand Down Expand Up @@ -333,7 +333,7 @@ else if (value instanceof Comment) {
}
else {
final String string = (String) TypeUtils.convert(value, String.class);
if (string != null && !string.equals("")) {
if (string != null && !string.isEmpty()) {
element.addContent(new Text(string));
}
}
Expand Down Expand Up @@ -459,11 +459,11 @@ private static boolean equalStrings(String s1, String s2) {
public static String getPrefix(final Object node) {
if (node instanceof Element) {
final String prefix = ((Element) node).getNamespacePrefix();
return prefix == null || prefix.equals("") ? null : prefix;
return prefix == null || prefix.isEmpty() ? null : prefix;
}
if (node instanceof Attribute) {
final String prefix = ((Attribute) node).getNamespacePrefix();
return prefix == null || prefix.equals("") ? null : prefix;
return prefix == null || prefix.isEmpty() ? null : prefix;
}
return null;
}
Expand Down Expand Up @@ -518,7 +518,7 @@ protected static String findEnclosingAttribute(Object n, final String attrName,
if (n instanceof Element) {
final Element e = (Element) n;
final String attr = e.getAttributeValue(attrName, ns);
if (attr != null && !attr.equals("")) {
if (attr != null && !attr.isEmpty()) {
return attr;
}
}
Expand Down

0 comments on commit bf7c051

Please sign in to comment.