Skip to content

Commit d0f3df0

Browse files
committed
Remove redundant throws declarations
DEVSIX-3495
1 parent c861837 commit d0f3df0

File tree

8 files changed

+111
-123
lines changed

8 files changed

+111
-123
lines changed

src/main/java/com/itextpdf/html2pdf/HtmlConverter.java

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@ This file is part of the iText (R) project.
4646
import com.itextpdf.html2pdf.attach.Attacher;
4747
import com.itextpdf.html2pdf.exception.Html2PdfException;
4848
import com.itextpdf.io.util.FileUtil;
49+
import com.itextpdf.kernel.Version;
4950
import com.itextpdf.kernel.counter.event.IMetaInfo;
5051
import com.itextpdf.kernel.pdf.DocumentProperties;
5152
import com.itextpdf.kernel.pdf.PdfDocument;
5253
import com.itextpdf.kernel.pdf.PdfWriter;
5354
import com.itextpdf.layout.Document;
5455
import com.itextpdf.layout.element.IElement;
55-
import java.lang.reflect.Array;
56-
import java.lang.reflect.Constructor;
57-
import java.lang.reflect.Method;
58-
import com.itextpdf.kernel.Version;
5956
import com.itextpdf.styledxmlparser.IXmlParser;
6057
import com.itextpdf.styledxmlparser.node.IDocumentNode;
6158
import com.itextpdf.styledxmlparser.node.impl.jsoup.JsoupHtmlParser;
@@ -66,6 +63,9 @@ This file is part of the iText (R) project.
6663
import java.io.IOException;
6764
import java.io.InputStream;
6865
import java.io.OutputStream;
66+
import java.lang.reflect.Array;
67+
import java.lang.reflect.Constructor;
68+
import java.lang.reflect.Method;
6969
import java.util.List;
7070

