Class ChannelImageOutputStream
java.lang.Object
org.apache.sis.internal.storage.io.ChannelData
org.apache.sis.internal.storage.io.ChannelDataOutput
org.apache.sis.internal.storage.io.ChannelImageOutputStream
- All Implemented Interfaces:
Closeable,DataOutput,Flushable,AutoCloseable,Markable
Adds the missing methods in
ChannelDataOutput for implementing the DataOutput interface.
Current implementation does not yet implements the ImageOutputStream sub-interface, but a future
implementation may do so.
We do not implement ImageOutputStream yet because the latter inherits all read operations from
ImageInputStream, while the org.apache.sis.internal.storage package keeps the concerns
separated. Despite that, the name of this ChannelImageOutputStream anticipates a future version
which would implement the image I/O interface.
DataOutput methods are defined in this separated class rather than in the parent class
because some methods are Java 1.0 legacy and should be avoided (e.g. writeBytes(String)).
- Since:
- 0.5
- Version:
- 0.5
-
Field Summary
Fields inherited from class org.apache.sis.internal.storage.io.ChannelDataOutput
channelFields inherited from class org.apache.sis.internal.storage.io.ChannelData
buffer, bufferOffset, channelOffset, filename -
Constructor Summary
ConstructorsConstructorDescriptionChannelImageOutputStream(String filename, WritableByteChannel channel, ByteBuffer buffer) Creates a new output stream for the given channel and using the given buffer.Creates a new output source from the givenChannelDataOutput. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()Closes the ChannelDataOutput.channel.final voidwrite(int v) Writes a single byte to the stream at the current position.final voidwriteBoolean(boolean v) Writes boolean value (8 bits) into the steam.voidwriteBytes(String s) Writes the lower-order byte of each character.final voidwriteChars(String s) Writes all characters from the source into the stream.voidWrites two bytes of length information to the output stream, followed by the modified UTF-8 representation of every character in thestrstring.Methods inherited from class org.apache.sis.internal.storage.io.ChannelDataOutput
ensureBufferAccepts, flush, flushAndSetPosition, getStreamPosition, seek, write, write, writeBit, writeBits, writeByte, writeChar, writeChars, writeChars, writeDouble, writeDoubles, writeDoubles, writeFloat, writeFloats, writeFloats, writeInt, writeInts, writeInts, writeLong, writeLongs, writeLongs, writeShort, writeShorts, writeShortsMethods inherited from class org.apache.sis.internal.storage.io.ChannelData
clearBitOffset, flushBefore, getBitOffset, getFlushedPosition, mark, onEmptyTransfer, readBitFromBuffer, reset, reset, setBitOffset, setStreamPosition, skipRemainingBits, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.io.DataOutput
write, write, writeByte, writeChar, writeDouble, writeFloat, writeInt, writeLong, writeShort
-
Constructor Details
-
ChannelImageOutputStream
public ChannelImageOutputStream(String filename, WritableByteChannel channel, ByteBuffer buffer) throws IOException Creates a new output stream for the given channel and using the given buffer.- Parameters:
filename- a file identifier used only for formatting error message.channel- the channel where to write data.buffer- the buffer from where to read the data.- Throws:
IOException- if an error occurred while writing into channel.
-
ChannelImageOutputStream
Creates a new output source from the givenChannelDataOutput. This constructor is invoked when we need to change the implementation class fromChannelDataOutputtoChannelImageOutputStream.- Parameters:
output- the existing instance from which to takes the channel and buffer.- Throws:
IOException- if an error occurred while writing into channel.
-
-
Method Details
-
write
Writes a single byte to the stream at the current position. The 24 high-order bits ofvare ignored.- Specified by:
writein interfaceDataOutput- Parameters:
v- an integer whose lower 8 bits are to be written.- Throws:
IOException- if some I/O exception occurs during writing.
-
writeBoolean
Writes boolean value (8 bits) into the steam. This method delegates to ChannelDataOutput.writeByte(int). If booleanvistruethe byte value 1 is written whereas if boolean isfalsezero is written.- Specified by:
writeBooleanin interfaceDataOutput- Parameters:
v- boolean to be written.- Throws:
IOException- if some I/O exception occurs during writing.
-
writeBytes
Writes the lower-order byte of each character. The high-order eight bits of each character in the string are ignored - this method does not applies any encoding.This method is provided because required by the
DataOutputinterface, but its usage should generally be avoided.- Specified by:
writeBytesin interfaceDataOutput- Parameters:
s- the string to be written.- Throws:
IOException- if an error occurred while writing the stream.
-
writeChars
Writes all characters from the source into the stream.- Specified by:
writeCharsin interfaceDataOutput- Parameters:
s- a String consider as an array of characters to be written into stream.- Throws:
IOException- if an error occurred while writing the stream.
-
writeUTF
Writes two bytes of length information to the output stream, followed by the modified UTF-8 representation of every character in thestrstring. Each character is converted to a group of one, two, or three bytes, depending on the character code point value.- Specified by:
writeUTFin interfaceDataOutput- Parameters:
s- the string to be written.- Throws:
IOException- if an error occurred while writing the stream.
-
close
Closes the ChannelDataOutput.channel.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an error occurred while closing the channel.
-