Package com.itextpdf.io.source
Class HighPrecisionOutputStreamOutputStream>
java.lang.Object
java.io.OutputStream
com.itextpdf.io.source.HighPrecisionOutputStream
- Type Parameters:
-
T-OutputStream
- All Implemented Interfaces:
-
Closeable,Flushable,AutoCloseable
- Direct Known Subclasses:
-
PdfOutputStream
Output stream based on
OutputStream for which it is possible to set high precision in order to write all floats and doubles with high precision.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHighPrecisionOutputStream(OutputStream outputStream) Creates a newHighPrecisionOutputStreaminstance based onOutputStreaminstance.HighPrecisionOutputStream(OutputStream outputStream, boolean localHighPrecision) Creates a newHighPrecisionOutputStreaminstance based onOutputStreaminstance and precision setting value. -
Method Summary
Modifier and TypeMethodDescriptionvoidassignBytes(byte[] bytes, int count) voidclose()voidflush()longGets current output stream position.static booleanGets global high precision setting.booleanGets local high precision setting.Gets internalOutputStream.booleanReturns true, if internalOutputStreamhave to be closed afterclose()call, false otherwise.voidreset()voidsetCloseStream(boolean closeStream) Sets internalOutputStreamto be closed afterclose().static voidsetHighPrecision(boolean value) Sets global high precision setting for allHighPrecisionOutputStreaminstances.voidsetLocalHighPrecision(boolean value) Sets local high precision setting for theHighPrecisionOutputStream.voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b) voidwriteByte(byte value) writeByte(int value) Writes byte to internalOutputStream.writeBytes(byte[] b) Seewrite(byte[]).writeBytes(byte[] b, int off, int len) writeDouble(double value) Writes double to internalOutputStreamin ISO format.writeDouble(double value, boolean highPrecision) Writes double to internalOutputStreamin ISO format.writeFloat(float value) Writes float to internalOutputStreamin ISO format.writeFloat(float value, boolean highPrecision) Writes float to internalOutputStreamin ISO format.writeFloats(float[] value) Writes float array to internalOutputStreamin ISO format.writeInteger(int value) Writes int to internalOutputStreamin ISO format.writeLong(long value) Writes long to internalOutputStreamin ISO format.Writes new line to internalOutputStream.Writes space to internalOutputStream.writeString(String value) WritesStringto internalOutputStreamin ISO format.Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
outputStream
-
currentPos
protected long currentPos -
closeStream
protected boolean closeStream
-
-
Constructor Details
-
HighPrecisionOutputStream
Creates a newHighPrecisionOutputStreaminstance based onOutputStreaminstance.- Parameters:
-
outputStream- theHighPrecisionOutputStreaminstance.
-
HighPrecisionOutputStream
Creates a newHighPrecisionOutputStreaminstance based onOutputStreaminstance and precision setting value.- Parameters:
-
outputStream- theOutputStreaminstance. -
localHighPrecision- If true, all float and double values will be written with high precision. GlobalByteUtils.HighPrecisionsetting will be overridden by this one.
-
-
Method Details
-
getHighPrecision
public static boolean getHighPrecision()Gets global high precision setting.- Returns:
- global high precision setting.
-
setHighPrecision
public static void setHighPrecision(boolean value) Sets global high precision setting for allHighPrecisionOutputStreaminstances.- Parameters:
-
value- if true, all floats and double will be written with high precision in allHighPrecisionOutputStreaminstances.
-
getLocalHighPrecision
public boolean getLocalHighPrecision()Gets local high precision setting.- Returns:
- local high precision setting.
-
setLocalHighPrecision
public void setLocalHighPrecision(boolean value) Sets local high precision setting for theHighPrecisionOutputStream. GlobalByteUtils.HighPrecisionsetting will be overridden by this one.- Parameters:
-
value- if true, all floats and double will be written with high precision in the underlyingHighPrecisionOutputStream.
-
write
- Specified by:
-
writein classOutputStream - Throws:
-
IOException
-
write
- Overrides:
-
writein classOutputStream - Throws:
-
IOException
-
write
- Overrides:
-
writein classOutputStream - Throws:
-
IOException
-
writeByte
public void writeByte(byte value) - Parameters:
-
value- byte to write. - Throws:
-
IOException- ifIOExceptionoccurs.
-
flush
- Specified by:
-
flushin interfaceFlushable - Overrides:
-
flushin classOutputStream - Throws:
-
IOException
-
close
- Specified by:
-
closein interfaceAutoCloseable - Specified by:
-
closein interfaceCloseable - Overrides:
-
closein classOutputStream - Throws:
-
IOException
-
writeLong
Writes long to internalOutputStreamin ISO format.- Parameters:
-
value- value to write. - Returns:
- this stream as passed generic stream.
-
writeInteger
Writes int to internalOutputStreamin ISO format.- Parameters:
-
value- value to write. - Returns:
- this stream as passed generic stream.
-
writeFloat
Writes float to internalOutputStreamin ISO format.- Parameters:
-
value- value to write. - Returns:
- this stream as passed generic stream.
-
writeFloat
Writes float to internalOutputStreamin ISO format.- Parameters:
-
value- value to write. -
highPrecision- If true, float value will be written with high precision. - Returns:
- this stream as passed generic stream.
-
writeFloats
Writes float array to internalOutputStreamin ISO format.- Parameters:
-
value- float array to write. - Returns:
- this stream as passed generic stream.
-
writeDouble
Writes double to internalOutputStreamin ISO format.- Parameters:
-
value- value to write. - Returns:
- this stream as passed generic stream.
-
writeDouble
Writes double to internalOutputStreamin ISO format.- Parameters:
-
value- value to write. -
highPrecision- If true, double value will be written with high precision. - Returns:
- this stream as passed generic stream.
-
writeByte
Writes byte to internalOutputStream.- Parameters:
-
value- value to write. - Returns:
- this stream as passed generic stream.
-
writeSpace
Writes space to internalOutputStream.- Returns:
- this stream as passed generic stream.
-
writeNewLine
Writes new line to internalOutputStream.- Returns:
- this stream as passed generic stream.
-
writeString
WritesStringto internalOutputStreamin ISO format.- Parameters:
-
value- string to write. - Returns:
- this stream as passed generic stream.
-
writeBytes
Seewrite(byte[]).- Parameters:
-
b- byte array to write. - Returns:
- this stream as passed generic stream.
- Throws:
-
IOException- ifIOExceptionis thrown.
-
writeBytes
- Parameters:
-
b- the data to write. -
off- the start offset in the data. -
len- the number of bytes to write. - Returns:
- this stream as passed generic stream.
- Throws:
-
IOException- ifIOExceptionis thrown.
-
getCurrentPos
public long getCurrentPos()Gets current output stream position.- Returns:
- current output stream position.
-
getOutputStream
Gets internalOutputStream.- Returns:
-
internal
OutputStream.
-
isCloseStream
public boolean isCloseStream()Returns true, if internalOutputStreamhave to be closed afterclose()call, false otherwise.- Returns:
- true if stream needs to be closed, false if it's done manually.
-
setCloseStream
public void setCloseStream(boolean closeStream) Sets internalOutputStreamto be closed afterclose().- Parameters:
-
closeStream- true if stream needs to be closed, false if it's done manually.
-
assignBytes
public void assignBytes(byte[] bytes, int count) - Parameters:
-
bytes- bytes to assign. -
count- number of bytes to assign.
-
reset
public void reset()- Throws:
-
IOException- if internalHighPrecisionOutputStreamis not aByteArrayOutputStreaminstance.
-