You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2017/12/01 21:11:56 UTC
[3/4] qpid-proton-j git commit: PROTON-1708 Optimizations for the
EncoderImpl and DecoderImpl
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/StringType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/StringType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/StringType.java
index a035e94..91476bc 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/StringType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/StringType.java
@@ -21,35 +21,34 @@
package org.apache.qpid.proton.codec;
import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.util.Arrays;
import java.util.Collection;
public class StringType extends AbstractPrimitiveType<String>
{
- private static final Charset Charset_UTF8 = Charset.forName("UTF-8");
private static final DecoderImpl.TypeDecoder<String> _stringCreator =
- new DecoderImpl.TypeDecoder<String>()
- {
+ new DecoderImpl.TypeDecoder<String>()
+ {
- public String decode(final ByteBuffer buf)
+ public String decode(DecoderImpl decoder, final ByteBuffer buf)
+ {
+ CharsetDecoder charsetDecoder = decoder.getCharsetDecoder();
+ try
{
- CharsetDecoder charsetDecoder = Charset_UTF8.newDecoder();
- try
- {
- CharBuffer charBuf = charsetDecoder.decode(buf);
- return charBuf.toString();
- }
- catch (CharacterCodingException e)
- {
- throw new IllegalArgumentException("Cannot parse String");
- }
-
+ return decoder.getCharsetDecoder().decode(buf).toString();
+ }
+ catch (CharacterCodingException e)
+ {
+ throw new IllegalArgumentException("Cannot parse String");
+ }
+ finally
+ {
+ charsetDecoder.reset();
}
- };
+ }
+ };
public static interface StringEncoding extends PrimitiveTypeEncoding<String>
@@ -175,6 +174,13 @@ public class StringType extends AbstractPrimitiveType<String>
_length = length;
}
+ public void skipValue()
+ {
+ DecoderImpl decoder = getDecoder();
+ ByteBuffer buffer = decoder.getByteBuffer();
+ int size = decoder.readRawInt();
+ buffer.position(buffer.position() + size);
+ }
}
private class ShortStringEncoding
@@ -233,6 +239,14 @@ public class StringType extends AbstractPrimitiveType<String>
_value = val;
_length = length;
}
+
+ public void skipValue()
+ {
+ DecoderImpl decoder = getDecoder();
+ ByteBuffer buffer = decoder.getByteBuffer();
+ int size = ((int)decoder.readRawByte()) & 0xff;
+ buffer.position(buffer.position() + size);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/SymbolType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/SymbolType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/SymbolType.java
index 4fb2038..e333e6a 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/SymbolType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/SymbolType.java
@@ -39,10 +39,9 @@ public class SymbolType extends AbstractPrimitiveType<Symbol>
private DecoderImpl.TypeDecoder<Symbol> _symbolCreator =
new DecoderImpl.TypeDecoder<Symbol>()
{
-
- public Symbol decode(final ByteBuffer buf)
+ @Override
+ public Symbol decode(DecoderImpl decoder, ByteBuffer buf)
{
-
Symbol symbol = _symbolCache.get(buf);
if(symbol == null)
{
@@ -76,12 +75,27 @@ public class SymbolType extends AbstractPrimitiveType<Symbol>
return Symbol.class;
}
+ public void fastWrite(EncoderImpl encoder, Symbol symbol)
+ {
+ if (symbol.length() <= 255)
+ {
+ encoder.writeRaw(EncodingCodes.SYM8);
+ encoder.writeRaw((byte) symbol.length());
+ symbol.writeTo(encoder.getBuffer());
+ }
+ else
+ {
+ encoder.writeRaw(EncodingCodes.SYM32);
+ encoder.writeRaw(symbol.length());
+ symbol.writeTo(encoder.getBuffer());
+ }
+ }
+
public SymbolEncoding getEncoding(final Symbol val)
{
return val.length() <= 255 ? _shortSymbolEncoding : _symbolEncoding;
}
-
public SymbolEncoding getCanonicalEncoding()
{
return _symbolEncoding;
@@ -105,13 +119,7 @@ public class SymbolType extends AbstractPrimitiveType<Symbol>
@Override
protected void writeEncodedValue(final Symbol val)
{
- final int length = val.length();
- final EncoderImpl encoder = getEncoder();
-
- for(int i = 0; i < length; i++)
- {
- encoder.writeRaw((byte)val.charAt(i));
- }
+ val.writeTo(getEncoder().getBuffer());
}
@Override
@@ -143,8 +151,16 @@ public class SymbolType extends AbstractPrimitiveType<Symbol>
int size = decoder.readRawInt();
return decoder.readRaw(_symbolCreator, size);
}
+
+ public void skipValue()
+ {
+ DecoderImpl decoder = getDecoder();
+ ByteBuffer buffer = decoder.getByteBuffer();
+ int size = decoder.readRawInt();
+ buffer.position(buffer.position() + size);
+ }
}
-
+
private class ShortSymbolEncoding
extends SmallFloatingSizePrimitiveTypeEncoding<Symbol>
implements SymbolEncoding
@@ -158,14 +174,7 @@ public class SymbolType extends AbstractPrimitiveType<Symbol>
@Override
protected void writeEncodedValue(final Symbol val)
{
-
- final int length = val.length();
- final EncoderImpl encoder = getEncoder();
-
- for(int i = 0; i < length; i++)
- {
- encoder.writeRaw((byte)val.charAt(i));
- }
+ val.writeTo(getEncoder().getBuffer());
}
@Override
@@ -197,5 +206,13 @@ public class SymbolType extends AbstractPrimitiveType<Symbol>
int size = ((int)decoder.readRawByte()) & 0xff;
return decoder.readRaw(_symbolCreator, size);
}
+
+ public void skipValue()
+ {
+ DecoderImpl decoder = getDecoder();
+ ByteBuffer buffer = decoder.getByteBuffer();
+ int size = ((int)decoder.readRawByte()) & 0xff;
+ buffer.position(buffer.position() + size);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/TimestampType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/TimestampType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/TimestampType.java
index 54baa25..c2efe08 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/TimestampType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/TimestampType.java
@@ -45,6 +45,11 @@ public class TimestampType extends AbstractPrimitiveType<Date>
return _timestampEncoding;
}
+ public void fastWrite(EncoderImpl encoder, long timestamp)
+ {
+ encoder.writeRaw(EncodingCodes.TIMESTAMP);
+ encoder.writeRaw(timestamp);
+ }
public TimestampEncoding getCanonicalEncoding()
{
@@ -60,7 +65,7 @@ public class TimestampType extends AbstractPrimitiveType<Date>
{
_timestampEncoding.write(l);
}
-
+
private class TimestampEncoding extends FixedSizePrimitiveTypeEncoding<Date>
{
@@ -90,12 +95,12 @@ public class TimestampType extends AbstractPrimitiveType<Date>
{
getEncoder().writeRaw(val.getTime());
}
-
+
public void write(final long l)
{
writeConstructor();
getEncoder().writeRaw(l);
-
+
}
public boolean encodesSuperset(final TypeEncoding<Date> encoding)
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeConstructor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeConstructor.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeConstructor.java
index 7b3f3a0..a707209 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeConstructor.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/TypeConstructor.java
@@ -24,6 +24,8 @@ public interface TypeConstructor<V>
{
V readValue();
+ void skipValue();
+
boolean encodesJavaPrimitive();
Class<V> getTypeClass();
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/UUIDType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/UUIDType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/UUIDType.java
index 20b9002..99f63f4 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/UUIDType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/UUIDType.java
@@ -45,6 +45,12 @@ public class UUIDType extends AbstractPrimitiveType<UUID>
return _uuidEncoding;
}
+ public void fastWrite(EncoderImpl encoder, UUID value)
+ {
+ encoder.writeRaw(EncodingCodes.UUID);
+ encoder.writeRaw(value.getMostSignificantBits());
+ encoder.writeRaw(value.getLeastSignificantBits());
+ }
public UUIDEncoding getCanonicalEncoding()
{
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedByteType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedByteType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedByteType.java
index 781a9de..184d8be 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedByteType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedByteType.java
@@ -46,6 +46,11 @@ public class UnsignedByteType extends AbstractPrimitiveType<UnsignedByte>
return _unsignedByteEncoding;
}
+ public void fastWrite(EncoderImpl encoder, UnsignedByte value)
+ {
+ encoder.writeRaw(EncodingCodes.UBYTE);
+ encoder.writeRaw(value.byteValue());
+ }
public UnsignedByteEncoding getCanonicalEncoding()
{
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedIntegerType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedIntegerType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedIntegerType.java
index 860e373..ce64484 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedIntegerType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedIntegerType.java
@@ -59,6 +59,24 @@ public class UnsignedIntegerType extends AbstractPrimitiveType<UnsignedInteger>
: (i >= 0 && i <= 255) ? _smallUnsignedIntegerEncoding : _unsignedIntegerEncoding;
}
+ public void fastWrite(EncoderImpl encoder, UnsignedInteger value)
+ {
+ int intValue = value.intValue();
+ if (intValue == 0)
+ {
+ encoder.writeRaw(EncodingCodes.UINT0);
+ }
+ else if (intValue > 0 && intValue <= 255)
+ {
+ encoder.writeRaw(EncodingCodes.SMALLUINT);
+ encoder.writeRaw((byte)intValue);
+ }
+ else
+ {
+ encoder.writeRaw(EncodingCodes.UINT);
+ encoder.writeRaw(intValue);
+ }
+ }
public UnsignedIntegerEncoding getCanonicalEncoding()
{
@@ -102,12 +120,12 @@ public class UnsignedIntegerType extends AbstractPrimitiveType<UnsignedInteger>
{
getEncoder().writeRaw(val.intValue());
}
-
+
public void write(final int i)
{
writeConstructor();
getEncoder().writeRaw(i);
-
+
}
public boolean encodesSuperset(final TypeEncoding<UnsignedInteger> encoding)
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedLongType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedLongType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedLongType.java
index 4b7980e..715028a 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedLongType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedLongType.java
@@ -35,8 +35,8 @@ public class UnsignedLongType extends AbstractPrimitiveType<UnsignedLong>
private UnsignedLongEncoding _unsignedLongEncoding;
private UnsignedLongEncoding _smallUnsignedLongEncoding;
private UnsignedLongEncoding _zeroUnsignedLongEncoding;
-
-
+
+
UnsignedLongType(final EncoderImpl encoder, final DecoderImpl decoder)
{
_unsignedLongEncoding = new AllUnsignedLongEncoding(encoder, decoder);
@@ -59,6 +59,24 @@ public class UnsignedLongType extends AbstractPrimitiveType<UnsignedLong>
: (l >= 0 && l <= 255L) ? _smallUnsignedLongEncoding : _unsignedLongEncoding;
}
+ public void fastWrite(EncoderImpl encoder, UnsignedLong value)
+ {
+ long longValue = value.longValue();
+ if (longValue == 0)
+ {
+ encoder.writeRaw(EncodingCodes.ULONG0);
+ }
+ else if (longValue > 0 && longValue <= 255)
+ {
+ encoder.writeRaw(EncodingCodes.SMALLULONG);
+ encoder.writeRaw((byte)longValue);
+ }
+ else
+ {
+ encoder.writeRaw(EncodingCodes.ULONG);
+ encoder.writeRaw(longValue);
+ }
+ }
public UnsignedLongEncoding getCanonicalEncoding()
{
@@ -157,8 +175,8 @@ public class UnsignedLongType extends AbstractPrimitiveType<UnsignedLong>
return UnsignedLong.valueOf(((long)getDecoder().readRawByte())&0xffl);
}
}
-
-
+
+
private class ZeroUnsignedLongEncoding
extends FixedSizePrimitiveTypeEncoding<UnsignedLong>
implements UnsignedLongEncoding
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedShortType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedShortType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedShortType.java
index 378c207..a30ee46 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedShortType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/UnsignedShortType.java
@@ -46,6 +46,11 @@ public class UnsignedShortType extends AbstractPrimitiveType<UnsignedShort>
return _unsignedShortEncoder;
}
+ public void fastWrite(EncoderImpl encoder, UnsignedShort value)
+ {
+ encoder.writeRaw(EncodingCodes.USHORT);
+ encoder.writeRaw(value.shortValue());
+ }
public UnsignedShortEncoding getCanonicalEncoding()
{
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AcceptedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AcceptedType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AcceptedType.java
index 2da2d2b..32db983 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AcceptedType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AcceptedType.java
@@ -41,7 +41,7 @@ public final class AcceptedType extends AbstractDescribedType<Accepted,List> imp
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000024L);
- private AcceptedType(EncoderImpl encoder)
+ AcceptedType(EncoderImpl encoder)
{
super(encoder);
}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpSequenceType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpSequenceType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpSequenceType.java
index 8844893..054d34d 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpSequenceType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpSequenceType.java
@@ -42,7 +42,7 @@ public class AmqpSequenceType extends AbstractDescribedType<AmqpSequence,List> i
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000076L);
- private AmqpSequenceType(EncoderImpl encoder)
+ AmqpSequenceType(EncoderImpl encoder)
{
super(encoder);
}
@@ -68,7 +68,7 @@ public class AmqpSequenceType extends AbstractDescribedType<AmqpSequence,List> i
return AmqpSequence.class;
}
-
+
public static void register(Decoder decoder, EncoderImpl encoder)
{
@@ -80,4 +80,3 @@ public class AmqpSequenceType extends AbstractDescribedType<AmqpSequence,List> i
encoder.register(type);
}
}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpValueType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpValueType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpValueType.java
index d2dc8e1..9af847a 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpValueType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/AmqpValueType.java
@@ -42,7 +42,7 @@ public class AmqpValueType extends AbstractDescribedType<AmqpValue,Object> imple
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000077L);
- private AmqpValueType(EncoderImpl encoder)
+ AmqpValueType(EncoderImpl encoder)
{
super(encoder);
}
@@ -68,7 +68,7 @@ public class AmqpValueType extends AbstractDescribedType<AmqpValue,Object> imple
return AmqpValue.class;
}
-
+
public static void register(Decoder decoder, EncoderImpl encoder)
{
@@ -80,4 +80,3 @@ public class AmqpValueType extends AbstractDescribedType<AmqpValue,Object> imple
encoder.register(type);
}
}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DataType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DataType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DataType.java
index d7435c2..9ab06c0 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DataType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/DataType.java
@@ -43,7 +43,7 @@ public class DataType extends AbstractDescribedType<Data,Binary> implements Desc
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000075L);
- private DataType(EncoderImpl encoder)
+ DataType(EncoderImpl encoder)
{
super(encoder);
}
@@ -69,7 +69,7 @@ public class DataType extends AbstractDescribedType<Data,Binary> implements Desc
return Data.class;
}
-
+
public static void register(Decoder decoder, EncoderImpl encoder)
{
@@ -81,4 +81,3 @@ public class DataType extends AbstractDescribedType<Data,Binary> implements Desc
encoder.register(type);
}
}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAcceptedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAcceptedType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAcceptedType.java
new file mode 100644
index 0000000..3624836
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAcceptedType.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.codec.messaging;
+
+import java.util.Collection;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Accepted;
+import org.apache.qpid.proton.codec.AMQPType;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
+import org.apache.qpid.proton.codec.DecodeException;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.TypeEncoding;
+import org.apache.qpid.proton.codec.WritableBuffer;
+
+public class FastPathAcceptedType implements AMQPType<Accepted>, FastPathDescribedTypeConstructor<Accepted> {
+
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000024L), Symbol.valueOf("amqp:accepted:list"),
+ };
+
+ private final AcceptedType acceptedType;
+
+ public FastPathAcceptedType(EncoderImpl encoder) {
+ this.acceptedType = new AcceptedType(encoder);
+ }
+
+ public EncoderImpl getEncoder() {
+ return acceptedType.getEncoder();
+ }
+
+ public DecoderImpl getDecoder() {
+ return acceptedType.getDecoder();
+ }
+
+ @Override
+ public boolean encodesJavaPrimitive() {
+ return false;
+ }
+
+ @Override
+ public Class<Accepted> getTypeClass() {
+ return Accepted.class;
+ }
+
+ @Override
+ public TypeEncoding<Accepted> getEncoding(Accepted accepted) {
+ return acceptedType.getEncoding(accepted);
+ }
+
+ @Override
+ public TypeEncoding<Accepted> getCanonicalEncoding() {
+ return acceptedType.getCanonicalEncoding();
+ }
+
+ @Override
+ public Collection<? extends TypeEncoding<Accepted>> getAllEncodings() {
+ return acceptedType.getAllEncodings();
+ }
+
+ @Override
+ public Accepted readValue() {
+ DecoderImpl decoder = getDecoder();
+ byte typeCode = decoder.getByteBuffer().get();
+
+ switch (typeCode) {
+ case EncodingCodes.LIST0:
+ break;
+ case EncodingCodes.LIST8:
+ decoder.getByteBuffer().get();
+ decoder.getByteBuffer().get();
+ break;
+ case EncodingCodes.LIST32:
+ decoder.getByteBuffer().getInt();
+ decoder.getByteBuffer().getInt();
+ break;
+ default:
+ throw new DecodeException("Incorrect type found in Accepted type encoding: " + typeCode);
+ }
+
+ return Accepted.getInstance();
+ }
+
+ @Override
+ public void skipValue() {
+ getDecoder().readConstructor().skipValue();
+ }
+
+ @Override
+ public void write(Accepted accepted) {
+ WritableBuffer buffer = getEncoder().getBuffer();
+ buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
+ getEncoder().writeUnsignedLong(acceptedType.getDescriptor());
+ buffer.put(EncodingCodes.LIST0);
+ }
+
+ public static void register(Decoder decoder, EncoderImpl encoder) {
+ FastPathAcceptedType type = new FastPathAcceptedType(encoder);
+ for(Object descriptor : DESCRIPTORS) {
+ decoder.register(descriptor, (FastPathDescribedTypeConstructor<?>) type);
+ }
+ encoder.register(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpSequenceType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpSequenceType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpSequenceType.java
new file mode 100644
index 0000000..611ec10
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpSequenceType.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.codec.messaging;
+
+import java.util.Collection;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.AmqpSequence;
+import org.apache.qpid.proton.codec.AMQPType;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.TypeEncoding;
+import org.apache.qpid.proton.codec.WritableBuffer;
+
+public class FastPathAmqpSequenceType implements AMQPType<AmqpSequence>, FastPathDescribedTypeConstructor<AmqpSequence> {
+
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000076L), Symbol.valueOf("amqp:amqp-sequence:list"),
+ };
+
+ private final AmqpSequenceType sequenceType;
+
+ public FastPathAmqpSequenceType(EncoderImpl encoder) {
+ this.sequenceType = new AmqpSequenceType(encoder);
+ }
+
+ public EncoderImpl getEncoder() {
+ return sequenceType.getEncoder();
+ }
+
+ public DecoderImpl getDecoder() {
+ return sequenceType.getDecoder();
+ }
+
+ @Override
+ public boolean encodesJavaPrimitive() {
+ return false;
+ }
+
+ @Override
+ public Class<AmqpSequence> getTypeClass() {
+ return AmqpSequence.class;
+ }
+
+ @Override
+ public TypeEncoding<AmqpSequence> getEncoding(AmqpSequence val) {
+ return sequenceType.getEncoding(val);
+ }
+
+ @Override
+ public TypeEncoding<AmqpSequence> getCanonicalEncoding() {
+ return sequenceType.getCanonicalEncoding();
+ }
+
+ @Override
+ public Collection<? extends TypeEncoding<AmqpSequence>> getAllEncodings() {
+ return sequenceType.getAllEncodings();
+ }
+
+ @Override
+ public AmqpSequence readValue() {
+ return new AmqpSequence(getDecoder().readList());
+ }
+
+ @Override
+ public void skipValue() {
+ getDecoder().readConstructor().skipValue();
+ }
+
+ @Override
+ public void write(AmqpSequence sequence) {
+ WritableBuffer buffer = getEncoder().getBuffer();
+ buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
+ getEncoder().writeUnsignedLong(sequenceType.getDescriptor());
+ getEncoder().writeObject(sequence.getValue());
+ }
+
+ public static void register(Decoder decoder, EncoderImpl encoder) {
+ FastPathAmqpSequenceType type = new FastPathAmqpSequenceType(encoder);
+ for (Object descriptor : DESCRIPTORS) {
+ decoder.register(descriptor, (FastPathDescribedTypeConstructor<?>) type);
+ }
+ encoder.register(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpValueType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpValueType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpValueType.java
new file mode 100644
index 0000000..7120481
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathAmqpValueType.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.codec.messaging;
+
+import java.util.Collection;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.AmqpValue;
+import org.apache.qpid.proton.codec.AMQPType;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.TypeEncoding;
+import org.apache.qpid.proton.codec.WritableBuffer;
+
+public class FastPathAmqpValueType implements AMQPType<AmqpValue>, FastPathDescribedTypeConstructor<AmqpValue> {
+
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000077L), Symbol.valueOf("amqp:amqp-value:*"),
+ };
+
+ private final AmqpValueType valueType;
+
+ public FastPathAmqpValueType(EncoderImpl encoder) {
+ this.valueType = new AmqpValueType(encoder);
+ }
+
+ public EncoderImpl getEncoder() {
+ return valueType.getEncoder();
+ }
+
+ public DecoderImpl getDecoder() {
+ return valueType.getDecoder();
+ }
+
+ @Override
+ public boolean encodesJavaPrimitive() {
+ return false;
+ }
+
+ @Override
+ public Class<AmqpValue> getTypeClass() {
+ return AmqpValue.class;
+ }
+
+ @Override
+ public TypeEncoding<AmqpValue> getEncoding(AmqpValue value) {
+ return valueType.getEncoding(value);
+ }
+
+ @Override
+ public TypeEncoding<AmqpValue> getCanonicalEncoding() {
+ return valueType.getCanonicalEncoding();
+ }
+
+ @Override
+ public Collection<? extends TypeEncoding<AmqpValue>> getAllEncodings() {
+ return valueType.getAllEncodings();
+ }
+
+ @Override
+ public AmqpValue readValue() {
+ return new AmqpValue(getDecoder().readObject());
+ }
+
+ @Override
+ public void skipValue() {
+ getDecoder().readConstructor().skipValue();
+ }
+
+ @Override
+ public void write(AmqpValue value) {
+ WritableBuffer buffer = getEncoder().getBuffer();
+ buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
+ getEncoder().writeUnsignedLong(valueType.getDescriptor());
+ getEncoder().writeObject(value.getValue());
+ }
+
+ public static void register(Decoder decoder, EncoderImpl encoder) {
+ FastPathAmqpValueType type = new FastPathAmqpValueType(encoder);
+ for(Object descriptor : DESCRIPTORS) {
+ decoder.register(descriptor, (FastPathDescribedTypeConstructor<?>) type);
+ }
+ encoder.register(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathApplicationPropertiesType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathApplicationPropertiesType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathApplicationPropertiesType.java
new file mode 100644
index 0000000..4eed5e7
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathApplicationPropertiesType.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.codec.messaging;
+
+import java.util.Collection;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
+import org.apache.qpid.proton.codec.AMQPType;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.MapType;
+import org.apache.qpid.proton.codec.TypeEncoding;
+import org.apache.qpid.proton.codec.WritableBuffer;
+
+public class FastPathApplicationPropertiesType implements AMQPType<ApplicationProperties>, FastPathDescribedTypeConstructor<ApplicationProperties> {
+
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000074L), Symbol.valueOf("amqp:application-properties:map"),
+ };
+
+ private final ApplicationPropertiesType propertiesType;
+
+ public FastPathApplicationPropertiesType(EncoderImpl encoder) {
+ this.propertiesType = new ApplicationPropertiesType(encoder);
+ }
+
+ public EncoderImpl getEncoder() {
+ return propertiesType.getEncoder();
+ }
+
+ public DecoderImpl getDecoder() {
+ return propertiesType.getDecoder();
+ }
+
+ @Override
+ public boolean encodesJavaPrimitive() {
+ return false;
+ }
+
+ @Override
+ public Class<ApplicationProperties> getTypeClass() {
+ return ApplicationProperties.class;
+ }
+
+ @Override
+ public TypeEncoding<ApplicationProperties> getEncoding(ApplicationProperties val) {
+ return propertiesType.getEncoding(val);
+ }
+
+ @Override
+ public TypeEncoding<ApplicationProperties> getCanonicalEncoding() {
+ return propertiesType.getCanonicalEncoding();
+ }
+
+ @Override
+ public Collection<? extends TypeEncoding<ApplicationProperties>> getAllEncodings() {
+ return propertiesType.getAllEncodings();
+ }
+
+ @Override
+ public ApplicationProperties readValue() {
+ return new ApplicationProperties(getDecoder().readMap());
+ }
+
+ @Override
+ public void skipValue() {
+ getDecoder().readConstructor().skipValue();
+ }
+
+ @Override
+ public void write(ApplicationProperties val) {
+ WritableBuffer buffer = getEncoder().getBuffer();
+
+ buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
+ getEncoder().writeUnsignedLong(propertiesType.getDescriptor());
+
+ MapType mapType = (MapType) getEncoder().getType(val.getValue());
+
+ mapType.setKeyEncoding(getEncoder().getTypeFromClass(String.class));
+ mapType.write(val.getValue());
+ mapType.setKeyEncoding(null);
+ }
+
+ public static void register(Decoder decoder, EncoderImpl encoder) {
+ FastPathApplicationPropertiesType type = new FastPathApplicationPropertiesType(encoder);
+ for(Object descriptor : DESCRIPTORS)
+ {
+ decoder.register(descriptor, type);
+ }
+ encoder.register(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDataType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDataType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDataType.java
new file mode 100644
index 0000000..75a7543
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDataType.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.codec.messaging;
+
+import java.util.Collection;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Data;
+import org.apache.qpid.proton.codec.AMQPType;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.TypeEncoding;
+import org.apache.qpid.proton.codec.WritableBuffer;
+
+public class FastPathDataType implements AMQPType<Data>, FastPathDescribedTypeConstructor<Data> {
+
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000075L), Symbol.valueOf("amqp:data:binary"),
+ };
+
+ private final DataType dataType;
+
+ public FastPathDataType(EncoderImpl encoder) {
+ this.dataType = new DataType(encoder);
+ }
+
+ public EncoderImpl getEncoder() {
+ return dataType.getEncoder();
+ }
+
+ public DecoderImpl getDecoder() {
+ return dataType.getDecoder();
+ }
+
+ @Override
+ public boolean encodesJavaPrimitive() {
+ return false;
+ }
+
+ @Override
+ public Class<Data> getTypeClass() {
+ return dataType.getTypeClass();
+ }
+
+ @Override
+ public TypeEncoding<Data> getEncoding(Data val) {
+ return dataType.getEncoding(val);
+ }
+
+ @Override
+ public TypeEncoding<Data> getCanonicalEncoding() {
+ return dataType.getCanonicalEncoding();
+ }
+
+ @Override
+ public Collection<? extends TypeEncoding<Data>> getAllEncodings() {
+ return dataType.getAllEncodings();
+ }
+
+ @Override
+ public Data readValue() {
+ return new Data(getDecoder().readBinary());
+ }
+
+ @Override
+ public void skipValue() {
+ getDecoder().readConstructor().skipValue();
+ }
+
+ @Override
+ public void write(Data data) {
+ WritableBuffer buffer = getEncoder().getBuffer();
+ buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
+ getEncoder().writeUnsignedLong(dataType.getDescriptor());
+ getEncoder().writeBinary(data.getValue());
+ }
+
+ public static void register(Decoder decoder, EncoderImpl encoder) {
+ FastPathDataType type = new FastPathDataType(encoder);
+ for(Object descriptor : DESCRIPTORS) {
+ decoder.register(descriptor, (FastPathDescribedTypeConstructor<?>) type);
+ }
+ encoder.register(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDeliveryAnnotationsType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDeliveryAnnotationsType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDeliveryAnnotationsType.java
new file mode 100644
index 0000000..4252393
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathDeliveryAnnotationsType.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.codec.messaging;
+
+import java.util.Collection;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations;
+import org.apache.qpid.proton.codec.AMQPType;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
+import org.apache.qpid.proton.codec.MapType;
+import org.apache.qpid.proton.codec.TypeEncoding;
+import org.apache.qpid.proton.codec.WritableBuffer;
+
+public class FastPathDeliveryAnnotationsType implements AMQPType<DeliveryAnnotations>, FastPathDescribedTypeConstructor<DeliveryAnnotations> {
+
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000071L), Symbol.valueOf("amqp:delivery-annotations:map"),
+ };
+
+ private final DeliveryAnnotationsType annotationsType;
+
+ public FastPathDeliveryAnnotationsType(EncoderImpl encoder) {
+ this.annotationsType = new DeliveryAnnotationsType(encoder);
+ }
+
+ public EncoderImpl getEncoder() {
+ return annotationsType.getEncoder();
+ }
+
+ public DecoderImpl getDecoder() {
+ return annotationsType.getDecoder();
+ }
+
+ @Override
+ public boolean encodesJavaPrimitive() {
+ return false;
+ }
+
+ @Override
+ public Class<DeliveryAnnotations> getTypeClass() {
+ return DeliveryAnnotations.class;
+ }
+
+ @Override
+ public TypeEncoding<DeliveryAnnotations> getEncoding(DeliveryAnnotations val) {
+ return annotationsType.getEncoding(val);
+ }
+
+ @Override
+ public TypeEncoding<DeliveryAnnotations> getCanonicalEncoding() {
+ return annotationsType.getCanonicalEncoding();
+ }
+
+ @Override
+ public Collection<? extends TypeEncoding<DeliveryAnnotations>> getAllEncodings() {
+ return annotationsType.getAllEncodings();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public DeliveryAnnotations readValue() {
+ return new DeliveryAnnotations(getDecoder().readMap());
+ }
+
+ @Override
+ public void skipValue() {
+ getDecoder().readConstructor().skipValue();
+ }
+
+ @Override
+ public void write(DeliveryAnnotations val) {
+ WritableBuffer buffer = getEncoder().getBuffer();
+
+ buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
+ getEncoder().writeUnsignedLong(annotationsType.getDescriptor());
+
+ MapType mapType = (MapType) getEncoder().getType(val.getValue());
+
+ mapType.setKeyEncoding(getEncoder().getTypeFromClass(Symbol.class));
+ mapType.write(val.getValue());
+ mapType.setKeyEncoding(null);
+ }
+
+ public static void register(Decoder decoder, EncoderImpl encoder) {
+ FastPathDeliveryAnnotationsType type = new FastPathDeliveryAnnotationsType(encoder);
+ for(Object descriptor : DESCRIPTORS)
+ {
+ decoder.register(descriptor, type);
+ }
+ encoder.register(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathFooterType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathFooterType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathFooterType.java
new file mode 100644
index 0000000..d1b0d40
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathFooterType.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.codec.messaging;
+
+import java.util.Collection;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Footer;
+import org.apache.qpid.proton.codec.AMQPType;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
+import org.apache.qpid.proton.codec.MapType;
+import org.apache.qpid.proton.codec.TypeEncoding;
+import org.apache.qpid.proton.codec.WritableBuffer;
+
+public class FastPathFooterType implements AMQPType<Footer>, FastPathDescribedTypeConstructor<Footer> {
+
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000078L), Symbol.valueOf("amqp:footer:map"),
+ };
+
+ private final FooterType footerType;
+
+ public FastPathFooterType(EncoderImpl encoder) {
+ this.footerType = new FooterType(encoder);
+ }
+
+ public EncoderImpl getEncoder() {
+ return footerType.getEncoder();
+ }
+
+ public DecoderImpl getDecoder() {
+ return footerType.getDecoder();
+ }
+
+ @Override
+ public boolean encodesJavaPrimitive() {
+ return false;
+ }
+
+ @Override
+ public Class<Footer> getTypeClass() {
+ return Footer.class;
+ }
+
+ @Override
+ public TypeEncoding<Footer> getEncoding(Footer val) {
+ return footerType.getEncoding(val);
+ }
+
+ @Override
+ public TypeEncoding<Footer> getCanonicalEncoding() {
+ return footerType.getCanonicalEncoding();
+ }
+
+ @Override
+ public Collection<? extends TypeEncoding<Footer>> getAllEncodings() {
+ return footerType.getAllEncodings();
+ }
+
+ @Override
+ public Footer readValue() {
+ return new Footer(getDecoder().readMap());
+ }
+
+ @Override
+ public void skipValue() {
+ getDecoder().readConstructor().skipValue();
+ }
+
+ @Override
+ public void write(Footer val) {
+ WritableBuffer buffer = getEncoder().getBuffer();
+
+ buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
+ getEncoder().writeUnsignedLong(footerType.getDescriptor());
+
+ MapType mapType = (MapType) getEncoder().getType(val.getValue());
+
+ mapType.write(val.getValue());
+ }
+
+ public static void register(Decoder decoder, EncoderImpl encoder) {
+ FastPathFooterType type = new FastPathFooterType(encoder);
+ for(Object descriptor : DESCRIPTORS)
+ {
+ decoder.register(descriptor, type);
+ }
+ encoder.register(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathHeaderType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathHeaderType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathHeaderType.java
new file mode 100644
index 0000000..11c5223
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathHeaderType.java
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.codec.messaging;
+
+import java.util.Collection;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Header;
+import org.apache.qpid.proton.codec.AMQPType;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
+import org.apache.qpid.proton.codec.DecodeException;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.TypeEncoding;
+import org.apache.qpid.proton.codec.WritableBuffer;
+
+public class FastPathHeaderType implements AMQPType<Header>, FastPathDescribedTypeConstructor<Header> {
+
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000070L), Symbol.valueOf("amqp:header:list"),
+ };
+
+ private final HeaderType headerType;
+
+ public FastPathHeaderType(EncoderImpl encoder) {
+ this.headerType = new HeaderType(encoder);
+ }
+
+ public EncoderImpl getEncoder() {
+ return headerType.getEncoder();
+ }
+
+ public DecoderImpl getDecoder() {
+ return headerType.getDecoder();
+ }
+
+ @Override
+ public Header readValue() {
+ DecoderImpl decoder = getDecoder();
+ byte typeCode = decoder.getByteBuffer().get();
+
+ @SuppressWarnings("unused")
+ int size = 0;
+ int count = 0;
+
+ switch (typeCode) {
+ case EncodingCodes.LIST0:
+ break;
+ case EncodingCodes.LIST8:
+ size = ((int)decoder.getByteBuffer().get()) & 0xff;
+ count = ((int)decoder.getByteBuffer().get()) & 0xff;
+ break;
+ case EncodingCodes.LIST32:
+ size = decoder.getByteBuffer().getInt();
+ count = decoder.getByteBuffer().getInt();
+ break;
+ default:
+ throw new DecodeException("Incorrect type found in Transfer encoding: " + typeCode);
+ }
+
+ Header header = new Header();
+
+ for (int index = 0; index < count; ++index) {
+ switch (index) {
+ case 0:
+ header.setDurable(decoder.readBoolean());
+ break;
+ case 1:
+ header.setPriority(decoder.readUnsignedByte());
+ break;
+ case 2:
+ header.setTtl(decoder.readUnsignedInteger());
+ break;
+ case 3:
+ header.setFirstAcquirer(decoder.readBoolean());
+ break;
+ case 4:
+ header.setDeliveryCount(decoder.readUnsignedInteger());
+ break;
+ default:
+ throw new IllegalStateException("To many entries in Header encoding");
+ }
+ }
+
+ return header;
+ }
+
+ @Override
+ public void skipValue() {
+ getDecoder().readConstructor().skipValue();
+ }
+
+ @Override
+ public boolean encodesJavaPrimitive() {
+ return false;
+ }
+
+ @Override
+ public Class<Header> getTypeClass() {
+ return Header.class;
+ }
+
+ @Override
+ public TypeEncoding<Header> getEncoding(Header header) {
+ return headerType.getEncoding(header);
+ }
+
+ @Override
+ public TypeEncoding<Header> getCanonicalEncoding() {
+ return headerType.getCanonicalEncoding();
+ }
+
+ @Override
+ public Collection<? extends TypeEncoding<Header>> getAllEncodings() {
+ return headerType.getAllEncodings();
+ }
+
+ @Override
+ public void write(Header value) {
+ WritableBuffer buffer = getEncoder().getBuffer();
+ int count = getElementCount(value);
+ byte encodingCode = deduceEncodingCode(value, count);
+
+ buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
+ getEncoder().writeUnsignedLong(headerType.getDescriptor());
+
+ // Optimized step, no other data to be written.
+ if (count == 0 || encodingCode == EncodingCodes.LIST0) {
+ buffer.put(EncodingCodes.LIST0);
+ return;
+ }
+
+ final int fieldWidth;
+
+ if (encodingCode == EncodingCodes.LIST8) {
+ fieldWidth = 1;
+ buffer.put(EncodingCodes.LIST8);
+ } else {
+ fieldWidth = 4;
+ buffer.put(EncodingCodes.LIST32);
+ }
+
+ int startIndex = buffer.position();
+
+ // Reserve space for the size and write the count of list elements.
+ if (fieldWidth == 1) {
+ buffer.put((byte) 0);
+ buffer.put((byte) count);
+ } else {
+ buffer.putInt(0);
+ buffer.putInt(count);
+ }
+
+ // Write the list elements and then compute total size written.
+ for (int i = 0; i < count; ++i) {
+ writeElement(value, i);
+ }
+
+ // Move back and write the size
+ int endIndex = buffer.position();
+ int writeSize = endIndex - startIndex - fieldWidth;
+
+ buffer.position(startIndex);
+ if (fieldWidth == 1) {
+ buffer.put((byte) writeSize);
+ } else {
+ buffer.putInt(writeSize);
+ }
+ buffer.position(endIndex);
+ }
+
+ private void writeElement(Header header, int index) {
+ switch (index) {
+ case 0:
+ getEncoder().writeBoolean(header.getDurable());
+ break;
+ case 1:
+ getEncoder().writeUnsignedByte(header.getPriority());
+ break;
+ case 2:
+ getEncoder().writeUnsignedInteger(header.getTtl());
+ break;
+ case 3:
+ getEncoder().writeBoolean(header.getFirstAcquirer());
+ break;
+ case 4:
+ getEncoder().writeUnsignedInteger(header.getDeliveryCount());
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown Header value index: " + index);
+ }
+ }
+
+ private int getElementCount(Header header) {
+ if (header.getDeliveryCount() != null) {
+ return 5;
+ } else if (header.getFirstAcquirer() != null) {
+ return 4;
+ } else if (header.getTtl() != null) {
+ return 3;
+ } else if (header.getPriority() != null) {
+ return 2;
+ } else if (header.getDurable() != null) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ private byte deduceEncodingCode(Header value, int elementCount) {
+ if (elementCount == 0) {
+ return EncodingCodes.LIST0;
+ } else {
+ return EncodingCodes.LIST8;
+ }
+ }
+
+ public static void register(Decoder decoder, EncoderImpl encoder) {
+ FastPathHeaderType type = new FastPathHeaderType(encoder);
+ for(Object descriptor : DESCRIPTORS)
+ {
+ decoder.register(descriptor, (FastPathDescribedTypeConstructor<?>) type);
+ }
+ encoder.register(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathMessageAnnotationsType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathMessageAnnotationsType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathMessageAnnotationsType.java
new file mode 100644
index 0000000..6d32004
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathMessageAnnotationsType.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.codec.messaging;
+
+import java.util.Collection;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.MessageAnnotations;
+import org.apache.qpid.proton.codec.AMQPType;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.MapType;
+import org.apache.qpid.proton.codec.TypeEncoding;
+import org.apache.qpid.proton.codec.WritableBuffer;
+
+public class FastPathMessageAnnotationsType implements AMQPType<MessageAnnotations>, FastPathDescribedTypeConstructor<MessageAnnotations> {
+
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000072L), Symbol.valueOf("amqp:message-annotations:map"),
+ };
+
+ private final MessageAnnotationsType annotationsType;
+
+ public FastPathMessageAnnotationsType(EncoderImpl encoder) {
+ this.annotationsType = new MessageAnnotationsType(encoder);
+ }
+
+ public EncoderImpl getEncoder() {
+ return annotationsType.getEncoder();
+ }
+
+ public DecoderImpl getDecoder() {
+ return annotationsType.getDecoder();
+ }
+
+ @Override
+ public boolean encodesJavaPrimitive() {
+ return false;
+ }
+
+ @Override
+ public Class<MessageAnnotations> getTypeClass() {
+ return MessageAnnotations.class;
+ }
+
+ @Override
+ public TypeEncoding<MessageAnnotations> getEncoding(MessageAnnotations val) {
+ return annotationsType.getEncoding(val);
+ }
+
+ @Override
+ public TypeEncoding<MessageAnnotations> getCanonicalEncoding() {
+ return annotationsType.getCanonicalEncoding();
+ }
+
+ @Override
+ public Collection<? extends TypeEncoding<MessageAnnotations>> getAllEncodings() {
+ return annotationsType.getAllEncodings();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public MessageAnnotations readValue() {
+ return new MessageAnnotations(getDecoder().readMap());
+ }
+
+ @Override
+ public void skipValue() {
+ getDecoder().readConstructor().skipValue();
+ }
+
+ @Override
+ public void write(MessageAnnotations val) {
+ WritableBuffer buffer = getEncoder().getBuffer();
+
+ buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
+ getEncoder().writeUnsignedLong(annotationsType.getDescriptor());
+
+ MapType mapType = (MapType) getEncoder().getType(val.getValue());
+
+ mapType.setKeyEncoding(getEncoder().getTypeFromClass(Symbol.class));
+ mapType.write(val.getValue());
+ mapType.setKeyEncoding(null);
+ }
+
+ public static void register(Decoder decoder, EncoderImpl encoder) {
+ FastPathMessageAnnotationsType type = new FastPathMessageAnnotationsType(encoder);
+ for(Object descriptor : DESCRIPTORS)
+ {
+ decoder.register(descriptor, type);
+ }
+ encoder.register(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathPropertiesType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathPropertiesType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathPropertiesType.java
new file mode 100644
index 0000000..d689747
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/FastPathPropertiesType.java
@@ -0,0 +1,308 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.codec.messaging;
+
+import java.util.Collection;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.proton.amqp.messaging.Properties;
+import org.apache.qpid.proton.codec.AMQPType;
+import org.apache.qpid.proton.codec.FastPathDescribedTypeConstructor;
+import org.apache.qpid.proton.codec.DecodeException;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
+import org.apache.qpid.proton.codec.EncodingCodes;
+import org.apache.qpid.proton.codec.TypeEncoding;
+import org.apache.qpid.proton.codec.WritableBuffer;
+
+public class FastPathPropertiesType implements AMQPType<Properties>, FastPathDescribedTypeConstructor<Properties> {
+
+ private static final Object[] DESCRIPTORS =
+ {
+ UnsignedLong.valueOf(0x0000000000000073L), Symbol.valueOf("amqp:properties:list"),
+ };
+
+ private final PropertiesType propertiesType;
+
+ public FastPathPropertiesType(EncoderImpl encoder) {
+ this.propertiesType = new PropertiesType(encoder);
+ }
+
+ public EncoderImpl getEncoder() {
+ return propertiesType.getEncoder();
+ }
+
+ public DecoderImpl getDecoder() {
+ return propertiesType.getDecoder();
+ }
+
+ @Override
+ public Properties readValue() {
+ DecoderImpl decoder = getDecoder();
+ byte typeCode = decoder.getByteBuffer().get();
+
+ @SuppressWarnings("unused")
+ int size = 0;
+ int count = 0;
+
+ switch (typeCode) {
+ case EncodingCodes.LIST0:
+ break;
+ case EncodingCodes.LIST8:
+ size = ((int)decoder.getByteBuffer().get()) & 0xff;
+ count = ((int)decoder.getByteBuffer().get()) & 0xff;
+ break;
+ case EncodingCodes.LIST32:
+ size = decoder.getByteBuffer().getInt();
+ count = decoder.getByteBuffer().getInt();
+ break;
+ default:
+ throw new DecodeException("Incorrect type found in Transfer encoding: " + typeCode);
+ }
+
+ Properties properties = new Properties();
+
+ for (int index = 0; index < count; ++index) {
+ switch (index) {
+ case 0:
+ properties.setMessageId(decoder.readObject());
+ break;
+ case 1:
+ properties.setUserId(decoder.readBinary());
+ break;
+ case 2:
+ properties.setTo(decoder.readString());
+ break;
+ case 3:
+ properties.setSubject(decoder.readString());
+ break;
+ case 4:
+ properties.setReplyTo(decoder.readString());
+ break;
+ case 5:
+ properties.setCorrelationId(decoder.readObject());
+ break;
+ case 6:
+ properties.setContentType(decoder.readSymbol());
+ break;
+ case 7:
+ properties.setContentEncoding(decoder.readSymbol());
+ break;
+ case 8:
+ properties.setAbsoluteExpiryTime(decoder.readTimestamp());
+ break;
+ case 9:
+ properties.setCreationTime(decoder.readTimestamp());
+ break;
+ case 10:
+ properties.setGroupId(decoder.readString());
+ break;
+ case 11:
+ properties.setGroupSequence(decoder.readUnsignedInteger());
+ break;
+ case 12:
+ properties.setReplyToGroupId(decoder.readString());
+ break;
+ default:
+ throw new IllegalStateException("To many entries in Properties encoding");
+ }
+ }
+
+ return properties;
+ }
+
+ @Override
+ public void skipValue() {
+ getDecoder().readConstructor().skipValue();
+ }
+
+ @Override
+ public boolean encodesJavaPrimitive() {
+ return false;
+ }
+
+ @Override
+ public Class<Properties> getTypeClass() {
+ return Properties.class;
+ }
+
+ @Override
+ public TypeEncoding<Properties> getEncoding(Properties properties) {
+ return propertiesType.getEncoding(properties);
+ }
+
+ @Override
+ public TypeEncoding<Properties> getCanonicalEncoding() {
+ return propertiesType.getCanonicalEncoding();
+ }
+
+ @Override
+ public Collection<? extends TypeEncoding<Properties>> getAllEncodings() {
+ return propertiesType.getAllEncodings();
+ }
+
+ @Override
+ public void write(Properties value) {
+ WritableBuffer buffer = getEncoder().getBuffer();
+ int count = getElementCount(value);
+ byte encodingCode = deduceEncodingCode(value, count);
+
+ buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
+ getEncoder().writeUnsignedLong(propertiesType.getDescriptor());
+
+ // Optimized step, no other data to be written.
+ if (count == 0 || encodingCode == EncodingCodes.LIST0) {
+ buffer.put(EncodingCodes.LIST0);
+ return;
+ }
+
+ final int fieldWidth;
+
+ if (encodingCode == EncodingCodes.LIST8) {
+ fieldWidth = 1;
+ buffer.put(EncodingCodes.LIST8);
+ } else {
+ fieldWidth = 4;
+ buffer.put(EncodingCodes.LIST32);
+ }
+
+ int startIndex = buffer.position();
+
+ // Reserve space for the size and write the count of list elements.
+ if (fieldWidth == 1) {
+ buffer.put((byte) 0);
+ buffer.put((byte) count);
+ } else {
+ buffer.putInt(0);
+ buffer.putInt(count);
+ }
+
+ // Write the list elements and then compute total size written.
+ for (int i = 0; i < count; ++i) {
+ writeElement(value, i);
+ }
+
+ // Move back and write the size
+ int endIndex = buffer.position();
+ int writeSize = endIndex - startIndex - fieldWidth;
+
+ buffer.position(startIndex);
+ if (fieldWidth == 1) {
+ buffer.put((byte) writeSize);
+ } else {
+ buffer.putInt(writeSize);
+ }
+ buffer.position(endIndex);
+ }
+
+ private byte deduceEncodingCode(Properties value, int elementCount) {
+ if (elementCount == 0) {
+ return EncodingCodes.LIST0;
+ } else {
+ return EncodingCodes.LIST32;
+ }
+ }
+
+ private void writeElement(Properties properties, int index) {
+ switch (index) {
+ case 0:
+ getEncoder().writeObject(properties.getMessageId());
+ break;
+ case 1:
+ getEncoder().writeBinary(properties.getUserId());
+ break;
+ case 2:
+ getEncoder().writeString(properties.getTo());
+ break;
+ case 3:
+ getEncoder().writeString(properties.getSubject());
+ break;
+ case 4:
+ getEncoder().writeString(properties.getReplyTo());
+ break;
+ case 5:
+ getEncoder().writeObject(properties.getCorrelationId());
+ break;
+ case 6:
+ getEncoder().writeSymbol(properties.getContentType());
+ break;
+ case 7:
+ getEncoder().writeSymbol(properties.getContentEncoding());
+ break;
+ case 8:
+ getEncoder().writeTimestamp(properties.getAbsoluteExpiryTime());
+ break;
+ case 9:
+ getEncoder().writeTimestamp(properties.getCreationTime());
+ break;
+ case 10:
+ getEncoder().writeString(properties.getGroupId());
+ break;
+ case 11:
+ getEncoder().writeUnsignedInteger(properties.getGroupSequence());
+ break;
+ case 12:
+ getEncoder().writeString(properties.getReplyToGroupId());
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown Properties value index: " + index);
+ }
+ }
+
+ private int getElementCount(Properties properties) {
+ if (properties.getReplyToGroupId() != null) {
+ return 13;
+ } else if (properties.getGroupSequence() != null) {
+ return 12;
+ } else if (properties.getGroupId() != null) {
+ return 11;
+ } else if (properties.getCreationTime() != null) {
+ return 10;
+ } else if (properties.getAbsoluteExpiryTime() != null) {
+ return 9;
+ } else if (properties.getContentEncoding() != null) {
+ return 8;
+ } else if (properties.getContentType() != null) {
+ return 7;
+ } else if (properties.getCorrelationId() != null) {
+ return 6;
+ } else if (properties.getReplyTo() != null) {
+ return 5;
+ } else if (properties.getSubject() != null) {
+ return 4;
+ } else if (properties.getTo() != null) {
+ return 3;
+ } else if (properties.getUserId() != null) {
+ return 2;
+ } else if (properties.getMessageId() != null) {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ public static void register(Decoder decoder, EncoderImpl encoder) {
+ FastPathPropertiesType type = new FastPathPropertiesType(encoder);
+ for(Object descriptor : DESCRIPTORS)
+ {
+ decoder.register(descriptor, (FastPathDescribedTypeConstructor<?>) type);
+ }
+ encoder.register(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/HeaderType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/HeaderType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/HeaderType.java
index b7f5a43..310bce1 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/HeaderType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/HeaderType.java
@@ -35,7 +35,6 @@ import org.apache.qpid.proton.codec.Decoder;
import org.apache.qpid.proton.codec.DescribedTypeConstructor;
import org.apache.qpid.proton.codec.EncoderImpl;
-
public class HeaderType extends AbstractDescribedType<Header,List> implements DescribedTypeConstructor<Header>
{
private static final Object[] DESCRIPTORS =
@@ -154,5 +153,4 @@ public class HeaderType extends AbstractDescribedType<Header,List> implements De
}
encoder.register(type);
}
-
}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java
index 818aaa8..98c4431 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/messaging/PropertiesType.java
@@ -36,7 +36,6 @@ import org.apache.qpid.proton.codec.Decoder;
import org.apache.qpid.proton.codec.DescribedTypeConstructor;
import org.apache.qpid.proton.codec.EncoderImpl;
-
public class PropertiesType extends AbstractDescribedType<Properties,List> implements DescribedTypeConstructor<Properties>
{
private static final Object[] DESCRIPTORS =
@@ -46,7 +45,7 @@ public class PropertiesType extends AbstractDescribedType<Properties,List> impl
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000073L);
- private PropertiesType(EncoderImpl encoder)
+ PropertiesType(EncoderImpl encoder)
{
super(encoder);
}
@@ -190,8 +189,6 @@ public class PropertiesType extends AbstractDescribedType<Properties,List> impl
return Properties.class;
}
-
-
public static void register(Decoder decoder, EncoderImpl encoder)
{
PropertiesType type = new PropertiesType(encoder);
@@ -201,5 +198,4 @@ public class PropertiesType extends AbstractDescribedType<Properties,List> impl
}
encoder.register(type);
}
-
}
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2a2d3ff2/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DispositionType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DispositionType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DispositionType.java
index b833613..44a6202 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DispositionType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/DispositionType.java
@@ -47,7 +47,7 @@ public final class DispositionType extends AbstractDescribedType<Disposition,Lis
private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000015L);
- private DispositionType(EncoderImpl encoder)
+ DispositionType(EncoderImpl encoder)
{
super(encoder);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org