diff options
Diffstat (limited to 'src')
35 files changed, 130 insertions, 65 deletions
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/EmbeddedObjects.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/EmbeddedObjects.java index 7cfedc1152..9c9d0bce6f 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/EmbeddedObjects.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/EmbeddedObjects.java @@ -30,7 +30,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** * Demonstrates how you can extract embedded data from a .xls file */ -@SuppressWarnings({"java:S106","java:S4823"}) +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class EmbeddedObjects { private EmbeddedObjects() {} diff --git a/src/examples/src/org/apache/poi/hwpf/Word2Forrest.java b/src/examples/src/org/apache/poi/hwpf/Word2Forrest.java index e773efb5d1..b26f3c1675 100644 --- a/src/examples/src/org/apache/poi/hwpf/Word2Forrest.java +++ b/src/examples/src/org/apache/poi/hwpf/Word2Forrest.java @@ -32,6 +32,7 @@ import org.apache.poi.hwpf.usermodel.CharacterRun; import org.apache.poi.hwpf.usermodel.Paragraph; import org.apache.poi.hwpf.usermodel.Range; +@SuppressWarnings({"java:S106","java:S4823"}) public final class Word2Forrest { Writer _out; diff --git a/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java b/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java index a9f2592331..05a8a78121 100644 --- a/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java +++ b/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java @@ -199,6 +199,7 @@ import org.apache.poi.util.IOUtils; * 2mm have been noted in testing. Further investigation will * continue to rectify this issue. */ +@SuppressWarnings({"java:S106","java:S4823"}) public class AddDimensionedImage { // Four constants that determine how - and indeed whether - the rows diff --git a/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java b/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java index fbbcab895d..0e35509e28 100644 --- a/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java +++ b/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java @@ -45,8 +45,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; * * @author Yegor Kozlov */ -@SuppressWarnings("java:S1192") -public class BusinessPlan { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class BusinessPlan { private static final String[] titles = { "ID", "Project Name", "Owner", "Days", "Start", "End"}; @@ -88,6 +88,8 @@ public class BusinessPlan { null, null, null, null, null, "x", null, null, null, null, null}, }; + private BusinessPlan() {} + public static void main(String[] args) throws Exception { Workbook wb; diff --git a/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java b/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java index bd7a95d05f..108cc25962 100644 --- a/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java +++ b/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java @@ -17,16 +17,26 @@ package org.apache.poi.ss.examples; -import org.apache.poi.xssf.usermodel.*; -import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.ss.usermodel.*; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; - import java.io.FileOutputStream; import java.util.Calendar; -import java.util.Map; import java.util.HashMap; +import java.util.Map; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.PrintSetup; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * A monthly calendar created using Apache POI. Each month is on a separate sheet. @@ -37,7 +47,8 @@ import java.util.HashMap; * * @author Yegor Kozlov */ -public class CalendarDemo { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class CalendarDemo { private static final String[] days = { "Sunday", "Monday", "Tuesday", @@ -47,6 +58,8 @@ public class CalendarDemo { "January", "February", "March","April", "May", "June","July", "August", "September","October", "November", "December"}; + private CalendarDemo() {} + public static void main(String[] args) throws Exception { Calendar calendar = Calendar.getInstance(); diff --git a/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java b/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java index e66e6b4c56..4729c9fb53 100644 --- a/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java +++ b/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java @@ -37,12 +37,15 @@ import org.apache.poi.xssf.usermodel.XSSFFont; /** * Demonstrates how to read excel styles for cells */ -public class CellStyleDetails { +@SuppressWarnings({"java:S106","java:S4823"}) +public final class CellStyleDetails { + private CellStyleDetails() {} + public static void main(String[] args) throws Exception { if(args.length == 0) { throw new IllegalArgumentException("Filename must be given"); } - + try (Workbook wb = WorkbookFactory.create(new File(args[0]))) { DataFormatter formatter = new DataFormatter(); @@ -82,7 +85,7 @@ public class CellStyleDetails { } } } - + private static String renderColor(Color color) { if(color instanceof HSSFColor) { return ((HSSFColor)color).getHexString(); diff --git a/src/examples/src/org/apache/poi/ss/examples/ConditionalFormats.java b/src/examples/src/org/apache/poi/ss/examples/ConditionalFormats.java index 28a861b6c2..ff26f9d17d 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ConditionalFormats.java +++ b/src/examples/src/org/apache/poi/ss/examples/ConditionalFormats.java @@ -57,8 +57,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; * http://www.contextures.com/xlcondformat03.html * </p> */ -@SuppressWarnings("java:S1192") -public class ConditionalFormats { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class ConditionalFormats { + + private ConditionalFormats() {} /** * generates a sample workbook with conditional formatting, diff --git a/src/examples/src/org/apache/poi/ss/examples/DrawingBorders.java b/src/examples/src/org/apache/poi/ss/examples/DrawingBorders.java index e23fdb7360..8a4ad94e1e 100644 --- a/src/examples/src/org/apache/poi/ss/examples/DrawingBorders.java +++ b/src/examples/src/org/apache/poi/ss/examples/DrawingBorders.java @@ -36,13 +36,16 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * Excel Border Drawing - examples - * + * * <p> * Partly based on the code snippets from * org.apache.poi.ss.examples.ConditionalFormats * </p> */ -public class DrawingBorders { +@SuppressWarnings({"java:S106","java:S4823"}) +public final class DrawingBorders { + + private DrawingBorders() {} public static void main(String[] args) throws IOException { try (Workbook wb = (args.length > 0 && args[0].equals("-xls")) diff --git a/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java b/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java index 4dfd6f5302..f2cd249ef4 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java +++ b/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java @@ -80,7 +80,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; * } * </pre> */ -@SuppressWarnings("java:S1192") +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public class ExcelComparator { private static final String CELL_DATA_DOES_NOT_MATCH = "Cell Data does not Match ::"; diff --git a/src/examples/src/org/apache/poi/ss/examples/LoadEmbedded.java b/src/examples/src/org/apache/poi/ss/examples/LoadEmbedded.java index 4fd640ca70..34313b07b9 100644 --- a/src/examples/src/org/apache/poi/ss/examples/LoadEmbedded.java +++ b/src/examples/src/org/apache/poi/ss/examples/LoadEmbedded.java @@ -43,12 +43,15 @@ import org.apache.xmlbeans.XmlException; * Loads embedded resources from Workbooks. Code taken from the website: * https://poi.apache.org/spreadsheet/quick-guide.html#Embedded */ -public class LoadEmbedded { - public static void main(String[] args) throws IOException, EncryptedDocumentException, OpenXML4JException, XmlException { +@SuppressWarnings({"java:S106","java:S4823"}) +public final class LoadEmbedded { + private LoadEmbedded() {} + + public static void main(String[] args) throws IOException, EncryptedDocumentException, OpenXML4JException, XmlException { Workbook wb = WorkbookFactory.create(new File(args[0])); loadEmbedded(wb); } - + public static void loadEmbedded(Workbook wb) throws IOException, InvalidFormatException, OpenXML4JException, XmlException { if (wb instanceof HSSFWorkbook) { loadEmbedded((HSSFWorkbook)wb); @@ -60,7 +63,7 @@ public class LoadEmbedded { throw new IllegalArgumentException(wb.getClass().getName()); } } - + public static void loadEmbedded(HSSFWorkbook workbook) throws IOException { for (HSSFObjectData obj : workbook.getAllEmbeddedObjects()) { //the OLE2 Class Name of the object @@ -92,7 +95,7 @@ public class LoadEmbedded { } } } - + public static void loadEmbedded(XSSFWorkbook workbook) throws IOException, InvalidFormatException, OpenXML4JException, XmlException { for (PackagePart pPart : workbook.getAllEmbeddedParts()) { String contentType = pPart.getContentType(); diff --git a/src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java b/src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java index 4714090bf1..079b782b14 100644 --- a/src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java +++ b/src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java @@ -45,8 +45,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; * * @author Yegor Kozlov */ -@SuppressWarnings("java:S1192") -public class LoanCalculator { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class LoanCalculator { + + private LoanCalculator() {} public static void main(String[] args) throws Exception { Workbook wb; diff --git a/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java b/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java index 8484c0998c..05776bee3e 100644 --- a/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java +++ b/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java @@ -42,8 +42,10 @@ import org.apache.poi.ss.util.CellReference; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -@SuppressWarnings("java:S1192") -public class SSPerformanceTest { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class SSPerformanceTest { + private SSPerformanceTest() {} + public static void main(String[] args) throws IOException { if (args.length < 4) { usage("need at least four command arguments"); diff --git a/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java b/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java index 5d65bd3539..5829454ec2 100644 --- a/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java +++ b/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java @@ -44,18 +44,20 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; * * @author Yegor Kozlov */ -@SuppressWarnings("java:S1192") -public class TimesheetDemo { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class TimesheetDemo { private static final String[] titles = { "Person", "ID", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Total\nHrs", "Overtime\nHrs", "Regular\nHrs" }; - private static Object[][] sample_data = { + private static final Object[][] sample_data = { {"Yegor Kozlov", "YK", 5.0, 8.0, 10.0, 5.0, 5.0, 7.0, 6.0}, {"Gisella Bronzetti", "GB", 4.0, 3.0, 1.0, 3.5, null, null, 4.0}, }; + private TimesheetDemo() {} + public static void main(String[] args) throws Exception { Workbook wb; diff --git a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java index 408a6a3ff3..a5f8bf5421 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java +++ b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java @@ -129,6 +129,7 @@ import org.apache.poi.ss.usermodel.WorkbookFactory; * either obeying Excel's or UNIX formatting * conventions. */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public class ToCSV { private Workbook workbook; diff --git a/src/examples/src/org/apache/poi/ss/examples/formula/CheckFunctionsSupported.java b/src/examples/src/org/apache/poi/ss/examples/formula/CheckFunctionsSupported.java index 0e32c29116..d2291f009d 100644 --- a/src/examples/src/org/apache/poi/ss/examples/formula/CheckFunctionsSupported.java +++ b/src/examples/src/org/apache/poi/ss/examples/formula/CheckFunctionsSupported.java @@ -45,6 +45,7 @@ import org.apache.poi.ss.util.CellReference; * files using Apache POI, along with how to handle errors whilst * doing so. */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public class CheckFunctionsSupported { public static void main(String[] args) throws Exception { if (args.length < 1) { @@ -96,8 +97,8 @@ public class CheckFunctionsSupported { } } - private Workbook workbook; - private FormulaEvaluator evaluator; + private final Workbook workbook; + private final FormulaEvaluator evaluator; public CheckFunctionsSupported(Workbook workbook) { this.workbook = workbook; this.evaluator = workbook.getCreationHelper().createFormulaEvaluator(); diff --git a/src/examples/src/org/apache/poi/ss/examples/formula/UserDefinedFunctionExample.java b/src/examples/src/org/apache/poi/ss/examples/formula/UserDefinedFunctionExample.java index a76dbebf1d..7f5922b02a 100644 --- a/src/examples/src/org/apache/poi/ss/examples/formula/UserDefinedFunctionExample.java +++ b/src/examples/src/org/apache/poi/ss/examples/formula/UserDefinedFunctionExample.java @@ -16,11 +16,11 @@ ==================================================================== */ package org.apache.poi.ss.examples.formula; -import java.io.File ; +import java.io.File; -import org.apache.poi.ss.formula.functions.FreeRefFunction ; -import org.apache.poi.ss.formula.udf.DefaultUDFFinder ; -import org.apache.poi.ss.formula.udf.UDFFinder ; +import org.apache.poi.ss.formula.functions.FreeRefFunction; +import org.apache.poi.ss.formula.udf.DefaultUDFFinder; +import org.apache.poi.ss.formula.udf.UDFFinder; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellValue; import org.apache.poi.ss.usermodel.FormulaEvaluator; @@ -28,26 +28,29 @@ import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; -import org.apache.poi.ss.util.CellReference ; +import org.apache.poi.ss.util.CellReference; /** * An example class of how to invoke a User Defined Function for a given * XLS instance using POI's UDFFinder implementation. */ -public class UserDefinedFunctionExample { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class UserDefinedFunctionExample { + + private UserDefinedFunctionExample() {} + + public static void main(String[] args ) throws Exception { - public static void main( String[] args ) throws Exception { - if( args.length != 2 ) { // e.g. src/examples/src/org/apache/poi/ss/examples/formula/mortgage-calculation.xls Sheet1!B4 System.out.println( "usage: UserDefinedFunctionExample fileName cellId" ) ; return; } - + System.out.println( "fileName: " + args[0] ) ; System.out.println( "cell: " + args[1] ) ; - + File workbookFile = new File( args[0] ) ; try (Workbook workbook = WorkbookFactory.create(workbookFile, null, true)) { diff --git a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java b/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java index 874bce4d76..15fdc2af58 100644 --- a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java +++ b/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java @@ -53,8 +53,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; * This example shows how to display a spreadsheet in HTML using the classes for * spreadsheet display. */ -@SuppressWarnings("java:S1192") -public class ToHtml { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class ToHtml { private final Workbook wb; private final Appendable output; private boolean completeHTML; diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java b/src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java index ce17c668cb..d717e37ab0 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java +++ b/src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java @@ -41,6 +41,7 @@ import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource; /** * Build a bar chart from a template pptx */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class BarChartDemo { private BarChartDemo() {} diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java b/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java index 5fee24e363..eb007fc09b 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java +++ b/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java @@ -49,6 +49,7 @@ import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis; /** * Build a chart without reading template file */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class ChartFromScratch { private ChartFromScratch() {} diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java b/src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java index 806735c4a8..543726a48b 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java +++ b/src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java @@ -14,7 +14,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ==================================================================== + * ==================================================================== */ package org.apache.poi.xslf.usermodel; @@ -25,16 +25,16 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; -import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.openxml4j.opc.PackagePart; /** * Demonstrates how you can extract data from a .pptx file */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class DataExtraction { private DataExtraction() {} - public static void main(String[] args) throws IOException, OpenXML4JException { + public static void main(String[] args) throws IOException { PrintStream out = System.out; @@ -42,7 +42,7 @@ public final class DataExtraction { out.println("Input file is required"); return; } - + FileInputStream is = new FileInputStream(args[0]); try (XMLSlideShow ppt = new XMLSlideShow(is)) { is.close(); diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/MergePresentations.java b/src/examples/src/org/apache/poi/xslf/usermodel/MergePresentations.java index a4c241e30c..e295ffd1ee 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/MergePresentations.java +++ b/src/examples/src/org/apache/poi/xslf/usermodel/MergePresentations.java @@ -14,7 +14,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ==================================================================== + * ==================================================================== */ package org.apache.poi.xslf.usermodel; @@ -25,6 +25,7 @@ import java.io.FileOutputStream; /** * Merge multiple pptx presentations together */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class MergePresentations { private MergePresentations() {} diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java b/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java index ce920709e6..15036a874f 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java +++ b/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java @@ -38,6 +38,7 @@ import org.apache.poi.xddf.usermodel.chart.XDDFPieChartData; /** * Build a pie chart from a template pptx */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class PieChartDemo { private PieChartDemo() {} diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step1.java b/src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step1.java index c74046b45d..6651bcc4f8 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step1.java +++ b/src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step1.java @@ -31,6 +31,7 @@ import org.apache.poi.xslf.usermodel.XSLFTextShape; /** * Reading a .pptx presentation and printing basic shape properties */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class Step1 { private Step1() {} diff --git a/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java b/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java index 85300de6f4..8540cb237b 100644 --- a/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java +++ b/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java @@ -61,10 +61,11 @@ import org.xml.sax.XMLReader; * For a more advanced implementation of SAX event parsing * of XLSX files, see {@link XSSFEventBasedExcelExtractor} * and {@link XSSFSheetXMLHandler}. Note that for many cases, - * it may be possible to simply use those with a custom + * it may be possible to simply use those with a custom * {@link SheetContentsHandler} and no SAX code needed of * your own! */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public class XLSX2CSV { /** * Uses the XSSF Event SAX helpers to do most of the work @@ -75,7 +76,7 @@ public class XLSX2CSV { private boolean firstCellOfRow; private int currentRow = -1; private int currentCol = -1; - + private void outputMissingRows(int number) { for (int i=0; i<number; i++) { for (int j=0; j<minColumns; j++) { @@ -125,7 +126,7 @@ public class XLSX2CSV { output.append(','); } currentCol = thisCol; - + // Number or string? try { //noinspection ResultOfMethodCallIgnored @@ -183,7 +184,7 @@ public class XLSX2CSV { public void processSheet( Styles styles, SharedStrings strings, - SheetContentsHandler sheetHandler, + SheetContentsHandler sheetHandler, InputStream sheetInputStream) throws IOException, SAXException { DataFormatter formatter = new DataFormatter(); InputSource sheetSource = new InputSource(sheetInputStream); diff --git a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java b/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java index f45cac0a91..154a5a80ae 100644 --- a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java +++ b/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java @@ -42,6 +42,7 @@ import org.xml.sax.helpers.DefaultHandler; * See {@link XLSX2CSV} for a fuller example of doing * XSLX processing with the XSSF Event code. */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public class FromHowTo { public void processFirstSheet(String filename) throws Exception { try (OPCPackage pkg = OPCPackage.open(filename, PackageAccess.READ)) { diff --git a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/LoadPasswordProtectedXlsxStreaming.java b/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/LoadPasswordProtectedXlsxStreaming.java index 2e7df6c441..7a3ad6b022 100644 --- a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/LoadPasswordProtectedXlsxStreaming.java +++ b/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/LoadPasswordProtectedXlsxStreaming.java @@ -35,10 +35,10 @@ import org.apache.poi.xssf.usermodel.examples.LoadPasswordProtectedXlsx; * <li><code>AesZipFileZipEntrySource</code> is used to ensure that temp files are encrypted. * </ul><p> */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class LoadPasswordProtectedXlsxStreaming { - private LoadPasswordProtectedXlsxStreaming() { - } + private LoadPasswordProtectedXlsxStreaming() {} public static void main(String[] args) throws Exception { LoadPasswordProtectedXlsx.execute(args, LoadPasswordProtectedXlsxStreaming::printSheetCount); diff --git a/src/examples/src/org/apache/poi/xssf/streaming/examples/SavePasswordProtectedXlsx.java b/src/examples/src/org/apache/poi/xssf/streaming/examples/SavePasswordProtectedXlsx.java index f91141c78f..a20c87e825 100644 --- a/src/examples/src/org/apache/poi/xssf/streaming/examples/SavePasswordProtectedXlsx.java +++ b/src/examples/src/org/apache/poi/xssf/streaming/examples/SavePasswordProtectedXlsx.java @@ -46,7 +46,10 @@ import org.apache.poi.xssf.streaming.SXSSFSheet; * <li><code>SXSSFWorkbookWithCustomZipEntrySource</code> extends SXSSFWorkbook to ensure temp files are encrypted. * </ul><p> */ -public class SavePasswordProtectedXlsx { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class SavePasswordProtectedXlsx { + + private SavePasswordProtectedXlsx() {} public static void main(String[] args) throws Exception { if(args.length != 2) { @@ -81,7 +84,7 @@ public class SavePasswordProtectedXlsx { } TempFileUtils.checkTempFiles(); } - + public static void save(final InputStream inputStream, final String filename, final String pwd) throws InvalidFormatException, IOException, GeneralSecurityException { diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CustomXMLMapping.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/CustomXMLMapping.java index 70b235413f..9f2ab3d4b7 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CustomXMLMapping.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/CustomXMLMapping.java @@ -16,17 +16,20 @@ ==================================================================== */ package org.apache.poi.xssf.usermodel.examples; +import java.io.ByteArrayOutputStream; + import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.xssf.extractor.XSSFExportToXml; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFMap; - -import java.io.ByteArrayOutputStream; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * Print all custom XML mappings registered in the given workbook */ -public class CustomXMLMapping { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class CustomXMLMapping { + + private CustomXMLMapping() {} public static void main(String[] args) throws Exception { try (OPCPackage pkg = OPCPackage.open(args[0]); diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java index 0d30923852..b7f2930ffc 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java @@ -29,7 +29,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * Iterate over rows and cells */ -public class IterateCells { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class IterateCells { + + private IterateCells() {} public static void main(String[] args) throws IOException { try ( diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/LoadPasswordProtectedXlsx.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/LoadPasswordProtectedXlsx.java index 50149bdae7..7afe88f00e 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/LoadPasswordProtectedXlsx.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/LoadPasswordProtectedXlsx.java @@ -37,8 +37,11 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; * <li><code>AesZipFileZipEntrySource</code> is used to ensure that temp files are encrypted. * </ul><p> */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class LoadPasswordProtectedXlsx { + private LoadPasswordProtectedXlsx() {} + public interface EncryptionHandler { void handle(final InputStream inputStream) throws Exception; } diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java index f0d9ebde37..0bee5e73e9 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java @@ -35,7 +35,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * Demonstrates how to insert pictures in a SpreadsheetML document */ -public class WorkingWithPictures { +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) +public final class WorkingWithPictures { + private WorkingWithPictures() {} + public static void main(String[] args) throws IOException { //create a new workbook diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/BarChartExample.java b/src/examples/src/org/apache/poi/xwpf/usermodel/examples/BarChartExample.java index 2b2d176f12..2301687c47 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/BarChartExample.java +++ b/src/examples/src/org/apache/poi/xwpf/usermodel/examples/BarChartExample.java @@ -43,6 +43,7 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument; /** * Build a bar chart from a template docx */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class BarChartExample { private BarChartExample() {} diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/ChartFromScratch.java b/src/examples/src/org/apache/poi/xwpf/usermodel/examples/ChartFromScratch.java index 6e4418f816..266466c141 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/ChartFromScratch.java +++ b/src/examples/src/org/apache/poi/xwpf/usermodel/examples/ChartFromScratch.java @@ -49,6 +49,7 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument; /** * Build a chart without reading template file */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class ChartFromScratch { private ChartFromScratch() {} diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java b/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java index 2ebcb354bf..9e379955e2 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java +++ b/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java @@ -33,6 +33,7 @@ import org.apache.poi.xwpf.usermodel.XWPFRun; /** * Demonstrates how to add pictures in a .docx document */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public final class SimpleImages { private SimpleImages() {} diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/UpdateEmbeddedDoc.java b/src/examples/src/org/apache/poi/xwpf/usermodel/examples/UpdateEmbeddedDoc.java index c21f595d13..af0eefde46 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/UpdateEmbeddedDoc.java +++ b/src/examples/src/org/apache/poi/xwpf/usermodel/examples/UpdateEmbeddedDoc.java @@ -42,10 +42,11 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument; * embedded into a WordprocessingML document. Note that the test has currently * only been conducted with a binary Excel workbook and NOT yet with a * SpreadsheetML workbook embedded into the document.<p> - * + * * This code was successfully tested with the following file from the POI test collection: * http://svn.apache.org/repos/asf/poi/trunk/test-data/document/EmbeddedDocument.docx */ +@SuppressWarnings({"java:S106","java:S4823","java:S1192"}) public class UpdateEmbeddedDoc { private XWPFDocument doc; |