[
https://issues.apache.org/jira/browse/DIRMINA-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12615949#action_12615949
]
Rich Dougherty commented on DIRMINA-489:
----------------------------------------
Hi Mark
I've added a patch which shows how this can be done, but here's a bit more
explanation. For reference, here's the core code:
+ ByteArray ba1 = wrapString("Hello");
+ ByteArray ba2 = wrapString("MINA");
+ ByteArray ba3 = wrapString("World");
+
+ CompositeByteArray cba = new CompositeByteArray();
+ cba.addLast(ba1);
+ cba.addLast(ba2);
+ cba.addLast(ba3);
+
+ assertEquals("HelloMINAWorld", toString(cba));
CompositeByteArray is the right class for that task, and the method you want is
'addLast'. You can also 'addFirst' if you like. If you want transparent
automatic expansion of the CompositeByteArray, using only 'put' methods, check
out CompositeByteArrayRelativeWriter.
A CompositeByteArray is made of other ByteArrays. This means you can't add
IoBuffers directly; you'd need to convert or copy them into a ByteArray first.
In your case you can just make the Strings directly into ByteArrays - see the
'wrapString' method in the patch.
Currently ByteArrays are quite low-level. They only really deal with getting
and putting ByteBuffers and primitives. So there's currently no support for
getting or putting Strings, IoBuffers and byte[]s. However, I think these
things should be fairly easy to add, if they're needed.
Cheers
Rich
> Composite IoBuffer
> ------------------
>
> Key: DIRMINA-489
> URL: https://issues.apache.org/jira/browse/DIRMINA-489
> Project: MINA
> Issue Type: New Feature
> Components: Core
> Reporter: David M. Lloyd
> Fix For: 2.0.0-M3
>
> Attachments: mina-composite-20080515.patch.gz,
> mina-composite-20080517.patch, mina-composite-20080521-2.patch,
> mina-composite-20080521.patch, mina-composite-20080723-1.patch,
> mina-composite-20080723-2.patch
>
>
> Provide a way to create a large IoBuffer from several smaller IoBuffers,
> without copying the underlying data.
> It would probably be acceptable to constrain the composite buffer in various
> ways, for example by disallowing autoexpanding or otherwise changing the
> capacity, the implementation could be greatly simplified.
> The goal is to be able to process large messages with a minimum of copying.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.