From a5cf0f0d3fff77668f5b62db7850f400ae970269 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Thu, 16 Jul 2020 10:03:00 +0000 Subject: [PATCH] use BigInteger.valueOf git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1879937 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xwpf/usermodel/examples/HeaderFooterTable.java | 2 +- src/java/org/apache/poi/ss/util/MutableFPNumber.java | 2 +- .../org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java | 4 ++-- src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java | 8 ++++---- src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java | 6 +++--- .../java/org/apache/poi/xwpf/usermodel/XWPFTable.java | 2 +- .../org/apache/poi/xwpf/usermodel/TestXWPFRun.java | 2 +- .../org/apache/poi/xwpf/usermodel/TestXWPFTable.java | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/HeaderFooterTable.java b/src/examples/src/org/apache/poi/xwpf/usermodel/examples/HeaderFooterTable.java index 3278f2cb5f..bc40c4d764 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/HeaderFooterTable.java +++ b/src/examples/src/org/apache/poi/xwpf/usermodel/examples/HeaderFooterTable.java @@ -66,7 +66,7 @@ public class HeaderFooterTable { // Now set up a grid for the table, cells will fit into the grid // Each cell width is 3120 in 1440ths of an inch, or 1/3rd of 6.5" - BigInteger w = new BigInteger("3120"); + BigInteger w = BigInteger.valueOf(3120); CTTblGrid grid = ctTbl.addNewTblGrid(); for (int i = 0; i < 3; i++) { CTTblGridCol gridCol = grid.addNewGridCol(); diff --git a/src/java/org/apache/poi/ss/util/MutableFPNumber.java b/src/java/org/apache/poi/ss/util/MutableFPNumber.java index 1facc8801a..38594426b2 100644 --- a/src/java/org/apache/poi/ss/util/MutableFPNumber.java +++ b/src/java/org/apache/poi/ss/util/MutableFPNumber.java @@ -156,7 +156,7 @@ final class MutableFPNumber { * Holds values for quick multiplication and division by 10 */ private static final class TenPower { - private static final BigInteger FIVE = new BigInteger("5"); + private static final BigInteger FIVE = BigInteger.valueOf(5); private static final TenPower[] _cache = new TenPower[350]; public final BigInteger _multiplicand; diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java index 3c014ff78e..46f301bc40 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFVMLDrawing.java @@ -252,8 +252,8 @@ public final class XSSFVMLDrawing extends POIXMLDocumentPart { cldata.addNewSizeWithCells(); cldata.addNewAnchor().setStringValue("1, 15, 0, 2, 3, 15, 3, 16"); cldata.addNewAutoFill().setStringValue("False"); - cldata.addNewRow().setBigIntegerValue(new BigInteger("0")); - cldata.addNewColumn().setBigIntegerValue(new BigInteger("0")); + cldata.addNewRow().setBigIntegerValue(BigInteger.valueOf(0)); + cldata.addNewColumn().setBigIntegerValue(BigInteger.valueOf(0)); _items.add(shape); _qnames.add(QNAME_SHAPE); return shape; diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java index e7e9b8e985..82acbb2817 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java @@ -52,7 +52,7 @@ public class TOC { this.block = block; CTSdtPr sdtPr = block.addNewSdtPr(); CTDecimalNumber id = sdtPr.addNewId(); - id.setVal(new BigInteger("4844945")); + id.setVal(BigInteger.valueOf(4844945)); sdtPr.addNewDocPartObj().addNewDocPartGallery().setVal("Table of contents"); CTSdtEndPr sdtEndPr = block.addNewSdtEndPr(); CTRPr rPr = sdtEndPr.addNewRPr(); @@ -64,8 +64,8 @@ public class TOC { rPr.addNewB().setVal(STOnOff.OFF); rPr.addNewBCs().setVal(STOnOff.OFF); rPr.addNewColor().setVal("auto"); - rPr.addNewSz().setVal(new BigInteger("24")); - rPr.addNewSzCs().setVal(new BigInteger("24")); + rPr.addNewSz().setVal(BigInteger.valueOf(24)); + rPr.addNewSzCs().setVal(BigInteger.valueOf(24)); CTSdtContentBlock content = block.addNewSdtContent(); CTP p = content.addNewP(); p.setRsidR("00EF7E24".getBytes(LocaleUtil.CHARSET_1252)); @@ -90,7 +90,7 @@ public class TOC { CTTabStop tab = tabs.addNewTab(); tab.setVal(STTabJc.RIGHT); tab.setLeader(STTabTlc.DOT); - tab.setPos(new BigInteger("8290")); + tab.setPos(BigInteger.valueOf(8290)); pPr.addNewRPr().addNewNoProof(); CTR run = p.addNewR(); run.addNewRPr().addNewNoProof(); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java index 1d785750a0..c53d7699e2 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java @@ -870,7 +870,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { @Override public int getFontSize() { CTRPr pr = getRunProperties(false); - return (pr != null && pr.isSetSz()) ? pr.getSz().getVal().divide(new BigInteger("2")).intValue() : -1; + return (pr != null && pr.isSetSz()) ? pr.getSz().getVal().divide(BigInteger.valueOf(2)).intValue() : -1; } /** @@ -887,10 +887,10 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { */ @Override public void setFontSize(int size) { - BigInteger bint = new BigInteger(Integer.toString(size)); + BigInteger bint = BigInteger.valueOf(size); CTRPr pr = getRunProperties(true); CTHpsMeasure ctSize = pr.isSetSz() ? pr.getSz() : pr.addNewSz(); - ctSize.setVal(bint.multiply(new BigInteger("2"))); + ctSize.setVal(bint.multiply(BigInteger.valueOf(2))); } /** diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java index b0af94cec2..37713dd1a9 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java @@ -190,7 +190,7 @@ public class XWPFTable implements IBodyElement, ISDTContents { table.addNewTr().addNewTc().addNewP(); CTTblPr tblpro = table.addNewTblPr(); - tblpro.addNewTblW().setW(new BigInteger("0")); + tblpro.addNewTblW().setW(BigInteger.valueOf(0)); tblpro.getTblW().setType(STTblWidth.AUTO); // layout diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java index 846085b512..72013f8985 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java @@ -179,7 +179,7 @@ public class TestXWPFRun { @Test public void testSetGetFontSize() { CTRPr rpr = ctRun.addNewRPr(); - rpr.addNewSz().setVal(new BigInteger("14")); + rpr.addNewSz().setVal(BigInteger.valueOf(14)); XWPFRun run = new XWPFRun(ctRun, irb); assertEquals(7, run.getFontSize()); diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java index 77ba00e0f2..a110d17019 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java @@ -73,8 +73,8 @@ public class TestXWPFTable { XWPFDocument doc = new XWPFDocument(); CTTbl ctTable = CTTbl.Factory.newInstance(); CTTblGrid cttblgrid = ctTable.addNewTblGrid(); - cttblgrid.addNewGridCol().setW(new BigInteger("123")); - cttblgrid.addNewGridCol().setW(new BigInteger("321")); + cttblgrid.addNewGridCol().setW(BigInteger.valueOf(123)); + cttblgrid.addNewGridCol().setW(BigInteger.valueOf(321)); XWPFTable xtab = new XWPFTable(ctTable, doc); assertEquals(123, xtab.getCTTbl().getTblGrid().getGridColArray(0).getW().intValue()); -- 2.39.5