mirror of https://github.com/apache/poi.git
use isEmpty()
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896547 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9345c84194
commit
c8fc960d2d
|
@ -191,7 +191,7 @@ public class ExcelAntTest extends Task{
|
|||
" of " + testCount + " evaluations failed to " +
|
||||
"evaluate correctly.",
|
||||
Project.MSG_ERR );
|
||||
if(showFailureDetail && failureMessages.size() > 0 ) {
|
||||
if(showFailureDetail && !failureMessages.isEmpty()) {
|
||||
for (String failureMessage : failureMessages) {
|
||||
log(failureMessage, Project.MSG_ERR);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class XDDFTextParagraph implements Iterable<XDDFTextRun> {
|
|||
public void setText(String text) {
|
||||
// keep the properties of current last run
|
||||
XmlObject existing = null;
|
||||
if (_runs.size() > 0) {
|
||||
if (!_runs.isEmpty()) {
|
||||
existing = _runs.get(_runs.size() - 1).getProperties().copy();
|
||||
}
|
||||
// remove all runs
|
||||
|
|
|
@ -134,7 +134,7 @@ public class XSLFTextParagraph implements TextParagraph<XSLFShape,XSLFTextParagr
|
|||
public XSLFTextRun addLineBreak(){
|
||||
XSLFLineBreak run = new XSLFLineBreak(_p.addNewBr(), this);
|
||||
CTTextCharacterProperties brProps = run.getRPr(true);
|
||||
if(_runs.size() > 0){
|
||||
if (!_runs.isEmpty()) {
|
||||
// by default line break has the font size of the last text run
|
||||
CTTextCharacterProperties prevRun = _runs.get(_runs.size() - 1).getRPr(true);
|
||||
brProps.set(prevRun);
|
||||
|
|
|
@ -66,7 +66,7 @@ public class XSSFBSharedStringsTable implements SharedStrings {
|
|||
pkg.getPartsByContentType(XSSFBRelation.SHARED_STRINGS_BINARY.getContentType());
|
||||
|
||||
// Some workbooks have no shared strings table.
|
||||
if (parts.size() > 0) {
|
||||
if (!parts.isEmpty()) {
|
||||
PackagePart sstPart = parts.get(0);
|
||||
try (InputStream stream = sstPart.getInputStream()) {
|
||||
readFrom(stream);
|
||||
|
|
|
@ -226,7 +226,7 @@ public class XSSFBSheetHandler extends XSSFBParser {
|
|||
|
||||
private void outputHeaderFooter(XSSFBHeaderFooter headerFooter) {
|
||||
String text = headerFooter.getString();
|
||||
if (text != null && text.trim().length() > 0) {
|
||||
if (text != null && !text.trim().isEmpty()) {
|
||||
handler.headerFooter(text, headerFooter.isHeader(), headerFooter.getHeaderFooterTypeLabel());
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ public class XSSFBSheetHandler extends XSSFBParser {
|
|||
return;
|
||||
}
|
||||
Queue<CellAddress> queue = comments.getAddresses();
|
||||
while (queue.size() > 0) {
|
||||
while (!queue.isEmpty()) {
|
||||
CellAddress cellAddress = queue.peek();
|
||||
if (cellAddress.getRow() == currentRow && cellAddress.getColumn() < colNum) {
|
||||
cellAddress = queue.remove();
|
||||
|
@ -261,7 +261,7 @@ public class XSSFBSheetHandler extends XSSFBParser {
|
|||
}
|
||||
Queue<CellAddress> queue = comments.getAddresses();
|
||||
int lastInterpolatedRow = -1;
|
||||
while (queue.size() > 0) {
|
||||
while (!queue.isEmpty()) {
|
||||
CellAddress cellAddress = queue.peek();
|
||||
if (currentRow == CHECK_ALL_ROWS || cellAddress.getRow() < currentRow) {
|
||||
cellAddress = queue.remove();
|
||||
|
|
|
@ -129,7 +129,7 @@ public class ReadOnlySharedStringsTable extends DefaultHandler implements Shared
|
|||
pkg.getPartsByContentType(XSSFRelation.SHARED_STRINGS.getContentType());
|
||||
|
||||
// Some workbooks have no shared strings table.
|
||||
if (parts.size() > 0) {
|
||||
if (!parts.isEmpty()) {
|
||||
PackagePart sstPart = parts.get(0);
|
||||
try (InputStream stream = sstPart.getInputStream()) {
|
||||
readFrom(stream);
|
||||
|
|
|
@ -693,7 +693,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
|
|||
styleSheet.setBorders(ctBorders);
|
||||
|
||||
// Xfs
|
||||
if(xfs.size() > 0) {
|
||||
if (!xfs.isEmpty()) {
|
||||
CTCellXfs ctXfs = styleSheet.getCellXfs();
|
||||
if (ctXfs == null) {
|
||||
ctXfs = CTCellXfs.Factory.newInstance();
|
||||
|
@ -706,7 +706,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
|
|||
}
|
||||
|
||||
// Style xfs
|
||||
if(styleXfs.size() > 0) {
|
||||
if (!styleXfs.isEmpty()) {
|
||||
CTCellStyleXfs ctSXfs = styleSheet.getCellStyleXfs();
|
||||
if (ctSXfs == null) {
|
||||
ctSXfs = CTCellStyleXfs.Factory.newInstance();
|
||||
|
@ -719,7 +719,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
|
|||
}
|
||||
|
||||
// Style dxfs
|
||||
if(dxfs.size() > 0) {
|
||||
if (!dxfs.isEmpty()) {
|
||||
CTDxfs ctDxfs = styleSheet.getDxfs();
|
||||
if (ctDxfs == null) {
|
||||
ctDxfs = CTDxfs.Factory.newInstance();
|
||||
|
|
|
@ -3632,7 +3632,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
|
|||
}
|
||||
|
||||
// Now re-generate our CTHyperlinks, if needed
|
||||
if(hyperlinks.size() > 0) {
|
||||
if (!hyperlinks.isEmpty()) {
|
||||
if(worksheet.getHyperlinks() == null) {
|
||||
worksheet.addNewHyperlinks();
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
|
|||
public XSSFTextRun addLineBreak(){
|
||||
CTTextLineBreak br = _p.addNewBr();
|
||||
CTTextCharacterProperties brProps = br.addNewRPr();
|
||||
if(_runs.size() > 0){
|
||||
if (!_runs.isEmpty()) {
|
||||
// by default line break has the font size of the last text run
|
||||
CTTextCharacterProperties prevRun = _runs.get(_runs.size() - 1).getRPr();
|
||||
brProps.set(prevRun);
|
||||
|
|
|
@ -1741,7 +1741,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
|
|||
*/
|
||||
private void saveNamedRanges(){
|
||||
// Named ranges
|
||||
if(namedRanges.size() > 0) {
|
||||
if (!namedRanges.isEmpty()) {
|
||||
CTDefinedNames names = CTDefinedNames.Factory.newInstance();
|
||||
CTDefinedName[] nr = new CTDefinedName[namedRanges.size()];
|
||||
int i = 0;
|
||||
|
|
|
@ -68,7 +68,7 @@ public class XWPFEndnote extends XWPFAbstractFootnoteEndnote {
|
|||
public void ensureFootnoteRef(XWPFParagraph p) {
|
||||
|
||||
XWPFRun r = null;
|
||||
if (p.getRuns().size() > 0) {
|
||||
if (!p.runsIsEmpty()) {
|
||||
r = p.getRuns().get(0);
|
||||
}
|
||||
if (r == null) {
|
||||
|
|
|
@ -63,7 +63,7 @@ public class XWPFFootnote extends XWPFAbstractFootnoteEndnote {
|
|||
public void ensureFootnoteRef(XWPFParagraph p) {
|
||||
|
||||
XWPFRun r = null;
|
||||
if (p.getRuns().size() > 0) {
|
||||
if (!p.runsIsEmpty()) {
|
||||
r = p.getRuns().get(0);
|
||||
}
|
||||
if (r == null) {
|
||||
|
|
|
@ -180,6 +180,10 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
|
|||
return Collections.unmodifiableList(runs);
|
||||
}
|
||||
|
||||
public boolean runsIsEmpty() {
|
||||
return runs.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return literal runs and sdt/content control objects.
|
||||
*/
|
||||
|
|
|
@ -641,7 +641,7 @@ public final class TestXSSFExportToXML {
|
|||
void testBug59026() throws Exception {
|
||||
try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("59026.xlsx")) {
|
||||
Collection<XSSFMap> mappings = wb.getCustomXMLMappings();
|
||||
assertTrue(mappings.size() > 0);
|
||||
assertFalse(mappings.isEmpty());
|
||||
for (XSSFMap map : mappings) {
|
||||
XSSFExportToXml exporter = new XSSFExportToXml(map);
|
||||
|
||||
|
|
|
@ -906,7 +906,7 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
|
|||
|
||||
// Add the new picture in
|
||||
int offset = 0;
|
||||
if (_pictures.size() > 0) {
|
||||
if (!_pictures.isEmpty()) {
|
||||
HSLFPictureData prev = _pictures.get(_pictures.size() - 1);
|
||||
offset = prev.getOffset() + prev.getBseSize();
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||
ByteChunk htmlBodyBinaryChunk = mainChunks.getHtmlBodyChunkBinary();
|
||||
if (htmlBodyBinaryChunk != null) {
|
||||
List<PropertyValue> cpid = mainChunks.getProperties().get(MAPIProperty.INTERNET_CPID);
|
||||
if (cpid != null && cpid.size() > 0) {
|
||||
if (cpid != null && !cpid.isEmpty()) {
|
||||
int codepage = ((LongPropertyValue) cpid.get(0)).getValue();
|
||||
try {
|
||||
String encoding = CodePageUtil.codepageToEncoding(codepage, true);
|
||||
|
@ -423,7 +423,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||
// General codepage: Message codepage property.
|
||||
//
|
||||
List<PropertyValue> val = mainChunks.getProperties().get(MAPIProperty.MESSAGE_CODEPAGE);
|
||||
if (val != null && val.size() > 0) {
|
||||
if (val != null && !val.isEmpty()) {
|
||||
int codepage = ((LongPropertyValue) val.get(0)).getValue();
|
||||
try {
|
||||
String encoding = CodePageUtil.codepageToEncoding(codepage, true);
|
||||
|
@ -437,7 +437,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||
//
|
||||
if (generalcodepage == null) {
|
||||
val = mainChunks.getProperties().get(MAPIProperty.MESSAGE_LOCALE_ID);
|
||||
if (val != null && val.size() > 0) {
|
||||
if (val != null && !val.isEmpty()) {
|
||||
int lcid = ((LongPropertyValue) val.get(0)).getValue();
|
||||
int codepage = LocaleUtil.getDefaultCodePageFromLCID(lcid);
|
||||
try {
|
||||
|
@ -476,7 +476,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||
// UTF-8 is ignored for text body. This seems to be a special Outlook behavior.
|
||||
//
|
||||
val = mainChunks.getProperties().get(MAPIProperty.INTERNET_CPID);
|
||||
if (val != null && val.size() > 0) {
|
||||
if (val != null && !val.isEmpty()) {
|
||||
int codepage = ((LongPropertyValue) val.get(0)).getValue();
|
||||
try {
|
||||
String encoding = CodePageUtil.codepageToEncoding(codepage, true);
|
||||
|
@ -644,7 +644,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
|
|||
MAPIProperty.CREATION_TIME
|
||||
}) {
|
||||
List<PropertyValue> val = mainChunks.getProperties().get(prop);
|
||||
if (val != null && val.size() > 0) {
|
||||
if (val != null && !val.isEmpty()) {
|
||||
return ((TimePropertyValue)val.get(0)).getValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ public final class HSSFChart {
|
|||
} else if(r instanceof SeriesTextRecord) {
|
||||
// Applies to a series, unless we've seen a legend already
|
||||
SeriesTextRecord str = (SeriesTextRecord)r;
|
||||
if(lastChart.legendRecord == null && lastChart.series.size() > 0) {
|
||||
if(lastChart.legendRecord == null && !lastChart.series.isEmpty()) {
|
||||
HSSFSeries series = lastChart.series.get(lastChart.series.size()-1);
|
||||
series.seriesTitleText = str;
|
||||
} else {
|
||||
|
|
|
@ -300,7 +300,7 @@ public final class HSSFSheet implements Sheet {
|
|||
}
|
||||
}
|
||||
|
||||
if (_rows.size() > 0) {
|
||||
if (!_rows.isEmpty()) {
|
||||
Integer key = Integer.valueOf(row.getRowNum());
|
||||
HSSFRow removedRow = _rows.remove(key);
|
||||
if (removedRow != row) {
|
||||
|
|
|
@ -189,7 +189,7 @@ public class DirectoryProperty extends Property implements Parent, Iterable<Prop
|
|||
*/
|
||||
protected void preWrite()
|
||||
{
|
||||
if (_children.size() > 0)
|
||||
if (!_children.isEmpty())
|
||||
{
|
||||
Property[] children = _children.toArray(new Property[ 0 ]);
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ public class CellNumberFormatter extends CellFormatter {
|
|||
first = false;
|
||||
}
|
||||
}
|
||||
if (fractionalSpecials.size() > 0) {
|
||||
if (!fractionalSpecials.isEmpty()) {
|
||||
fmtBuf.append('.');
|
||||
for (Special s : fractionalSpecials) {
|
||||
if (isDigitFmt(s)) {
|
||||
|
@ -822,7 +822,7 @@ public class CellNumberFormatter extends CellFormatter {
|
|||
private void writeFractional(StringBuffer result, StringBuffer output) {
|
||||
int digit;
|
||||
int strip;
|
||||
if (fractionalSpecials.size() > 0) {
|
||||
if (!fractionalSpecials.isEmpty()) {
|
||||
String decimalSeparator = Character.toString(getDecimalFormatSymbols().getDecimalSeparator());
|
||||
digit = result.indexOf(decimalSeparator) + 1;
|
||||
if (exponent != null) {
|
||||
|
|
|
@ -49,7 +49,7 @@ public class CellNumberPartHandler implements PartHandler {
|
|||
// See comment in writeScientific -- exponent handling is complex.
|
||||
// (1) When parsing the format, remove the sign from after the 'e' and
|
||||
// put it before the first digit of the exponent.
|
||||
if (exponent == null && specials.size() > 0) {
|
||||
if (exponent == null && !specials.isEmpty()) {
|
||||
exponent = new Special('.', pos);
|
||||
specials.add(exponent);
|
||||
insertSignForExponent = part.charAt(1);
|
||||
|
@ -73,7 +73,7 @@ public class CellNumberPartHandler implements PartHandler {
|
|||
break;
|
||||
|
||||
case '.':
|
||||
if (decimalPoint == null && specials.size() > 0) {
|
||||
if (decimalPoint == null && !specials.isEmpty()) {
|
||||
decimalPoint = new Special('.', pos);
|
||||
specials.add(decimalPoint);
|
||||
}
|
||||
|
|
|
@ -357,7 +357,7 @@ final class TestPOIFSFileSystem {
|
|||
dis.reset();
|
||||
}
|
||||
}
|
||||
assertTrue(props.size() > 0);
|
||||
assertFalse(props.isEmpty());
|
||||
}
|
||||
}
|
||||
return count;
|
||||
|
|
Loading…
Reference in New Issue