@@ -25,11 +25,15 @@ This file is part of the iText (R) project.
25
25
import com .itextpdf .io .exceptions .IOException ;
26
26
import com .itextpdf .io .exceptions .IoExceptionMessageConstant ;
27
27
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 {
28
35
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.
33
37
private final ByteBuffer numBuffer = new ByteBuffer (32 );
34
38
private Boolean localHighPrecision ;
35
39
protected java .io .OutputStream outputStream = null ;
@@ -46,10 +50,10 @@ public static boolean getHighPrecision() {
46
50
}
47
51
48
52
/**
49
- * Sets global high precision setting for all {@link OutputStream } instances.
53
+ * Sets global high precision setting for all {@link HighPrecisionOutputStream } instances.
50
54
*
51
55
* @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.
53
57
*/
54
58
public static void setHighPrecision (boolean value ) {
55
59
ByteUtils .HighPrecision = value ;
@@ -65,36 +69,29 @@ public boolean getLocalHighPrecision() {
65
69
}
66
70
67
71
/**
68
- * Sets local high precision setting for the {@link OutputStream }.
72
+ * Sets local high precision setting for the {@link HighPrecisionOutputStream }.
69
73
* Global {@link ByteUtils#HighPrecision} setting will be overridden by this one.
70
74
*
71
75
* @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 }.
73
77
*/
74
78
public void setLocalHighPrecision (boolean value ) {
75
79
this .localHighPrecision = value ;
76
80
}
77
81
78
82
/**
79
- * Creates a new {@link OutputStream } instance
83
+ * Creates a new {@link HighPrecisionOutputStream } instance
80
84
* based on {@link java.io.OutputStream} instance.
81
85
*
82
- * @param outputStream the {@link OutputStream } instance.
86
+ * @param outputStream the {@link HighPrecisionOutputStream } instance.
83
87
*/
84
- public OutputStream (java .io .OutputStream outputStream ) {
88
+ public HighPrecisionOutputStream (java .io .OutputStream outputStream ) {
85
89
super ();
86
90
this .outputStream = outputStream ;
87
91
}
88
92
89
93
/**
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
98
95
* based on {@link java.io.OutputStream} instance and precision setting value.
99
96
*
100
97
* @param outputStream the {@link java.io.OutputStream} instance.
@@ -103,7 +100,7 @@ protected OutputStream() {
103
100
* Global {@link ByteUtils#HighPrecision} setting
104
101
* will be overridden by this one.
105
102
*/
106
- public OutputStream (java .io .OutputStream outputStream , boolean localHighPrecision ) {
103
+ public HighPrecisionOutputStream (java .io .OutputStream outputStream , boolean localHighPrecision ) {
107
104
super ();
108
105
this .outputStream = outputStream ;
109
106
this .localHighPrecision = localHighPrecision ;
@@ -303,7 +300,7 @@ public T writeString(String value) {
303
300
}
304
301
305
302
/**
306
- * See {@link OutputStream #write(byte[])}.
303
+ * See {@link HighPrecisionOutputStream #write(byte[])}.
307
304
*
308
305
* @param b byte array to write.
309
306
*
@@ -321,7 +318,7 @@ public T writeBytes(byte[] b) {
321
318
}
322
319
323
320
/**
324
- * See {@link OutputStream #write(byte[], int, int)}.
321
+ * See {@link HighPrecisionOutputStream #write(byte[], int, int)}.
325
322
*
326
323
* @param b the data to write.
327
324
* @param off the start offset in the data.
@@ -369,7 +366,7 @@ public boolean isCloseStream() {
369
366
}
370
367
371
368
/**
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()}.
373
370
*
374
371
* @param closeStream true if stream needs to be closed, false if it's done manually.
375
372
*/
@@ -395,8 +392,8 @@ public void assignBytes(byte[] bytes, int count) {
395
392
/**
396
393
* See {@link ByteArrayOutputStream#reset()}.
397
394
*
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.
400
397
*/
401
398
public void reset () {
402
399
if (outputStream instanceof ByteArrayOutputStream ) {
0 commit comments