Skip to content

Commit 3d0e05d

Browse files
committed
Fix warnings
1 parent e7189d3 commit 3d0e05d

File tree

6 files changed

+17
-27
lines changed

6 files changed

+17
-27
lines changed

src/main/java/com/orsonpdf/Dictionary.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class Dictionary {
5353
private String type;
5454

5555
/** Data storage. */
56-
private Map<String, Object> map;
56+
private final Map<String, Object> map;
5757

5858
/**
5959
* Creates a new instance with no type.
@@ -170,7 +170,7 @@ public String toPDFString() {
170170
Object value = this.map.get(key);
171171
if (value instanceof Number || value instanceof String) {
172172
b.append(key).append(" ");
173-
b.append(value.toString()).append("\n");
173+
b.append(value).append("\n");
174174
} else if (value instanceof PDFObject) {
175175
PDFObject pdfObj = (PDFObject) value;
176176
b.append(key).append(" ");

src/main/java/com/orsonpdf/DictionaryObject.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*/
4242
public class DictionaryObject extends PDFObject {
4343

44-
protected Dictionary dictionary;
44+
protected final Dictionary dictionary;
4545

4646
/**
4747
* Creates a new instance.

src/main/java/com/orsonpdf/FontKey.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
public class FontKey {
4343

4444
/** The key name. */
45-
private String name;
45+
private final String name;
4646

4747
/** Flag for bold. */
48-
private boolean isBold;
48+
private final boolean isBold;
4949

5050
/** Flag for italic. */
51-
private boolean isItalic;
51+
private final boolean isItalic;
5252

5353
/**
5454
* Creates a new key for a given font.

src/main/java/com/orsonpdf/PDFDocument.java

+4-9
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import java.io.FileNotFoundException;
3838
import java.io.FileOutputStream;
3939
import java.io.IOException;
40-
import java.io.UnsupportedEncodingException;
40+
import java.nio.charset.StandardCharsets;
4141
import java.util.ArrayList;
4242
import java.util.Date;
4343
import java.util.List;
@@ -266,7 +266,7 @@ public byte[] getPDFBytes() {
266266
xref[xref.length - 1] = bos.size();
267267
// write the xref table
268268
bos.write(toBytes("xref\n"));
269-
bos.write(toBytes("0 " + String.valueOf(this.nextNumber)
269+
bos.write(toBytes("0 " + this.nextNumber
270270
+ "\n"));
271271
bos.write(toBytes("0000000000 65535 f \n"));
272272
for (int i = 0; i < this.nextNumber - 1; i++) {
@@ -284,8 +284,7 @@ public byte[] getPDFBytes() {
284284
trailer.put("/Info", this.info);
285285
bos.write(trailer.toPDFBytes());
286286
bos.write(toBytes("startxref\n"));
287-
bos.write(toBytes(String.valueOf(xref[this.nextNumber - 1])
288-
+ "\n"));
287+
bos.write(toBytes(xref[this.nextNumber - 1] + "\n"));
289288
bos.write(toBytes("%%EOF"));
290289
} catch (IOException ex) {
291290
throw new RuntimeException(ex);
@@ -328,11 +327,7 @@ public void writeToFile(File f) {
328327
*/
329328
private byte[] toBytes(String s) {
330329
byte[] result = null;
331-
try {
332-
result = s.getBytes("US-ASCII");
333-
} catch (UnsupportedEncodingException ex) {
334-
throw new RuntimeException(ex);
335-
}
330+
result = s.getBytes(StandardCharsets.US_ASCII);
336331
return result;
337332
}
338333

src/main/java/com/orsonpdf/PDFUtils.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
import com.orsonpdf.util.Args;
3535
import java.awt.geom.AffineTransform;
36-
import java.io.UnsupportedEncodingException;
36+
import java.nio.charset.StandardCharsets;
3737
import java.text.DateFormat;
3838
import java.text.SimpleDateFormat;
3939
import java.util.Calendar;
@@ -62,7 +62,7 @@ public static String toPDFArray(boolean[] b) {
6262
if (i != 0) {
6363
sb.append(" ");
6464
}
65-
sb.append(String.valueOf(b[i]));
65+
sb.append(b[i]);
6666
}
6767
return sb.append("]").toString();
6868
}
@@ -81,7 +81,7 @@ public static String toPDFArray(float[] f) {
8181
if (i != 0) {
8282
b.append(" ");
8383
}
84-
b.append(String.valueOf(f[i]));
84+
b.append(f[i]);
8585
}
8686
return b.append("]").toString();
8787
}
@@ -100,7 +100,7 @@ public static String toPDFArray(double[] d) {
100100
if (i != 0) {
101101
b.append(" ");
102102
}
103-
b.append(String.valueOf(d[i]));
103+
b.append(d[i]);
104104
}
105105
return b.append("]").toString();
106106
}
@@ -170,11 +170,7 @@ public static String toPDFDateFormat(Calendar calendar) {
170170
*/
171171
public static byte[] toBytes(String s) {
172172
byte[] result = null;
173-
try {
174-
result = s.getBytes("US-ASCII");
175-
} catch (UnsupportedEncodingException ex) {
176-
throw new RuntimeException(ex);
177-
}
173+
result = s.getBytes(StandardCharsets.US_ASCII);
178174
return result;
179175
}
180176

src/main/java/com/orsonpdf/Page.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,10 @@ private Function createFunctionForMultipleGradient(
281281
PDFDocument doc = this.parent.getDocument();
282282

283283
if (mgp.getColors().length == 2) {
284-
Function f = new ExponentialInterpolationFunction(
284+
return new ExponentialInterpolationFunction(
285285
doc.getNextNumber(),
286-
mgp.getColors()[0].getRGBColorComponents(null),
286+
mgp.getColors()[0].getRGBColorComponents(null),
287287
mgp.getColors()[1].getRGBColorComponents(null));
288-
return f;
289288
} else {
290289
int count = mgp.getColors().length - 1;
291290
Function[] functions = new Function[count];

0 commit comments

Comments
 (0)