diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-07-17 01:53:18 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-07-17 01:53:18 +0000 |
commit | c589f0ee7a9c5c104244373720ddd6bf0ab68ca9 (patch) | |
tree | 88967bf7b53e347252d69837dbb6cc486dad3973 /poi-scratchpad | |
parent | dc7e2de82eef66051ae7684a9fae15f7540e4460 (diff) | |
download | poi-c589f0ee7a9c5c104244373720ddd6bf0ab68ca9.tar.gz poi-c589f0ee7a9c5c104244373720ddd6bf0ab68ca9.zip |
[github-339] Add extra methods to StringUtil and refactor some code to use them. Thanks to XenoAmess. This closes #339
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902789 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-scratchpad')
3 files changed, 6 insertions, 3 deletions
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/MAPIMessage.java b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/MAPIMessage.java index 5ffa6d0191..23c9bd770d 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/MAPIMessage.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/MAPIMessage.java @@ -53,6 +53,7 @@ import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.CodePageUtil; import org.apache.poi.util.LocaleUtil; +import org.apache.poi.util.StringUtil; import static org.apache.logging.log4j.util.Unbox.box; @@ -630,7 +631,7 @@ public class MAPIMessage extends POIReadOnlyDocument { */ public MESSAGE_CLASS getMessageClassEnum() throws ChunkNotFoundException { String mc = getStringFromChunk(mainChunks.getMessageClass()); - if (mc == null || mc.trim().length() == 0) { + if (StringUtil.isBlank(mc)) { return MESSAGE_CLASS.UNSPECIFIED; } else if (mc.equalsIgnoreCase("IPM.Note")) { return MESSAGE_CLASS.NOTE; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordConverter.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordConverter.java index 1ff262d456..01c4bed4fe 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordConverter.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordConverter.java @@ -52,6 +52,7 @@ import org.apache.poi.hwpf.usermodel.TableRow; import org.apache.poi.poifs.filesystem.Entry; import org.apache.poi.util.Beta; import org.apache.poi.util.Internal; +import org.apache.poi.util.StringUtil; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -553,7 +554,7 @@ public abstract class AbstractWordConverter { } } - haveAnyText |= text.trim().length() != 0; + haveAnyText |= StringUtil.isNotBlank(text); } return haveAnyText; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/WordToFoConverter.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/WordToFoConverter.java index 9bf16aeb03..fb96e1eb36 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/WordToFoConverter.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/WordToFoConverter.java @@ -48,6 +48,7 @@ import org.apache.poi.hwpf.usermodel.Table; import org.apache.poi.hwpf.usermodel.TableCell; import org.apache.poi.hwpf.usermodel.TableRow; import org.apache.poi.util.Beta; +import org.apache.poi.util.StringUtil; import org.apache.poi.util.XMLHelper; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -438,7 +439,7 @@ public class WordToFoConverter extends AbstractWordConverter Text textNode = foDocumentFacade.createText( bulletText ); inline.appendChild( textNode ); - haveAnyText |= bulletText.trim().length() != 0; + haveAnyText |= StringUtil.isNotBlank(bulletText); } haveAnyText = processCharacters( hwpfDocument, currentTableLevel, |