use isEmpty

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1925002 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2025-04-10 18:48:01 +00:00
parent b3d0fe52d3
commit 92d4a8d86d
3 changed files with 5 additions and 5 deletions

View File

@ -4644,7 +4644,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
StringBuilder rng = new StringBuilder();
rng.append(c);
if(rng.length() > 0 && r.length() > 0) {
if(rng.length() > 0 && !r.isEmpty()) {
rng.append(',');
}
rng.append(r);

View File

@ -144,13 +144,13 @@ public class XWPFWordExtractor implements POIXMLTextExtractor {
// Add comments
XWPFCommentsDecorator decorator = new XWPFCommentsDecorator(paragraph, null);
String commentText = decorator.getCommentText();
if (commentText.length() > 0) {
if (!commentText.isEmpty()) {
text.append(commentText).append('\n');
}
// Do endnotes and footnotes
String footnameText = paragraph.getFootnoteText();
if (footnameText != null && footnameText.length() > 0) {
if (footnameText != null && !footnameText.isEmpty()) {
text.append(footnameText).append('\n');
}

View File

@ -112,7 +112,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
NodeList kids = t.getDomNode().getChildNodes();
for (int n = 0; n < kids.getLength(); n++) {
if (kids.item(n) instanceof Text) {
if (text.length() > 0) {
if (!text.isEmpty()) {
text.append("\n");
}
text.append(kids.item(n).getNodeValue());
@ -148,7 +148,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/
static void preserveSpaces(XmlString xs) {
String text = xs.getStringValue();
if (text != null && text.length() >= 1
if (text != null && !text.isEmpty()
&& (Character.isWhitespace(text.charAt(0)) || Character.isWhitespace(text.charAt(text.length()-1)))) {
try (XmlCursor c = xs.newCursor()) {
c.toNextToken();