code refactor

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1925646 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2025-05-17 15:57:29 +00:00
parent 62b351cbeb
commit b76bbc866e
5 changed files with 12 additions and 9 deletions

View File

@ -59,7 +59,7 @@ public final class Word2Forrest
{
Paragraph p = r.getParagraph (x);
String text = p.text ();
if (text.trim ().length () == 0)
if (text.trim().isEmpty())
{
continue;
}

View File

@ -608,7 +608,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
}
// remove any remaining illegal references in _rows.cArray
while(_row.getCArray().length > _cells.size()) {
while(_row.sizeOfCArray() > _cells.size()) {
_row.removeC(_cells.size());
}
}

View File

@ -1155,7 +1155,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
* @return the LastParagraph of the document
*/
public XWPFParagraph getLastParagraph() {
int lastPos = paragraphs.toArray().length - 1;
final int lastPos = paragraphs.size() - 1;
return paragraphs.get(lastPos);
}

View File

@ -203,7 +203,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
if (run instanceof XWPFRun) {
XWPFRun xRun = (XWPFRun) run;
// don't include the text if reviewing is enabled and this is a deleted run
if (xRun.getCTR().getDelTextArray().length == 0) {
if (xRun.getCTR().sizeOfDelTextArray() == 0) {
out.append(xRun);
}
} else if (run instanceof XWPFSDT) {

View File

@ -83,11 +83,14 @@ public final class PropertyTable implements BATManaged {
for (ByteBuffer bb : dataSource) {
// Turn it into an array
byte[] data;
if (bb.hasArray() && bb.arrayOffset() == 0 &&
bb.array().length == _bigBigBlockSize.getBigBlockSize()) {
data = bb.array();
} else {
byte[] data = null;
if (bb.hasArray() && bb.arrayOffset() == 0) {
final byte[] array = bb.array();
if (array.length == _bigBigBlockSize.getBigBlockSize()) {
data = array;
}
}
if (data == null) {
data = IOUtils.safelyAllocate(_bigBigBlockSize.getBigBlockSize(), POIFSFileSystem.getMaxRecordLength());
int toRead = data.length;