Commit 8080c7c
authored
Add NIO channel support to
* feat: add NIO channel support to `AbstractStreamBuilder`
Some builders derived from `AbstractStreamBuilder` (for example, `SevenZFile.Builder` in Commons Compress) need to produce a `SeekableByteChannel` as their data source. Until now this required ad-hoc `instanceof` switches across different origin types.
This change integrates channel support directly into the origin/builder abstraction, leading to a cleaner and more object-oriented design.
### Key changes
* Add `getReadableByteChannel()` and `getWritableByteChannel()` to `AbstractOrigin` and propagate to `AbstractStreamBuilder`.
* Introduce `ChannelOrigin`, an `AbstractOrigin` implementation backed by an existing `ReadableByteChannel`/`WritableByteChannel`.
* Add `ByteArrayChannel`, a simple in-memory `SeekableByteChannel` implementation.
* Extend unit tests to cover the new methods and types.
* fix: cleanup on Windows
* fix: checkstyle violation
* fix: merge `ByteArrayChannel` and `ByteArraySeekableByteChannel`
* fix: failing test
* fix: remove irrelevant changes
* fix: changelog
* fix: make `data` private
* fix: refine `ByteArraySeekableByteChannel` Javadoc
Clarifies the Javadoc to better reflect the intended usage patterns:
* `wrap(byte[])` is modeled after `ByteArrayInputStream` and is primarily for read-oriented use.
* The public constructors `ByteArraySeekableByteChannel()` and `ByteArraySeekableByteChannel(int)` follow the pattern of `ByteArrayOutputStream` and are mainly suited for write-oriented use.
* fix: add missing `@Override` annotation
* fix: typo in default size value
* feat: add generic `getChannel(Class<C>)` accessor
Adds a type-safe `getChannel(Class<C>)` method that lets callers request any supported `Channel` subtype (e.g. `ReadableByteChannel`, `WritableByteChannel`, `SeekableByteChannel`) through a single entry point.
* fix: rename `doGetChannel` to `getChannel`
* fix: Javadoc
* fix: default capacity of `ByteArraySeekableByteChannel`
* fix: rename `getTestData` to `cloneTestData`
* docs: minimum channel type by origin
* fix: make `getChannel` final
* fix: don't clone `testData`
Cloning the test data is unnecessary as all but one test are not supposed to modify them.
* fix: test orderAbstractStreamBuilder (#784)1 parent 2b755f3 commit 8080c7c
File tree
22 files changed
+1085
-77
lines changed- src
- changes
- main/java/org/apache/commons/io
- build
- channels
- test/java/org/apache/commons/io
- build
- channels
22 files changed
+1085
-77
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
0 commit comments