try {
// If the core properties part does not exist in the part list,
// we save it as well
- if (this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES).size() == 0 &&
- this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES_ECMA376).size() == 0 ) {
+ if (this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES).isEmpty() &&
+ this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES_ECMA376).isEmpty()) {
LOG.atDebug().log("Save core properties part");
// Ensure that core properties are added if missing
public XSSFBStylesTable getXSSFBStylesTable() throws IOException {
ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFBRelation.STYLES_BINARY.getContentType());
- if(parts.size() == 0) return null;
+ if(parts.isEmpty()) return null;
// Create the Styles Table, and associate the Themes if present
try (InputStream stream = parts.get(0).getInputStream()) {
public SharedStrings getSharedStringsTable() throws IOException, InvalidFormatException {
ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFRelation.SHARED_STRINGS.getContentType());
try {
- return parts.size() == 0 ? null :
+ return parts.isEmpty() ? null :
useReadOnlySharedStringsTable ? new ReadOnlySharedStringsTable(parts.get(0)) :
new SharedStringsTable(parts.get(0));
} catch (SAXException se) {
*/
public StylesTable getStylesTable() throws IOException, InvalidFormatException {
ArrayList<PackagePart> parts = pkg.getPartsByContentType(XSSFRelation.STYLES.getContentType());
- if (parts.size() == 0) return null;
+ if (parts.isEmpty()) return null;
// Create the Styles Table, and associate the Themes if present
StylesTable styles = new StylesTable(parts.get(0));
if(_writer.getNumberOfFlushedRows() > 0) {
return _writer.getLowestIndexOfFlushedRows();
}
- return _rows.size() == 0 ? -1 : _rows.firstKey();
+ return _rows.isEmpty() ? -1 : _rows.firstKey();
}
/**
*/
@Override
public int getLastRowNum() {
- return _rows.size() == 0 ? -1 : _rows.lastKey();
+ return _rows.isEmpty() ? -1 : _rows.lastKey();
}
/**
*/
@Override
public short getFirstCellNum() {
- return (short)(_cells.size() == 0 ? -1 : _cells.firstKey());
+ return (short)(_cells.isEmpty() ? -1 : _cells.firstKey());
}
/**
*/
@Override
public short getLastCellNum() {
- return (short)(_cells.size() == 0 ? -1 : (_cells.lastKey() + 1));
+ return (short)(_cells.isEmpty() ? -1 : (_cells.lastKey() + 1));
}
/**
*/
@Beta
public void copyRows(List<? extends Row> srcRows, int destStartRow, CellCopyPolicy policy) {
- if (srcRows == null || srcRows.size() == 0) {
+ if (srcRows == null || srcRows.isEmpty()) {
throw new IllegalArgumentException("No rows to copy");
}
final Row srcStartRow = srcRows.get(0);
sheets.remove(index);
// only set new sheet if there are still some left
- if(sheets.size() == 0) {
+ if(sheets.isEmpty()) {
return;
}
*/
public XWPFTable createTable() {
XWPFTable table = new XWPFTable(ctFtnEdn.addNewTbl(), this);
- if (bodyElements.size() == 0) {
+ if (bodyElements.isEmpty()) {
XWPFParagraph p = createParagraph();
ensureFootnoteRef(p);
}
*/
private int getBodyElementSpecificPos(int pos, List<? extends IBodyElement> list) {
// If there's nothing to find, skip it
- if (list.size() == 0) {
+ if (list.isEmpty()) {
return -1;
}
@Override
protected void prepareForCommit() {
// must contain at least an empty paragraph
- if (bodyElements.size() == 0) {
+ if (bodyElements.isEmpty()) {
createParagraph();
}
for (XWPFTable tbl : tables) {
for (XWPFTableRow row : tbl.tableRows) {
for (XWPFTableCell cell : row.getTableCells()) {
- if (cell.getBodyElements().size() == 0) {
+ if (cell.getBodyElements().isEmpty()) {
cell.addParagraph();
}
}
/**
* Add a new cell at the end of each row in this table, creating a new column.
* If rows have different numbers of columns, will still append a cell to each row.
- * Currently does not match the width of existing columns.
+ * Currently, does not match the width of existing columns.
*/
public void addNewCol() {
- if (tableRows.size() == 0) {
+ if (tableRows.isEmpty()) {
createRow();
}
for (XWPFTableRow tableRow : tableRows) {
}
public void setText(String text) {
- XWPFParagraph par = (paragraphs.size() == 0) ? addParagraph() : paragraphs.get(0);
+ XWPFParagraph par = paragraphs.isEmpty() ? addParagraph() : paragraphs.get(0);
par.createRun().setText(text);
}
/**
* Testcase for function XLOOKUP()
*/
-public class TestXSSFXLookupFunction {
+class TestXSSFXLookupFunction {
//https://support.microsoft.com/en-us/office/xlookup-function-b7fd680e-6d10-43e6-84f9-88eae8bf5929
}
}
- if ( chpxs.size() == 0 )
+ if ( chpxs.isEmpty() )
{
LOG.atWarn().log("Text piece [{}; {}) has no CHPX. Creating new one.", box(startInclusive),box(boundary));
// create it manually
lastPapxIndex = oldPapxSortedByEndPos.size() - 1;
}
- if ( papxs.size() == 0 )
+ if ( papxs.isEmpty() )
{
LOG.atWarn().log("Paragraph [{}; {}) has no PAPX. Creating new one.", box(startInclusive),box(endExclusive));
// create it manually
private static int binarySearchStart( List<? extends PropertyNode<?>> rpl,
int start )
{
- if ( rpl.size() == 0 )
+ if ( rpl.isEmpty())
return -1;
if ( rpl.get( 0 ).getStart() >= start )
return 0;
}
// Create the extractors
- if(dirs.size() == 0 && nonPOIFS.size() == 0){
+ if(dirs.isEmpty() && nonPOIFS.isEmpty()){
return new POITextExtractor[0];
}
@Override
public int getRecordSize() {
byte[] rawData = getRawData();
- if (escherRecords.size() == 0 && rawData != null) {
+ if (escherRecords.isEmpty() && rawData != null) {
// XXX: It should be possible to derive this without concatenating the array, too.
return rawData.length;
}
public int serialize(int offset, byte[] data)
{
byte[] rawData = getRawData();
- if (getEscherRecords().size() == 0 && rawData != null)
+ if (getEscherRecords().isEmpty() && rawData != null)
{
return writeData( offset, data, rawData );
}
private int getRawDataSize() {
List<EscherRecord> escherRecords = getEscherRecords();
byte[] rawData = getRawData();
- if (escherRecords.size() == 0 && rawData != null)
- {
+ if (escherRecords.isEmpty() && rawData != null) {
return rawData.length;
}
int size = 0;
public void removeFormatRun(FormatRun r) {
field_4_format_runs.remove(r);
- if (field_4_format_runs.size() == 0) {
+ if (field_4_format_runs.isEmpty()) {
field_4_format_runs = null;
field_2_optionflags = richText.clearByte(field_2_optionflags);
}
_sheet.removeRow(hrow.getRowRecord());
// if there are no more rows, then reset first/last
- if(_rows.size() == 0) {
+ if(_rows.isEmpty()) {
_firstrow = -1;
_lastrow = -1;
}
}
private void dropDocument(final POIFSReaderListener listener,
- final DocumentDescriptor descriptor)
- {
+ final DocumentDescriptor descriptor) {
Set<POIFSReaderListener> listeners = chosenDocumentDescriptors.get(descriptor);
listeners.remove(listener);
- if (listeners.size() == 0)
- {
+ if (listeners.isEmpty()) {
chosenDocumentDescriptors.remove(descriptor);
}
}
offset++;
// Chain it
- if (_xbat_blocks.size() == 0) {
+ if (_xbat_blocks.isEmpty()) {
_header.setXBATStart(offset);
} else {
_xbat_blocks.get(_xbat_blocks.size() - 1).setValueAt(
*/
@SuppressWarnings("RegExpRepeatedSpace")
public class CellFormatPart {
- private static final Logger LOG = LogManager.getLogger(CellFormat.class.getName());
+ private static final Logger LOG = LogManager.getLogger(CellFormatPart.class);
static final Map<String, Color> NAMED_COLORS;
}
final Set<ValueAndFormat> avgSet = new LinkedHashSet<>(1);
- avgSet.add(new ValueAndFormat(allValues.size() == 0 ? 0 : total / allValues.size(), null, decimalTextFormat));
+ avgSet.add(new ValueAndFormat(allValues.isEmpty() ? 0 : total / allValues.size(), null, decimalTextFormat));
final double stdDev = allValues.size() <= 1 ? 0 : ((NumberEval) AggregateFunction.STDEV.evaluate(pop, 0, 0)).getNumberValue();
avgSet.add(new ValueAndFormat(stdDev, null, decimalTextFormat));
}
// Join the list of values with the specified delimiter and return
- if (delimiterArgs.size() == 0) {
+ if (delimiterArgs.isEmpty()) {
return new StringEval(String.join("", textValues));
} else if (delimiterArgs.size() == 1) {
String delimiter = laxValueToString(delimiterArgs.get(0));
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
-import java.util.Spliterator;
-import java.util.Spliterators;
import java.util.regex.Matcher;
import java.util.regex.Pattern;