From db41968325bc24b6d91656afdd36b49c9e5ecda7 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 18 Jan 2007 08:41:51 +0000 Subject: * uses LONG_STRING in place of WIDE_STRING for properties set through FieldTable.setString() as these appear to all be equivalent (apart from the type code) * uses setString instead of setAsciiString in creation of the connection.start-ok frames client properties * uses 4 bytes for the size of the BINARY value type as per the spec posted on the wiki git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@497352 13f79535-47bb-0310-9956-ffa450edef68 --- .../common/src/main/java/org/apache/qpid/framing/AMQType.java | 6 +++--- .../src/main/java/org/apache/qpid/framing/EncodingUtils.java | 2 +- .../src/main/java/org/apache/qpid/framing/FieldTable.java | 11 +---------- 3 files changed, 5 insertions(+), 14 deletions(-) (limited to 'qpid/java/common/src/main') diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java index 23c1929205..5175eace1e 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java @@ -230,7 +230,7 @@ public enum AMQType { public int getEncodingSize(Object value) { - return 1 + (value == null ? 0 : ((byte[]) value).length); + return EncodingUtils.encodedLongstrLength((byte[]) value); } @@ -250,12 +250,12 @@ public enum AMQType public void writeValueImpl(Object value, ByteBuffer buffer) { - EncodingUtils.writeBytes(buffer, (byte[]) value); + EncodingUtils.writeLongstr(buffer, (byte[]) value); } public Object readValueFromBuffer(ByteBuffer buffer) { - return EncodingUtils.readBytes(buffer); + return EncodingUtils.readLongstr(buffer); } }, diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java index c4d568ba88..339f83588d 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java @@ -747,7 +747,7 @@ public class EncodingUtils } } - public static byte[] readLongstr(ByteBuffer buffer) throws AMQFrameDecodingException + public static byte[] readLongstr(ByteBuffer buffer) { long length = buffer.getUnsignedInt(); if (length == 0) diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java index 147601b9f9..1a72910536 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java @@ -448,7 +448,6 @@ public class FieldTable { return setProperty(string, AMQType.ASCII_STRING.asTypedValue(value)); } - } public Object setString(AMQShortString string, String value) @@ -460,15 +459,7 @@ public class FieldTable } else { - //FIXME: determine string encoding and set either WIDE or ASCII string -// if () - { - return setProperty(string, AMQType.WIDE_STRING.asTypedValue(value)); - } -// else -// { -// return setProperty(string, AMQType.ASCII_STRING.asTypedValue(value)); -// } + return setProperty(string, AMQType.LONG_STRING.asTypedValue(value)); } } -- cgit v1.2.1