7171
/**
@@ -92,9 +92,8 @@ private HtmlConverter() {
9292
*
9393
* @param html the html in the form of a {@link String}
9494
* @param pdfStream the PDF as an {@link OutputStream}
95-
* @throws IOException Signals that an I/O exception has occurred.
9695
*/
97-
public static void convertToPdf(String html, OutputStream pdfStream) throws IOException {
96+
public static void convertToPdf(String html, OutputStream pdfStream) {
9897
convertToPdf(html, pdfStream, null);
9998
}
10099

@@ -105,9 +104,8 @@ public static void convertToPdf(String html, OutputStream pdfStream) throws IOEx
105104
* @param html the html in the form of a {@link String}
106105
* @param pdfStream the PDF as an {@link OutputStream}
107106
* @param converterProperties a {@link ConverterProperties} instance
108-
* @throws IOException Signals that an I/O exception has occurred.
109107
*/
110-
public static void convertToPdf(String html, OutputStream pdfStream, ConverterProperties converterProperties) throws IOException {
108+
public static void convertToPdf(String html, OutputStream pdfStream, ConverterProperties converterProperties) {
111109
convertToPdf(html, new PdfWriter(pdfStream), converterProperties);
112110
}
113111

@@ -117,9 +115,8 @@ public static void convertToPdf(String html, OutputStream pdfStream, ConverterPr
117115
*
118116
* @param html the html in the form of a {@link String}
119117
* @param pdfWriter the {@link PdfWriter} instance
120-
* @throws IOException Signals that an I/O exception has occurred.
121118
*/
122-
public static void convertToPdf(String html, PdfWriter pdfWriter) throws IOException {
119+
public static void convertToPdf(String html, PdfWriter pdfWriter) {
123120
convertToPdf(html, pdfWriter, null);
124121
}
125122

@@ -130,9 +127,8 @@ public static void convertToPdf(String html, PdfWriter pdfWriter) throws IOExcep
130127
* @param html the html in the form of a {@link String}
131128
* @param pdfWriter the {@link PdfWriter} instance
132129
* @param converterProperties a {@link ConverterProperties} instance
133-
* @throws IOException Signals that an I/O exception has occurred.
134130
*/
135-
public static void convertToPdf(String html, PdfWriter pdfWriter, ConverterProperties converterProperties) throws IOException {
131+
public static void convertToPdf(String html, PdfWriter pdfWriter, ConverterProperties converterProperties) {
136132
convertToPdf(html, new PdfDocument(pdfWriter, new DocumentProperties().setEventCountingMetaInfo(new HtmlMetaInfo())), converterProperties);
137133
}
138134

@@ -143,9 +139,8 @@ public static void convertToPdf(String html, PdfWriter pdfWriter, ConverterPrope
143139
* @param html the html in the form of a {@link String}
144140
* @param pdfDocument the {@link PdfDocument} instance
145141
* @param converterProperties a {@link ConverterProperties} instance
146-
* @throws IOException Signals that an I/O exception has occurred.
147142
*/
148-
public static void convertToPdf(String html, PdfDocument pdfDocument, ConverterProperties converterProperties) throws IOException {
143+
public static void convertToPdf(String html, PdfDocument pdfDocument, ConverterProperties converterProperties) {
149144
Document document = convertToDocument(html, pdfDocument, converterProperties);
150145
document.close();
151146
}
@@ -268,9 +263,8 @@ public static void convertToPdf(InputStream htmlStream, PdfDocument pdfDocument,
268263
* @param html the html in the form of a {@link String}
269264
* @param pdfWriter the {@link PdfWriter} containing the resulting PDF
270265
* @return a {@link Document} instance
271-
* @throws IOException Signals that an I/O exception has occurred.
272266
*/
273-
public static Document convertToDocument(String html, PdfWriter pdfWriter) throws IOException {
267+
public static Document convertToDocument(String html, PdfWriter pdfWriter) {
274268
return convertToDocument(html, pdfWriter, null);
275269
}
276270

@@ -296,9 +290,8 @@ public static Document convertToDocument(InputStream htmlStream, PdfWriter pdfWr
296290
* @param pdfWriter the pdf writer
297291
* @param converterProperties a {@link ConverterProperties} instance
298292
* @return a {@link Document} instance
299-
* @throws IOException Signals that an I/O exception has occurred.
300293
*/
301-
public static Document convertToDocument(String html, PdfWriter pdfWriter, ConverterProperties converterProperties) throws IOException {
294+
public static Document convertToDocument(String html, PdfWriter pdfWriter, ConverterProperties converterProperties) {
302295
return convertToDocument(html, new PdfDocument(pdfWriter), converterProperties);
303296
}
304297

@@ -326,9 +319,8 @@ public static Document convertToDocument(InputStream htmlStream, PdfWriter pdfWr
326319
* @param pdfDocument the {@link PdfDocument} instance
327320
* @param converterProperties a {@link ConverterProperties} instance
328321
* @return a {@link Document} instance
329-
* @throws IOException Signals that an I/O exception has occurred.
330322
*/
331-
public static Document convertToDocument(String html, PdfDocument pdfDocument, ConverterProperties converterProperties) throws IOException {
323+
public static Document convertToDocument(String html, PdfDocument pdfDocument, ConverterProperties converterProperties) {
332324
String licenseKeyClassName = "com.itextpdf.licensekey.LicenseKey";
333325
String licenseKeyProductClassName = "com.itextpdf.licensekey.LicenseKeyProduct";
334326
String licenseKeyFeatureClassName = "com.itextpdf.licensekey.LicenseKeyProductFeature";
@@ -435,9 +427,8 @@ public static Document convertToDocument(InputStream htmlStream, PdfDocument pdf
435427
*
436428
* @param html the html in the form of a {@link String}
437429
* @return a list of iText building blocks
438-
* @throws IOException Signals that an I/O exception has occurred.
439430
*/
440-
public static List<IElement> convertToElements(String html) throws IOException {
431+
public static List<IElement> convertToElements(String html) {
441432
return convertToElements(html, null);
442433
}
443434

@@ -461,9 +452,8 @@ public static List<IElement> convertToElements(InputStream htmlStream) throws IO
461452
* @param html the html in the form of a {@link String}
462453
* @param converterProperties a {@link ConverterProperties} instance
463454
* @return a list of iText building blocks
464-
* @throws IOException Signals that an I/O exception has occurred.
465455
*/
466-
public static List<IElement> convertToElements(String html, ConverterProperties converterProperties) throws IOException {
456+
public static List<IElement> convertToElements(String html, ConverterProperties converterProperties) {
467457
String licenseKeyClassName = "com.itextpdf.licensekey.LicenseKey";
468458
String licenseKeyProductClassName = "com.itextpdf.licensekey.LicenseKeyProduct";
469459
String licenseKeyFeatureClassName = "com.itextpdf.licensekey.LicenseKeyProductFeature";

src/test/java/com/itextpdf/html2pdf/ExtendedHtmlConversionITextTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public void convertToPdfAcroformFlattenAndCompare(String name, String sourceFold
176176
}
177177
}
178178

179-
private void compareTagStructure(String outPath, String cmpPath) throws IOException, InterruptedException, ParserConfigurationException, SAXException {
179+
private void compareTagStructure(String outPath, String cmpPath) throws IOException, ParserConfigurationException, SAXException {
180180
CompareTool compareTool = new CompareTool();
181181
String tagStructureErrors = compareTool.compareTagStructures(outPath, cmpPath);
182182
String resultMessage = "";

src/test/java/com/itextpdf/html2pdf/Html2ElementsTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static void beforeClass() {
8585
}
8686

8787
@Test
88-
public void htmlToElementsTest01() throws IOException {
88+
public void htmlToElementsTest01() {
8989
String html = "<p>Hello world!</p>";
9090
List<IElement> lst = HtmlConverter.convertToElements(html);
9191
Assert.assertTrue(lst.size() == 1);
@@ -96,7 +96,7 @@ public void htmlToElementsTest01() throws IOException {
9696
}
9797

9898
@Test
99-
public void htmlToElementsTest02() throws IOException {
99+
public void htmlToElementsTest02() {
100100
String html = "<table style=\"font-size: 2em\"><tr><td>123</td><td><456></td></tr><tr><td>Long cell</td></tr></table>";
101101
List<IElement> lst = HtmlConverter.convertToElements(html);
102102
Assert.assertTrue(lst.size() == 1);
@@ -108,7 +108,7 @@ public void htmlToElementsTest02() throws IOException {
108108
}
109109

110110
@Test
111-
public void htmlToElementsTest03() throws IOException {
111+
public void htmlToElementsTest03() {
112112
String html = "<p>Hello world!</p><table><tr><td>123</td><td><456></td></tr><tr><td>Long cell</td></tr></table><p>Hello world!</p>";
113113
List<IElement> lst = HtmlConverter.convertToElements(html);
114114
Assert.assertTrue(lst.size() == 3);
@@ -121,7 +121,7 @@ public void htmlToElementsTest03() throws IOException {
121121

122122
@Test
123123
// Handles malformed html
124-
public void htmlToElementsTest04() throws IOException {
124+
public void htmlToElementsTest04() {
125125
String html = "<p>Hello world!<table><td>123";
126126
List<IElement> lst = HtmlConverter.convertToElements(html);
127127
Assert.assertTrue(lst.size() == 2);
@@ -133,15 +133,15 @@ public void htmlToElementsTest04() throws IOException {
133133

134134
@Test
135135
@LogMessages(messages = {})
136-
public void htmlToElementsTest05() throws IOException {
136+
public void htmlToElementsTest05() {
137137
String html = "123";
138138
List<IElement> lst = HtmlConverter.convertToElements(html);
139139
Assert.assertTrue(lst.size() == 1);
140140
}
141141

142142
@Test
143143
@LogMessages(messages = {})
144-
public void htmlElementsTest06() throws IOException {
144+
public void htmlElementsTest06() {
145145
String html = "<html>Lorem<p>Ipsum</p>Dolor<p>Sit</p></html>";
146146
List<IElement> lst = HtmlConverter.convertToElements(html);
147147
Assert.assertTrue(lst.size() == 4);
@@ -151,7 +151,7 @@ public void htmlElementsTest06() throws IOException {
151151

152152
@Test
153153
@LogMessages(messages = {})
154-
public void htmlElementsTest07() throws IOException {
154+
public void htmlElementsTest07() {
155155
String html = "<html>Lorem<span>Dolor</span><p>Ipsum</p><p>Sit</p></html>";
156156
List<IElement> lst = HtmlConverter.convertToElements(html);
157157
Assert.assertTrue(lst.size() == 3);
@@ -161,14 +161,14 @@ public void htmlElementsTest07() throws IOException {
161161

162162
@Test
163163
// this test checks whether iText fails to process meta tag inside body section or not
164-
public void htmlToElementsTest08() throws IOException {
164+
public void htmlToElementsTest08() {
165165
String html = "<html><p>Hello world!</p><meta name=\"author\" content=\"Bruno\"><table><tr><td>123</td><td><456></td></tr><tr><td>Long cell</td></tr></table><p>Hello world!</p></html>";
166166
HtmlConverter.convertToElements(html);
167167
}
168168

169169
@Test
170170
//Test OutlineHandler exception throwing
171-
public void htmlToElementsTest09() throws IOException {
171+
public void htmlToElementsTest09() {
172172
/*
173173
Outlines require a PdfDocument, and OutlineHandler is based around its availability
174174
Any convert to elements workflow of course doesn't have a PdfDocument.
@@ -191,7 +191,7 @@ public void htmlToElementsTest09() throws IOException {
191191
@LogMessage(messageTemplate = LogMessageConstant.WORKER_UNABLE_TO_PROCESS_OTHER_WORKER, count = 1),
192192
@LogMessage(messageTemplate = LogMessageConstant.PDF_DOCUMENT_NOT_PRESENT, count = 1),
193193
})
194-
public void htmlObjectMalformedUrlTest() throws IOException {
194+
public void htmlObjectMalformedUrlTest() {
195195
String html = "<object data ='htt://as' type='image/svg+xml'></object>";
196196
List<IElement> lst = HtmlConverter.convertToElements(html);
197197
Assert.assertTrue(lst.size() == 0);

src/test/java/com/itextpdf/html2pdf/css/BrTagTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ This file is part of the iText (R) project.
4949
import com.itextpdf.test.ExtendedITextTest;
5050
import com.itextpdf.test.annotations.type.IntegrationTest;
5151

52-
import java.io.IOException;
5352
import java.util.List;
54-
5553
import org.junit.Assert;
5654
import org.junit.BeforeClass;
5755
import org.junit.Test;
@@ -70,7 +68,7 @@ public static void beforeClass() {
7068
}
7169

7270
@Test
73-
public void test() throws IOException, InterruptedException {
71+
public void test() {
7472
String input = "<html>\n" +
7573
"<head><title>Test</title></head>" +
7674
"<body style=\"font-family: FreeSans;\">" +

src/test/java/com/itextpdf/html2pdf/css/FontFaceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void fontFaceGrammarTest() throws IOException, InterruptedException {
118118
}
119119

120120
@Test
121-
public void droidSerifLocalWithMediaRuleFontTest3() throws IOException, InterruptedException {
121+
public void droidSerifLocalWithMediaRuleFontTest3() {
122122
String name = "droidSerifLocalWithMediaRuleFontTest";
123123
String htmlPath = sourceFolder + name + ".html";
124124
System.out.println("html: " + UrlUtil.getNormalizedFileUriString(htmlPath) + "\n");

src/test/java/com/itextpdf/html2pdf/css/LineHeightTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public void blockElementLineHeightTest() throws IOException, InterruptedExceptio
172172
}
173173

174174
@Test
175-
public void defaultLineHeightTest() throws IOException {
175+
public void defaultLineHeightTest() {
176176
List<IElement> elements = HtmlConverter.convertToElements("<p>Lorem Ipsum</p>");
177177
Assert.assertEquals(1.2f, elements.get(0).<Leading>getProperty(Property.LEADING).getValue(), 1e-10);
178178
}

0 commit comments

Comments
 (0)