Details
-
Wish
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
I think the interface RandomAccessContent should not extend DataOutput nor DataInput;
Instead, it could declare the following new methods:
1) int read(byte b[], int off, int len) throws IOException;
2) void write(byte b[], int off, int len) throws IOException;
3) int pread(long pos, byte b[], int off, int len) throws IOException;
4) void pwrite(long pos, byte b[], int off, int len) throws IOException;
Instead of changing this interface, a new one could be created (RandomAccessStream, maybe).
Benefits:
Currently, if a class implements this interface, it has to implement method "skipBytes", which is redundant since it already implements method "seek".
It also has to implement 14 methods related to reading, which is also redundant since they can be expressed in terms of specific calls to more primitive methods such as those proposed above.
In other words, I don't think different classes implementing RandomAccessContent (or RandomAccessStream) should all implement methods "readShort", "readInt"", "readLong", etc, since all implementations of them will be the same, if they are expressed in terms of calls to read(byte b[], int off, int len).