From b10ee442673d6d9c8abb46bd7a0606364930130d Mon Sep 17 00:00:00 2001 From: Steven Shaw Date: Tue, 12 Dec 2006 17:36:17 +0000 Subject: QPID-139. Initial (re)port of MINA's bytebuffer abstraction. Now includes the autoexpand feature. References to java.nio.Buffer were replaced with FixedByteBuffer and necessary methods added and implemented. FixedByteBuffer delegates to our existing HeapByteBuffer. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@486248 13f79535-47bb-0310-9956-ffa450edef68 --- dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs') diff --git a/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs b/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs index a9b7d629db..650186a90b 100644 --- a/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs +++ b/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs @@ -90,7 +90,7 @@ namespace Qpid.Client.Message { if (_data != null) { - _data.Release(); + _data.release(); } _data = null; _decodedValue = null; @@ -122,15 +122,20 @@ namespace Qpid.Client.Message return _decodedValue; } else - { + { + // Read remaining bytes. + byte[] bytes = new byte[_data.remaining()]; + _data.get(bytes); + + // Convert to string based on encoding. if (ContentHeaderProperties.Encoding != null) { // throw ArgumentException if the encoding is not supported - _decodedValue = Encoding.GetEncoding(ContentHeaderProperties.Encoding).GetString(_data.ToByteArray()); + _decodedValue = Encoding.GetEncoding(ContentHeaderProperties.Encoding).GetString(bytes); } else { - _decodedValue = Encoding.Default.GetString(_data.ToByteArray()); + _decodedValue = Encoding.Default.GetString(bytes); } return _decodedValue; } @@ -148,7 +153,7 @@ namespace Qpid.Client.Message // throw ArgumentException if the encoding is not supported bytes = Encoding.GetEncoding(ContentHeaderProperties.Encoding).GetBytes(value); } - _data = HeapByteBuffer.wrap(bytes, bytes.Length); + _data = ByteBuffer.wrap(bytes); _decodedValue = value; } } -- cgit v1.2.1