diff options
| author | Steven Shaw <steshaw@apache.org> | 2006-12-12 17:36:17 +0000 |
|---|---|---|
| committer | Steven Shaw <steshaw@apache.org> | 2006-12-12 17:36:17 +0000 |
| commit | b10ee442673d6d9c8abb46bd7a0606364930130d (patch) | |
| tree | 07827981760e15f8dcf5f5af892c3a0bad2eba66 /dotnet/Qpid.Common/Framing/EncodingUtils.cs | |
| parent | 7d0a7581134379324b36d78f8c49dcd793d1ab1e (diff) | |
| download | qpid-python-b10ee442673d6d9c8abb46bd7a0606364930130d.tar.gz | |
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
Diffstat (limited to 'dotnet/Qpid.Common/Framing/EncodingUtils.cs')
| -rw-r--r-- | dotnet/Qpid.Common/Framing/EncodingUtils.cs | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/dotnet/Qpid.Common/Framing/EncodingUtils.cs b/dotnet/Qpid.Common/Framing/EncodingUtils.cs index 748f3c9a0c..bb51f14b18 100644 --- a/dotnet/Qpid.Common/Framing/EncodingUtils.cs +++ b/dotnet/Qpid.Common/Framing/EncodingUtils.cs @@ -91,14 +91,14 @@ namespace Qpid.Framing encodedString = DEFAULT_ENCODER.GetBytes(s); } // TODO: check length fits in an unsigned byte - buffer.Put((byte) encodedString.Length); - buffer.Put(encodedString); + buffer.put((byte) encodedString.Length); + buffer.put(encodedString); } else { // really writing out unsigned byte - buffer.Put((byte) 0); + buffer.put((byte) 0); } } @@ -110,17 +110,17 @@ namespace Qpid.Framing } if (s != null) { - buffer.Put((uint)s.Length); + buffer.put((uint)s.Length); byte[] encodedString = null; lock (DEFAULT_ENCODER) { encodedString = DEFAULT_ENCODER.GetBytes(s); } - buffer.Put(encodedString); + buffer.put(encodedString); } else { - buffer.Put((uint) 0); + buffer.put((uint) 0); } } @@ -132,7 +132,7 @@ namespace Qpid.Framing } else { - buffer.Put((uint) 0); + buffer.put((uint) 0); } } @@ -147,25 +147,25 @@ namespace Qpid.Framing } } - buffer.Put(packedValue); + buffer.put(packedValue); } public static void WriteLongstr(ByteBuffer buffer, byte[] data) { if (data != null) { - buffer.Put((uint) data.Length); - buffer.Put(data); + buffer.put((uint) data.Length); + buffer.put(data); } else { - buffer.Put((uint) 0); + buffer.put((uint) 0); } } public static bool[] ReadBooleans(ByteBuffer buffer) { - byte packedValue = buffer.Get(); + byte packedValue = buffer.get(); bool[] result = new bool[8]; for (int i = 0; i < 8; i++) @@ -202,39 +202,46 @@ namespace Qpid.Framing /// <exception cref="AMQFrameDecodingException">if the buffer does not contain a decodable short string</exception> public static string ReadShortString(ByteBuffer buffer) { - byte length = buffer.Get(); + byte length = buffer.get(); if (length == 0) { return null; } else { + byte[] data = new byte[length]; + buffer.get(data); + lock (DEFAULT_ENCODER) { - return buffer.GetString(length, DEFAULT_ENCODER); + return DEFAULT_ENCODER.GetString(data); +// return buffer.GetString(length, DEFAULT_ENCODER); } } } public static string ReadLongString(ByteBuffer buffer) { - uint length = buffer.GetUnsignedInt(); + uint length = buffer.getUnsignedInt(); if (length == 0) { return null; } else - { + { + byte[] data = new byte[length]; + buffer.get(data); lock (DEFAULT_ENCODER) { - return buffer.GetString(length, DEFAULT_ENCODER); + return DEFAULT_ENCODER.GetString(data); + //return buffer.GetString(length, DEFAULT_ENCODER); } } } public static byte[] ReadLongstr(ByteBuffer buffer) { - uint length = buffer.GetUnsignedInt(); + uint length = buffer.getUnsignedInt(); if (length == 0) { return null; @@ -242,7 +249,7 @@ namespace Qpid.Framing else { byte[] result = new byte[length]; - buffer.Get(result); + buffer.get(result); return result; } } |
