Skip to content

Commit a954103

Browse files
committed
Revise public for-internal-usage methods
DEVSIX-3428
1 parent ac40d30 commit a954103

File tree

19 files changed

+387
-249
lines changed

19 files changed

+387
-249
lines changed

forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This file is part of the iText (R) project.
3232
import com.itextpdf.io.font.constants.StandardFonts;
3333
import com.itextpdf.io.image.ImageData;
3434
import com.itextpdf.io.image.ImageDataFactory;
35-
import com.itextpdf.io.source.OutputStream;
35+
import com.itextpdf.io.source.HighPrecisionOutputStream;
3636
import com.itextpdf.kernel.colors.Color;
3737
import com.itextpdf.kernel.colors.DeviceCmyk;
3838
import com.itextpdf.kernel.colors.DeviceGray;
@@ -1312,7 +1312,7 @@ private static PdfString generateDefaultAppearance(PdfName font, float fontSize,
13121312
assert font != null;
13131313

13141314
ByteArrayOutputStream output = new ByteArrayOutputStream();
1315-
PdfOutputStream pdfStream = new PdfOutputStream(new OutputStream<>(output));
1315+
PdfOutputStream pdfStream = new PdfOutputStream(new HighPrecisionOutputStream<>(output));
13161316
final byte[] g = new byte[]{(byte) 'g'};
13171317
final byte[] rg = new byte[]{(byte) 'r', (byte) 'g'};
13181318
final byte[] k = new byte[]{(byte) 'k'};

io/src/main/java/com/itextpdf/io/source/OutputStream.java renamed to io/src/main/java/com/itextpdf/io/source/HighPrecisionOutputStream.java

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ This file is part of the iText (R) project.
2525
import com.itextpdf.io.exceptions.IOException;
2626
import com.itextpdf.io.exceptions.IoExceptionMessageConstant;
2727

28+
/**
29+
* Output stream based on {@link java.io.OutputStream} for which it is possible to set high precision in order to write
30+
* all floats and doubles with high precision.
31+
*
32+
* @param <T> {@link java.io.OutputStream}
33+
*/
34+
public class HighPrecisionOutputStream<T extends java.io.OutputStream> extends java.io.OutputStream {
2835

29-
public class OutputStream<T extends java.io.OutputStream> extends java.io.OutputStream {
30-
31-
32-
//long=19 + max frac=6 => 26 => round to 32.
36+
// long=19 + max frac=6 => 26 => round to 32.
3337
private final ByteBuffer numBuffer = new ByteBuffer(32);
3438
private Boolean localHighPrecision;
3539
protected java.io.OutputStream outputStream = null;
@@ -46,10 +50,10 @@ public static boolean getHighPrecision() {
4650
}
4751

4852
/**
49-
* Sets global high precision setting for all {@link OutputStream} instances.
53+
* Sets global high precision setting for all {@link HighPrecisionOutputStream} instances.
5054
*
5155
* @param value if true, all floats and double will be written with high precision
52-
* in all {@link OutputStream} instances.
56+
* in all {@link HighPrecisionOutputStream} instances.
5357
*/
5458
public static void setHighPrecision(boolean value) {
5559
ByteUtils.HighPrecision = value;
@@ -65,36 +69,29 @@ public boolean getLocalHighPrecision() {
6569
}
6670

6771
/**
68-
* Sets local high precision setting for the {@link OutputStream}.
72+
* Sets local high precision setting for the {@link HighPrecisionOutputStream}.
6973
* Global {@link ByteUtils#HighPrecision} setting will be overridden by this one.
7074
*
7175
* @param value if true, all floats and double will be written with high precision
72-
* in the underlying {@link OutputStream}.
76+
* in the underlying {@link HighPrecisionOutputStream}.
7377
*/
7478
public void setLocalHighPrecision(boolean value) {
7579
this.localHighPrecision = value;
7680
}
7781

7882
/**
79-
* Creates a new {@link OutputStream} instance
83+
* Creates a new {@link HighPrecisionOutputStream} instance
8084
* based on {@link java.io.OutputStream} instance.
8185
*
82-
* @param outputStream the {@link OutputStream} instance.
86+
* @param outputStream the {@link HighPrecisionOutputStream} instance.
8387
*/
84-
public OutputStream(java.io.OutputStream outputStream) {
88+
public HighPrecisionOutputStream(java.io.OutputStream outputStream) {
8589
super();
8690
this.outputStream = outputStream;
8791
}
8892

8993
/**
90-
* Do not use this constructor. This is only for internal usage.
91-
*/
92-
protected OutputStream() {
93-
super();
94-
}
95-
96-
/**
97-
* Creates a new {@link OutputStream} instance
94+
* Creates a new {@link HighPrecisionOutputStream} instance
9895
* based on {@link java.io.OutputStream} instance and precision setting value.
9996
*
10097
* @param outputStream the {@link java.io.OutputStream} instance.
@@ -103,7 +100,7 @@ protected OutputStream() {
103100
* Global {@link ByteUtils#HighPrecision} setting
104101
* will be overridden by this one.
105102
*/
106-
public OutputStream(java.io.OutputStream outputStream, boolean localHighPrecision) {
103+
public HighPrecisionOutputStream(java.io.OutputStream outputStream, boolean localHighPrecision) {
107104
super();
108105
this.outputStream = outputStream;
109106
this.localHighPrecision = localHighPrecision;
@@ -303,7 +300,7 @@ public T writeString(String value) {
303300
}
304301

305302
/**
306-
* See {@link OutputStream#write(byte[])}.
303+
* See {@link HighPrecisionOutputStream#write(byte[])}.
307304
*
308305
* @param b byte array to write.
309306
*
@@ -321,7 +318,7 @@ public T writeBytes(byte[] b) {
321318
}
322319

323320
/**
324-
* See {@link OutputStream#write(byte[], int, int)}.
321+
* See {@link HighPrecisionOutputStream#write(byte[], int, int)}.
325322
*
326323
* @param b the data to write.
327324
* @param off the start offset in the data.
@@ -369,7 +366,7 @@ public boolean isCloseStream() {
369366
}
370367

371368
/**
372-
* Sets internal {@link java.io.OutputStream} to be closed after {@link OutputStream#close()}.
369+
* Sets internal {@link java.io.OutputStream} to be closed after {@link HighPrecisionOutputStream#close()}.
373370
*
374371
* @param closeStream true if stream needs to be closed, false if it's done manually.
375372
*/
@@ -395,8 +392,8 @@ public void assignBytes(byte[] bytes, int count) {
395392
/**
396393
* See {@link ByteArrayOutputStream#reset()}.
397394
*
398-
* @throws com.itextpdf.io.exceptions.IOException if internal {@link OutputStream}.
399-
* is not a {@link ByteArrayOutputStream} instance.
395+
* @throws com.itextpdf.io.exceptions.IOException if internal {@link HighPrecisionOutputStream} is not
396+
* a {@link ByteArrayOutputStream} instance.
400397
*/
401398
public void reset() {
402399
if (outputStream instanceof ByteArrayOutputStream) {

io/src/main/java/com/itextpdf/io/util/XmlUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This file is part of the iText (R) project.
3333

3434
/**
3535
* This file is a helper class for internal usage only.
36-
* Be aware that its API and functionality may be changed in future.
36+
* Be aware that its API and functionality may be changed in the future.
3737
*/
3838
public final class XmlUtil {
3939

0 commit comments

Comments
 (0)