summaryrefslogtreecommitdiff
path: root/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2007-02-26 17:46:07 +0000
committerRobert Greig <rgreig@apache.org>2007-02-26 17:46:07 +0000
commita019367dc582d61fa3739f385592c0baf9b972b8 (patch)
tree5ce170123120f788d07d472e2febf6b32f17dc29 /qpid/dotnet/Qpid.Common/Framing/FieldTable.cs
parent2e9743ac06fc05609155769bf04f4fa442d848c2 (diff)
downloadqpid-python-a019367dc582d61fa3739f385592c0baf9b972b8.tar.gz
(Patch submitted by Tomas Restrepo) QPID-ByteBuffer.diff.
Completely refactors the byte buffer implementation, doing away with a complex inheritance hierarchy. Fixes reading and writing of field table to permit interop with Java client. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@511923 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/dotnet/Qpid.Common/Framing/FieldTable.cs')
-rw-r--r--qpid/dotnet/Qpid.Common/Framing/FieldTable.cs29
1 files changed, 16 insertions, 13 deletions
diff --git a/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs b/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs
index b977bef0ba..fe83fff721 100644
--- a/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs
+++ b/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs
@@ -50,10 +50,10 @@ namespace Qpid.Framing
/// <exception cref="AMQFrameDecodingException">if there is an error decoding the table</exception>
public FieldTable(ByteBuffer buffer, uint length) : this()
{
- _encodedForm = buffer.slice();
- _encodedForm.limit((int)length);
+ _encodedForm = buffer.Slice();
+ _encodedForm.Limit = (int)length;
_encodedSize = length;
- buffer.skip((int)length);
+ buffer.Skip((int)length);
}
/// <summary>
@@ -312,6 +312,7 @@ namespace Qpid.Framing
/// <returns>The enumerator object</returns>
public IEnumerator GetEnumerator()
{
+ InitMapIfNecessary();
return _properties.GetEnumerator();
}
@@ -322,6 +323,7 @@ namespace Qpid.Framing
/// <returns>True if the property exists</returns>
public bool Contains(string s)
{
+ InitMapIfNecessary();
return _properties.Contains(s);
}
@@ -332,6 +334,7 @@ namespace Qpid.Framing
/// <returns>The internal dictionary</returns>
public IDictionary AsDictionary()
{
+ InitMapIfNecessary();
return _properties;
}
@@ -381,11 +384,11 @@ namespace Qpid.Framing
/// <returns>An array of bytes</returns>
public byte[] GetDataAsBytes()
{
- ByteBuffer buffer = ByteBuffer.allocate((int)_encodedSize);
+ ByteBuffer buffer = ByteBuffer.Allocate((int)_encodedSize);
WritePayload(buffer);
byte[] result = new byte[_encodedSize];
- buffer.flip();
- buffer.get(result);
+ buffer.Flip();
+ buffer.GetBytes(result);
//buffer.Release();
return result;
}
@@ -527,7 +530,7 @@ namespace Qpid.Framing
bool trace = _log.IsDebugEnabled;
if ( length > 0 )
{
- int expectedRemaining = buffer.remaining() - (int)length;
+ int expectedRemaining = buffer.Remaining - (int)length;
_properties = new LinkedHashtable();
do
@@ -540,7 +543,7 @@ namespace Qpid.Framing
}
_properties.Add(key, value);
- } while ( buffer.remaining() > expectedRemaining );
+ } while ( buffer.Remaining > expectedRemaining );
_encodedSize = length;
}
if ( trace )
@@ -595,7 +598,7 @@ namespace Qpid.Framing
{
if ( _encodedForm != null )
{
- buffer.put(_encodedForm);
+ buffer.Put(_encodedForm);
} else if ( _properties != null )
{
foreach ( DictionaryEntry de in _properties )
@@ -609,8 +612,8 @@ namespace Qpid.Framing
_log.Debug("Writing Property:" + key +
" Type:" + value.Type +
" Value:" + value.Value);
- _log.Debug("Buffer Position:" + buffer.position() +
- " Remaining:" + buffer.remaining());
+ _log.Debug("Buffer Position:" + buffer.Position +
+ " Remaining:" + buffer.Remaining);
}
//Write the actual parameter name
EncodingUtils.WriteShortStringBytes(buffer, key);
@@ -623,8 +626,8 @@ namespace Qpid.Framing
_log.Debug("Writing Property:" + key +
" Type:" + value.Type +
" Value:" + value.Value);
- _log.Debug("Buffer Position:" + buffer.position() +
- " Remaining:" + buffer.remaining());
+ _log.Debug("Buffer Position:" + buffer.Position +
+ " Remaining:" + buffer.Remaining);
}
}
}