summaryrefslogtreecommitdiff
path: root/qpid/java/amqp-1-0-common/src
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2012-04-04 21:10:07 +0000
committerRobert Godfrey <rgodfrey@apache.org>2012-04-04 21:10:07 +0000
commite70c313cebf1c11ef77b32c0766a69a2d66cd134 (patch)
treeab7be312ee56b53ed17bcac0f0565c485a5a6fd4 /qpid/java/amqp-1-0-common/src
parent2db8073cfd87aff6ac64de3128f1ebb2952ca0db (diff)
downloadqpid-python-e70c313cebf1c11ef77b32c0766a69a2d66cd134.tar.gz
QPID-3933 : [Java] Add interim AMQP 1-0 implementation
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1309594 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/amqp-1-0-common/src')
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractDescribedTypeWriter.java188
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractListWriter.java41
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractMapWriter.java95
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ArrayTypeConstructor.java113
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ArrayWriter.java82
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryString.java68
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryTypeConstructor.java80
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryWriter.java75
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BooleanConstructor.java80
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BooleanWriter.java70
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteArrayWriter.java66
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteBufferWriter.java75
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteTypeConstructor.java59
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteWriter.java90
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CharTypeConstructor.java67
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CharWriter.java53
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundTypeAssembler.java36
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundTypeConstructor.java192
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundWriter.java420
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DecimalConstructor.java230
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DefaultDescribedTypeConstructor.java70
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DelegatingValueWriter.java52
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedType.java85
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedTypeConstructor.java41
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedTypeConstructorRegistry.java35
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DoubleTypeConstructor.java58
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DoubleWriter.java54
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/Encoder.java85
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedEightWriter.java108
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedFourWriter.java122
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedOneWriter.java79
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedSixteenWriter.java150
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedTwoWriter.java96
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FloatTypeConstructor.java58
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FloatWriter.java54
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FrameWriter.java245
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/IntTypeConstructor.java58
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/IntegerWriter.java106
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ListWriter.java172
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/LongTypeConstructor.java58
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/LongWriter.java111
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/MapWriter.java102
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/NullTypeConstructor.java44
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/NullWriter.java70
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ProtocolHandler.java30
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ProtocolHeaderHandler.java146
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/RestrictedTypeValueWriter.java55
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ShortTypeConstructor.java58
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ShortWriter.java55
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SimpleVariableWidthWriter.java68
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallIntConstructor.java58
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallLongConstructor.java58
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallUIntConstructor.java58
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallULongConstructor.java59
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/StringTypeConstructor.java132
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/StringWriter.java146
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolArrayWriter.java170
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolTypeConstructor.java109
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolWriter.java102
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TimestampTypeConstructor.java60
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TimestampWriter.java57
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TypeConstructor.java32
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UByteTypeConstructor.java59
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UIntTypeConstructor.java59
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ULongTypeConstructor.java61
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UShortTypeConstructor.java60
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UUIDTypeConstructor.java62
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UUIDWriter.java63
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedByteWriter.java92
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedIntegerWriter.java148
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedLongWriter.java152
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedShortWriter.java56
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueHandler.java159
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueProducingProtocolHandler.java31
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueWriter.java58
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthTypeConstructor.java48
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthWriter.java169
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/WrapperTypeValueWriter.java55
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroListConstructor.java46
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroUIntConstructor.java45
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroULongConstructor.java45
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQFrame.java68
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQPProtocolHeaderHandler.java85
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/ConnectionHandler.java559
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameHandler.java329
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameParsingError.java34
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameTypeHandler.java31
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/OversizeFrameException.java42
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLFrame.java42
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLFrameHandler.java311
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLProtocolHeaderHandler.java86
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/TransportFrame.java51
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/MessageAttributes.java27
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionDecoder.java35
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionDecoderImpl.java62
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionEncoder.java34
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionEncoderImpl.java111
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/AMQPFrameTransport.java179
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/AMQPTransport.java170
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/BytesProcessor.java27
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/BytesTransport.java38
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/CallbackHandlerSource.java28
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/CircularBytesBuffer.java174
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEndpoint.java934
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEventListener.java43
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionState.java31
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Container.java76
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Delivery.java95
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/DeliveryStateHandler.java28
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ErrorHandler.java9
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/FrameOutputHandler.java36
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/FrameTransport.java37
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java542
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEventListener.java31
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Node.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ProtocolHeaderTransport.java134
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkEndpoint.java438
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkListener.java43
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingSessionHalfEndpoint.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpoint.java39
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpointImpl.java291
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLFrameTransport.java78
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLTransport.java85
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkEndpoint.java214
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkListener.java43
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingSessionHalfEndpoint.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SequenceNumber.java110
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionAttachment.java92
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEndpoint.java781
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEventListener.java47
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionHalfEndpoint.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionState.java34
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/StateChangeListener.java25
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/UnsettledTransfer.java53
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/AmqpErrorException.java54
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Binary.java161
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/DeliveryState.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/DistributionMode.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/ErrorCondition.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/FrameBody.java29
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/GlobalTxId.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/LifetimePolicy.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Outcome.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/RestrictedType.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/SaslFrameBody.java27
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Section.java27
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Source.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Symbol.java90
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Target.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/TxnCapability.java26
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/TxnId.java23
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedByte.java134
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedInteger.java149
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedLong.java162
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedShort.java132
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/WrapperType.java27
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/codec/AMQPDescribedTypeRegistry.java389
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Accepted.java46
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/AmqpSequence.java70
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/AmqpValue.java66
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/ApplicationProperties.java64
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Data.java68
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnClose.java46
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoLinks.java46
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoLinksOrMessages.java46
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoMessages.java46
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeliveryAnnotations.java64
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/ExactSubjectFilter.java82
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Filter.java28
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Footer.java70
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Header.java161
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/JMSSelectorFilter.java77
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/MatchingSubjectFilter.java81
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/MessageAnnotations.java64
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Modified.java112
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/NoLocalFilter.java45
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Properties.java333
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Received.java88
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Rejected.java70
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Released.java46
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Source.java280
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/StdDistMode.java95
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Target.java196
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/TerminusDurability.java107
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/TerminusExpiryPolicy.java119
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AcceptedConstructor.java72
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AcceptedWriter.java151
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpSequenceConstructor.java68
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpSequenceWriter.java80
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java65
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueWriter.java80
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ApplicationPropertiesConstructor.java68
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ApplicationPropertiesWriter.java80
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DataConstructor.java65
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DataWriter.java80
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnCloseConstructor.java72
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnCloseWriter.java142
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksConstructor.java72
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksOrMessagesConstructor.java72
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksOrMessagesWriter.java142
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksWriter.java142
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoMessagesConstructor.java72
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoMessagesWriter.java142
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeliveryAnnotationsConstructor.java68
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeliveryAnnotationsWriter.java80
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ExactSubjectFilterConstructor.java64
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ExactSubjectFilterWriter.java79
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/FooterConstructor.java68
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/FooterWriter.java80
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/HeaderConstructor.java207
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/HeaderWriter.java182
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/JMSSelectorFilterConstructor.java64
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/JMSSelectorFilterWriter.java80
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MatchingSubjectFilterConstructor.java64
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MatchingSubjectFilterWriter.java79
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MessageAnnotationsConstructor.java68
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MessageAnnotationsWriter.java80
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ModifiedConstructor.java154
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ModifiedWriter.java166
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/NoLocalFilterConstructor.java56
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/NoLocalFilterWriter.java89
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/PropertiesConstructor.java424
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/PropertiesWriter.java246
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReceivedConstructor.java126
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReceivedWriter.java158
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/RejectedConstructor.java99
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/RejectedWriter.java150
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReleasedConstructor.java72
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReleasedWriter.java142
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/SourceConstructor.java384
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/SourceWriter.java230
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/TargetConstructor.java269
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/TargetWriter.java198
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslChallenge.java74
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslCode.java131
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslInit.java116
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslMechanisms.java74
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslOutcome.java95
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslResponse.java74
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslChallengeConstructor.java99
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslChallengeWriter.java150
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslInitConstructor.java153
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslInitWriter.java166
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslMechanismsConstructor.java106
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslMechanismsWriter.java150
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslOutcomeConstructor.java126
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslOutcomeWriter.java158
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslResponseConstructor.java99
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslResponseWriter.java150
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Coordinator.java70
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Declare.java66
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Declared.java67
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Discharge.java87
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TransactionErrors.java107
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TransactionalState.java88
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TxnCapabilities.java144
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TxnCapability.java131
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/CoordinatorConstructor.java117
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/CoordinatorWriter.java150
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclareConstructor.java99
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclareWriter.java150
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclaredConstructor.java99
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclaredWriter.java150
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DischargeConstructor.java126
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DischargeWriter.java158
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/TransactionalStateConstructor.java126
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/TransactionalStateWriter.java158
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/AmqpError.java227
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Attach.java365
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Begin.java239
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Close.java89
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/ConnectionError.java107
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Detach.java131
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Disposition.java194
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/End.java89
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Error.java111
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Flow.java302
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/LinkError.java131
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Open.java281
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/ReceiverSettleMode.java95
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Role.java95
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/SenderSettleMode.java107
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/SessionError.java119
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Transfer.java299
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/AttachConstructor.java465
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/AttachWriter.java254
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/BeginConstructor.java303
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/BeginWriter.java206
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/CloseConstructor.java99
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/CloseWriter.java150
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DetachConstructor.java153
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DetachWriter.java166
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DispositionConstructor.java234
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DispositionWriter.java190
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/EndConstructor.java99
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/EndWriter.java150
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/ErrorConstructor.java169
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/ErrorWriter.java166
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/FlowConstructor.java370
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/FlowWriter.java230
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/OpenConstructor.java371
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/OpenWriter.java222
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/TransferConstructor.java369
-rw-r--r--qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/TransferWriter.java230
304 files changed, 35972 insertions, 0 deletions
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractDescribedTypeWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractDescribedTypeWriter.java
new file mode 100644
index 0000000000..6977a40902
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractDescribedTypeWriter.java
@@ -0,0 +1,188 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public abstract class AbstractDescribedTypeWriter<V> implements ValueWriter<V>
+{
+ private int _length;
+ private Registry _registry;
+ private static final int LARGE_COMPOUND_THRESHOLD_COUNT = 10;
+ private ValueWriter _delegate;
+ private static final byte DESCRIBED_TYPE = (byte)0;
+
+ public AbstractDescribedTypeWriter(final Registry registry)
+ {
+ _registry = registry;
+ }
+
+ enum State {
+ FORMAT_CODE,
+ DESCRIPTOR,
+ DESCRIBED,
+ DONE
+ }
+
+ private State _state = State.FORMAT_CODE;
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+ final int length = _length;
+
+ if(length == -1)
+ {
+ writeFirstPass(buffer);
+ }
+ else
+ {
+
+ State state = _state;
+
+ switch(state)
+ {
+ case FORMAT_CODE:
+ if(buffer.hasRemaining())
+ {
+ buffer.put(DESCRIBED_TYPE);
+ state = State.DESCRIPTOR;
+ _delegate = createDescriptorWriter();
+ }
+ else
+ {
+ break;
+ }
+
+ case DESCRIPTOR:
+ if(buffer.hasRemaining())
+ {
+ _delegate.writeToBuffer(buffer);
+ if(_delegate.isComplete())
+ {
+ state = State.DESCRIBED;
+ _delegate = createDescribedWriter();
+ }
+ else
+ {
+ break;
+ }
+ }
+ case DESCRIBED:
+ if(buffer.hasRemaining())
+ {
+ _delegate.writeToBuffer(buffer);
+ if(_delegate.isComplete())
+ {
+ state = State.DONE;
+ _delegate = null;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ }
+
+ _state = state;
+
+ }
+
+ return _length;
+ }
+
+ private void writeFirstPass(ByteBuffer buffer)
+ {
+
+ int length = 1;
+ State state = State.FORMAT_CODE;
+
+ ValueWriter descriptorWriter = createDescriptorWriter();
+ if(buffer.hasRemaining())
+ {
+ buffer.put(DESCRIBED_TYPE);
+ state = State.DESCRIPTOR;
+ _delegate = descriptorWriter;
+ }
+ length += descriptorWriter.writeToBuffer(buffer);
+
+ ValueWriter describedWriter = createDescribedWriter();
+
+ if(descriptorWriter.isComplete())
+ {
+ state = State.DESCRIBED;
+ _delegate = describedWriter;
+ }
+
+ length += describedWriter.writeToBuffer(buffer);
+
+ if(describedWriter.isComplete())
+ {
+ _delegate = null;
+ state = State.DONE;
+ }
+
+ _state = state;
+ _length = length;
+ }
+
+ public void setValue(V value)
+ {
+ _length = -1;
+ _delegate = null;
+ _state = State.FORMAT_CODE;
+ onSetValue(value);
+ }
+
+ public void setRegistry(Registry registry)
+ {
+ _registry = registry;
+ }
+
+ protected Registry getRegistry()
+ {
+ return _registry;
+ }
+
+ protected abstract void onSetValue(final V value);
+
+ protected abstract void clear();
+
+ protected abstract ValueWriter createDescribedWriter();
+
+ protected abstract Object getDescriptor();
+
+ protected final ValueWriter createDescriptorWriter()
+ {
+ return getRegistry().getValueWriter(getDescriptor());
+ }
+
+ public boolean isComplete()
+ {
+ return _state == State.DONE;
+ }
+
+ public boolean isCacheable()
+ {
+ return false;
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractListWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractListWriter.java
new file mode 100644
index 0000000000..655b1f2164
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractListWriter.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+public abstract class AbstractListWriter<V> extends CompoundWriter<V>
+{
+ public AbstractListWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected byte getFourOctetEncodingCode()
+ {
+ return (byte)0xd0;
+ }
+
+ @Override
+ protected byte getSingleOctetEncodingCode()
+ {
+ return (byte)0xc0;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractMapWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractMapWriter.java
new file mode 100644
index 0000000000..0fa29b5210
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/AbstractMapWriter.java
@@ -0,0 +1,95 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+public abstract class AbstractMapWriter<V> extends CompoundWriter<V>
+{
+ private boolean onKey;
+
+ public AbstractMapWriter(Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected byte getFourOctetEncodingCode()
+ {
+ return (byte)0xd1;
+ }
+
+ @Override
+ protected byte getSingleOctetEncodingCode()
+ {
+ return (byte)0xc1;
+ }
+
+ @Override
+ protected final int getCount()
+ {
+ return 2 * getMapCount();
+ }
+
+ protected abstract int getMapCount();
+
+ @Override
+ protected final boolean hasNext()
+ {
+ return onKey || hasMapNext();
+ }
+
+ protected abstract boolean hasMapNext();
+
+ @Override
+ protected final Object next()
+ {
+ if(onKey = !onKey)
+ {
+ return nextKey();
+ }
+ else
+ {
+ return nextValue();
+ }
+ }
+
+ protected abstract Object nextValue();
+
+ protected abstract Object nextKey();
+
+ @Override
+ protected final void clear()
+ {
+ onKey = false;
+ onClear();
+ }
+
+ protected abstract void onClear();
+
+ @Override
+ protected final void reset()
+ {
+ onKey = false;
+ onReset();
+ }
+
+ protected abstract void onReset();
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ArrayTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ArrayTypeConstructor.java
new file mode 100644
index 0000000000..68239ad143
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ArrayTypeConstructor.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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.transport.AmqpError;
+
+import java.lang.reflect.Array;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class ArrayTypeConstructor implements TypeConstructor<Object[]>
+{
+
+
+
+ public Object[] construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+ int size = read(in);
+ if(in.remaining() < size)
+ {
+ throw new AmqpErrorException(AmqpError.DECODE_ERROR,
+ "Insufficient data to decode array - requires %d octects, only %d remaining.",
+ size, in.remaining());
+ }
+ ByteBuffer dup = in.slice();
+ dup.limit(size);
+ in.position(in.position()+size);
+ int count = read(dup);
+ TypeConstructor t = handler.readConstructor(dup);
+ List rval = new ArrayList(count);
+ for(int i = 0; i < count; i++)
+ {
+ rval.add(t.construct(dup, handler));
+ }
+ if(dup.hasRemaining())
+ {
+ throw new AmqpErrorException(AmqpError.DECODE_ERROR,
+ "Array incorrectly encoded, %d bytes remaining after decoding %d elements",
+ dup.remaining(), count);
+ }
+ if(rval.size() == 0)
+ {
+ return null;
+ }
+ else
+ {
+
+
+ return rval.toArray((Object[])Array.newInstance(rval.get(0).getClass(), rval.size()));
+ }
+ }
+
+
+ abstract int read(ByteBuffer in) throws AmqpErrorException;
+
+
+ private static final ArrayTypeConstructor ONE_BYTE_SIZE_ARRAY = new ArrayTypeConstructor()
+ {
+
+ @Override int read(final ByteBuffer in) throws AmqpErrorException
+ {
+ if(!in.hasRemaining())
+ {
+ throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode array");
+ }
+ return ((int)in.get()) & 0xff;
+ }
+
+ };
+
+ private static final ArrayTypeConstructor FOUR_BYTE_SIZE_ARRAY = new ArrayTypeConstructor()
+ {
+
+ @Override int read(final ByteBuffer in) throws AmqpErrorException
+ {
+ if(in.remaining()<4)
+ {
+ throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode array");
+ }
+ return in.getInt();
+ }
+
+ };
+
+ public static ArrayTypeConstructor getOneByteSizeTypeConstructor()
+ {
+ return ONE_BYTE_SIZE_ARRAY;
+ }
+
+ public static ArrayTypeConstructor getFourByteSizeTypeConstructor()
+ {
+ return FOUR_BYTE_SIZE_ARRAY;
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ArrayWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ArrayWriter.java
new file mode 100644
index 0000000000..7766a486f0
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ArrayWriter.java
@@ -0,0 +1,82 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public class ArrayWriter implements ValueWriter<Object[]>
+{
+ private Object[] _list;
+ private int _position = 0;
+ private final Registry _registry;
+ private ValueWriter valueWriter;
+
+ public ArrayWriter(final Registry registry)
+ {
+ _registry = registry;
+ }
+
+
+ protected void onSetValue(final Object[] value)
+ {
+
+ Class clazz = value.getClass().getComponentType();
+ //valueWriter = _registry.getValueWriterByClass(clazz);
+
+
+ }
+
+
+
+
+ private static Factory<Object[]> FACTORY = new Factory<Object[]>()
+ {
+
+ public ValueWriter<Object[]> newInstance(Registry registry)
+ {
+ return new ArrayWriter(registry);
+ }
+ };
+
+ public static void register(Registry registry)
+ {
+ //registry.register(List.class, FACTORY);
+ }
+
+ public int writeToBuffer(final ByteBuffer buffer)
+ {
+ return 0; //TODO change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setValue(final Object[] frameBody)
+ {
+ //TODO change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isComplete()
+ {
+ return false; //TODO change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isCacheable()
+ {
+ return false; //TODO change body of implemented methods use File | Settings | File Templates.
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryString.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryString.java
new file mode 100644
index 0000000000..76bdac8ed7
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryString.java
@@ -0,0 +1,68 @@
+package org.apache.qpid.amqp_1_0.codec;
+
+
+final class BinaryString
+{
+
+ private byte[] _data;
+ private int _offset;
+ private int _size;
+ private int _hashCode;
+
+ BinaryString(final byte[] data, final int offset, final int size)
+ {
+
+ setData(data, offset, size);
+ }
+
+ BinaryString()
+ {
+ }
+
+ void setData(byte[] data, int offset, int size)
+ {
+ _data = data;
+ _offset = offset;
+ _size = size;
+ int hc = 0;
+ for (int i = 0; i < size; i++)
+ {
+ hc = 31*hc + (0xFF & data[offset + i]);
+ }
+ _hashCode = hc;
+ }
+
+
+ public final int hashCode()
+ {
+ return _hashCode;
+ }
+
+ public final boolean equals(Object o)
+ {
+ BinaryString buf = (BinaryString) o;
+ final int size = _size;
+ if (size != buf._size)
+ {
+ return false;
+ }
+
+ final byte[] myData = _data;
+ final byte[] theirData = buf._data;
+ int myOffset = _offset;
+ int theirOffset = buf._offset;
+ final int myLimit = myOffset + size;
+
+ while(myOffset < myLimit)
+ {
+ if (myData[myOffset++] != theirData[theirOffset++])
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryTypeConstructor.java
new file mode 100644
index 0000000000..e83718d88d
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryTypeConstructor.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.Binary;
+
+import java.nio.ByteBuffer;
+
+public class BinaryTypeConstructor extends VariableWidthTypeConstructor
+{
+ private static final BinaryTypeConstructor INSTANCE_1 = new BinaryTypeConstructor(1);
+ private static final BinaryTypeConstructor INSTANCE_4 = new BinaryTypeConstructor(4);
+
+ public static BinaryTypeConstructor getInstance(int i)
+ {
+ return i == 1 ? INSTANCE_1 : INSTANCE_4;
+ }
+
+
+ private BinaryTypeConstructor(int size)
+ {
+ super(size);
+ }
+
+ @Override
+ public Object construct(final ByteBuffer in, boolean isCopy, ValueHandler handler) throws AmqpErrorException
+ {
+ int size;
+
+ if(getSize() == 1)
+ {
+ size = in.get() & 0xFF;
+ }
+ else
+ {
+ size = in.getInt();
+ }
+
+ ByteBuffer inDup = in.slice();
+ inDup.limit(inDup.position()+size);
+
+ Binary binary;
+/* if(isCopy && inDup.hasArray())
+ {
+ binary= new Binary(inDup.array(), inDup.arrayOffset()+inDup.position(),size);
+ }
+ else
+ {*/
+ byte[] buf = new byte[size];
+ inDup.get(buf);
+ binary = new Binary(buf);
+ /* }*/
+
+ in.position(in.position()+size);
+
+
+ return binary;
+
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryWriter.java
new file mode 100644
index 0000000000..8ab4569646
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BinaryWriter.java
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.Binary;
+
+public class BinaryWriter extends SimpleVariableWidthWriter<Binary>
+{
+ private int _offset;
+ private int _length;
+
+ @Override
+ protected byte getFourOctetEncodingCode()
+ {
+ return (byte)0xb0;
+ }
+
+ @Override
+ protected byte getSingleOctetEncodingCode()
+ {
+ return (byte)0xa0;
+ }
+
+ @Override
+ protected byte[] getByteArray(Binary value)
+ {
+ _offset = value.getArrayOffset();
+ _length = value.getLength();
+ return value.getArray();
+ }
+
+ @Override
+ protected int getOffset()
+ {
+ return _offset;
+ }
+
+ @Override protected int getLength()
+ {
+ return _length;
+ }
+
+ private static Factory<Binary> FACTORY = new Factory<Binary>()
+ {
+
+ public ValueWriter<Binary> newInstance(Registry registry)
+ {
+ return new BinaryWriter();
+ }
+ };
+
+ public static void register(Registry registry)
+ {
+ registry.register(Binary.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BooleanConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BooleanConstructor.java
new file mode 100644
index 0000000000..5cad87cbd8
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BooleanConstructor.java
@@ -0,0 +1,80 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.nio.ByteBuffer;
+
+public class BooleanConstructor
+{
+ private static final TypeConstructor<Boolean> TRUE_INSTANCE = new TypeConstructor<Boolean>()
+ {
+ public Boolean construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+ return Boolean.TRUE;
+ }
+ };
+
+ private static final TypeConstructor<Boolean> FALSE_INSTANCE = new TypeConstructor<Boolean>()
+ {
+ public Boolean construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+ return Boolean.FALSE;
+ }
+ };
+ private static final TypeConstructor<Boolean> BYTE_INSTANCE = new TypeConstructor<Boolean>()
+ {
+ public Boolean construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.hasRemaining())
+ {
+ byte b = in.get();
+ return b != (byte) 0;
+ }
+ else
+ {
+ org.apache.qpid.amqp_1_0.type.transport.Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct boolean: insufficient input data");
+ throw new AmqpErrorException(error);
+ }
+ }
+
+ };
+
+
+ public static TypeConstructor<Boolean> getTrueInstance()
+ {
+ return TRUE_INSTANCE;
+ }
+
+ public static TypeConstructor<Boolean> getFalseInstance()
+ {
+ return FALSE_INSTANCE;
+ }
+
+ public static TypeConstructor<Boolean> getByteInstance()
+ {
+ return BYTE_INSTANCE;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BooleanWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BooleanWriter.java
new file mode 100644
index 0000000000..fb4449fb2c
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/BooleanWriter.java
@@ -0,0 +1,70 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public class BooleanWriter implements ValueWriter<Boolean>
+{
+ private boolean _complete = true;
+ private boolean _value;
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+ if(!_complete & buffer.hasRemaining())
+ {
+ buffer.put(_value ? (byte)0x41 : (byte)0x42);
+ _complete = true;
+ }
+ return 1;
+ }
+
+ public void setValue(Boolean value)
+ {
+ _complete = false;
+ _value = value.booleanValue();
+ }
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public boolean isComplete()
+ {
+ return _complete;
+ }
+
+ private static Factory<Boolean> FACTORY = new Factory<Boolean>()
+ {
+
+ public ValueWriter<Boolean> newInstance(Registry registry)
+ {
+ return new BooleanWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Boolean.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteArrayWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteArrayWriter.java
new file mode 100644
index 0000000000..662b4085db
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteArrayWriter.java
@@ -0,0 +1,66 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+public class ByteArrayWriter extends SimpleVariableWidthWriter<byte[]>
+{
+
+ @Override
+ protected byte getFourOctetEncodingCode()
+ {
+ return (byte)0xb0;
+ }
+
+ @Override
+ protected byte getSingleOctetEncodingCode()
+ {
+ return (byte)0xa0;
+ }
+
+ @Override
+ protected byte[] getByteArray(byte[] value)
+ {
+ return value;
+ }
+
+
+ @Override
+ protected int getOffset()
+ {
+ return 0;
+ }
+
+ private static Factory<byte[]> FACTORY = new Factory<byte[]>()
+ {
+
+ public ValueWriter<byte[]> newInstance(Registry registry)
+ {
+ return new ByteArrayWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(byte[].class, FACTORY);
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteBufferWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteBufferWriter.java
new file mode 100644
index 0000000000..41bd20c0a2
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteBufferWriter.java
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public class ByteBufferWriter extends SimpleVariableWidthWriter<ByteBuffer>
+{
+
+ @Override
+ protected byte getFourOctetEncodingCode()
+ {
+ return (byte)0xb0;
+ }
+
+ @Override
+ protected byte getSingleOctetEncodingCode()
+ {
+ return (byte)0xa0;
+ }
+
+ @Override
+ protected byte[] getByteArray(ByteBuffer value)
+ {
+ if(value.hasArray() && value.arrayOffset() == 0 && value.remaining() == value.array().length)
+ {
+ return value.array();
+ }
+ else
+ {
+ byte[] copy = new byte[value.remaining()];
+ value.duplicate().get(copy);
+ return copy;
+ }
+ }
+
+ @Override
+ protected int getOffset()
+ {
+ return 0;
+ }
+
+ private static Factory<ByteBuffer> FACTORY = new Factory<ByteBuffer>()
+ {
+
+ public ValueWriter<ByteBuffer> newInstance(Registry registry)
+ {
+ return new ByteBufferWriter();
+ }
+ };
+
+ public static void register(Registry registry)
+ {
+ registry.register(ByteBuffer.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteTypeConstructor.java
new file mode 100644
index 0000000000..03db2c568c
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteTypeConstructor.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.nio.ByteBuffer;
+
+public class ByteTypeConstructor implements TypeConstructor
+{
+ private static final ByteTypeConstructor INSTANCE = new ByteTypeConstructor();
+
+ public static ByteTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private ByteTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.hasRemaining())
+ {
+ return in.get();
+ }
+ else
+ {
+ Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct byte: insufficient input data");
+ throw new AmqpErrorException(error);
+
+ }
+
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteWriter.java
new file mode 100644
index 0000000000..6155de4d2a
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ByteWriter.java
@@ -0,0 +1,90 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public class ByteWriter implements ValueWriter<Byte>
+{
+ private int _written = 2;
+ private byte _value;
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+
+ switch(_written)
+ {
+ case 0:
+ if(buffer.hasRemaining())
+ {
+ buffer.put((byte)0x51);
+ }
+ else
+ {
+ break;
+ }
+ case 1:
+ if(buffer.hasRemaining())
+ {
+ buffer.put(_value);
+ _written = 2;
+ }
+ else
+ {
+ _written = 1;
+ }
+
+ }
+
+ return 2;
+ }
+
+ public void setValue(Byte value)
+ {
+ _written = 0;
+ _value = value.byteValue();
+ }
+
+ public boolean isComplete()
+ {
+ return _written == 2;
+ }
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ private static Factory<Byte> FACTORY = new Factory<Byte>()
+ {
+
+ public ValueWriter<Byte> newInstance(Registry registry)
+ {
+ return new ByteWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Byte.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CharTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CharTypeConstructor.java
new file mode 100644
index 0000000000..6a2ce2d725
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CharTypeConstructor.java
@@ -0,0 +1,67 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+
+import java.nio.ByteBuffer;
+
+public class CharTypeConstructor implements TypeConstructor
+{
+ private static final CharTypeConstructor INSTANCE = new CharTypeConstructor();
+
+
+ public static CharTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private CharTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.remaining()>=4)
+ {
+ int codePoint = in.getInt();
+ char[] chars = Character.toChars(codePoint);
+ if(chars.length == 1)
+ {
+ return chars[0];
+ }
+ else
+ {
+ return chars;
+ }
+ }
+ else
+ {
+ org.apache.qpid.amqp_1_0.type.transport.Error error = new org.apache.qpid.amqp_1_0.type.transport.Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct char: insufficient input data");
+ throw new AmqpErrorException(error);
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CharWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CharWriter.java
new file mode 100644
index 0000000000..05f6e28d2f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CharWriter.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+public class CharWriter extends FixedFourWriter<Character>
+{
+ private static final byte FORMAT_CODE = (byte)0x73;
+
+ @Override
+ byte getFormatCode()
+ {
+ return FORMAT_CODE;
+ }
+
+ @Override
+ int convertValueToInt(Character value)
+ {
+ return (int) value.charValue();
+ }
+
+ private static Factory<Character> FACTORY = new Factory<Character>()
+ {
+
+ public ValueWriter<Character> newInstance(Registry registry)
+ {
+ return new CharWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Character.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundTypeAssembler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundTypeAssembler.java
new file mode 100644
index 0000000000..5625797f74
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundTypeAssembler.java
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+
+public interface CompoundTypeAssembler
+{
+
+ public static interface Factory
+ {
+ CompoundTypeAssembler newInstance();
+ }
+
+ void init(int count) throws AmqpErrorException;
+ void addItem(Object obj) throws AmqpErrorException;
+ Object complete() throws AmqpErrorException;
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundTypeConstructor.java
new file mode 100644
index 0000000000..fc4fcdf9ee
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundTypeConstructor.java
@@ -0,0 +1,192 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Formatter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CompoundTypeConstructor extends VariableWidthTypeConstructor
+{
+ private final CompoundTypeAssembler.Factory _assemblerFactory;
+
+ public static final CompoundTypeAssembler.Factory LIST_ASSEMBLER_FACTORY =
+ new CompoundTypeAssembler.Factory()
+ {
+
+ public CompoundTypeAssembler newInstance()
+ {
+ return new ListAssembler();
+ }
+ };
+
+
+
+ private static class ListAssembler implements CompoundTypeAssembler
+ {
+ private List _list;
+
+ public void init(final int count) throws AmqpErrorException
+ {
+ _list = new ArrayList(count);
+ }
+
+ public void addItem(final Object obj) throws AmqpErrorException
+ {
+ _list.add(obj);
+ }
+
+ public Object complete() throws AmqpErrorException
+ {
+ return _list;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ListAssembler{" +
+ "_list=" + _list +
+ '}';
+ }
+ }
+
+
+ public static final CompoundTypeAssembler.Factory MAP_ASSEMBLER_FACTORY =
+ new CompoundTypeAssembler.Factory()
+ {
+
+ public CompoundTypeAssembler newInstance()
+ {
+ return new MapAssembler();
+ }
+ };
+
+ private static class MapAssembler implements CompoundTypeAssembler
+ {
+ private Map _map;
+ private Object _lastKey;
+ private static final Object NOT_A_KEY = new Object();
+
+
+ public void init(final int count) throws AmqpErrorException
+ {
+ // Can't have an odd number of elements in a map
+ if((count & 0x1) == 1)
+ {
+ Error error = new Error();
+ error.setCondition(AmqpError.DECODE_ERROR);
+ Formatter formatter = new Formatter();
+ formatter.format("map cannot have odd number of elements: %d", count);
+ error.setDescription(formatter.toString());
+ throw new AmqpErrorException(error);
+ }
+ _map = new HashMap(count);
+ _lastKey = NOT_A_KEY;
+ }
+
+ public void addItem(final Object obj) throws AmqpErrorException
+ {
+ if(_lastKey != NOT_A_KEY)
+ {
+ if(_map.put(_lastKey, obj) != null)
+ {
+ Error error = new Error();
+ error.setCondition(AmqpError.DECODE_ERROR);
+ Formatter formatter = new Formatter();
+ formatter.format("map cannot have duplicate keys: %s has values (%s, %s)", _lastKey, _map.get(_lastKey), obj);
+ error.setDescription(formatter.toString());
+
+ throw new AmqpErrorException(error);
+ }
+ _lastKey = NOT_A_KEY;
+ }
+ else
+ {
+ _lastKey = obj;
+ }
+
+ }
+
+ public Object complete() throws AmqpErrorException
+ {
+ return _map;
+ }
+ }
+
+
+ public static CompoundTypeConstructor getInstance(int i,
+ CompoundTypeAssembler.Factory assemblerFactory)
+ {
+ return new CompoundTypeConstructor(i, assemblerFactory);
+ }
+
+
+ private CompoundTypeConstructor(int size,
+ final CompoundTypeAssembler.Factory assemblerFactory)
+ {
+ super(size);
+ _assemblerFactory = assemblerFactory;
+ }
+
+ @Override
+ public Object construct(final ByteBuffer in, boolean isCopy, ValueHandler delegate) throws AmqpErrorException
+ {
+ int size;
+ int count;
+
+ if(getSize() == 1)
+ {
+ size = in.get() & 0xFF;
+ count = in.get() & 0xFF;
+ }
+ else
+ {
+ size = in.getInt();
+ count = in.getInt();
+ }
+
+ ByteBuffer data;
+ ByteBuffer inDup = in.slice();
+
+ inDup.limit(size-getSize());
+
+ CompoundTypeAssembler assembler = _assemblerFactory.newInstance();
+
+ assembler.init(count);
+
+ for(int i = 0; i < count; i++)
+ {
+ assembler.addItem(delegate.parse(in));
+ }
+
+ return assembler.complete();
+
+ }
+
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundWriter.java
new file mode 100644
index 0000000000..39dce2b448
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/CompoundWriter.java
@@ -0,0 +1,420 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class CompoundWriter<V> implements ValueWriter<V>
+{
+ private int _length;
+ private Registry _registry;
+ private static final int LARGE_COMPOUND_THRESHOLD_COUNT = 25;
+ private ValueWriter _delegate;
+ private Map<Class, ValueWriter> _writerCache = new HashMap<Class, ValueWriter>();
+
+ public CompoundWriter(final Registry registry)
+ {
+ _registry = registry;
+ }
+
+ enum State {
+ FORMAT_CODE,
+ SIZE_0,
+ SIZE_1,
+ SIZE_2,
+ SIZE_3,
+ COUNT_0,
+ COUNT_1,
+ COUNT_2,
+ COUNT_3,
+ DELEGATING,
+ DONE
+ }
+
+ private State _state = State.FORMAT_CODE;
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+ return writeToBuffer(buffer, false);
+ }
+
+ public int writeToBuffer(ByteBuffer buffer, boolean large)
+ {
+ final int length = _length;
+
+ if(length == -1)
+ {
+ writeFirstPass(buffer, (large || getCount() > LARGE_COMPOUND_THRESHOLD_COUNT) ? 4 : 1);
+ if(_delegate != null && _delegate.isComplete())
+ {
+ _delegate = null;
+ }
+ }
+ else
+ {
+ //
+
+ final int size = (length & 0xFFFFFF00) == 0 ? 1 : 4;
+ final int count = getCount();
+ final int typeLength = length - (1+size);
+
+ State state = _state;
+
+ switch(state)
+ {
+ case FORMAT_CODE:
+ if(buffer.hasRemaining())
+ {
+ buffer.put(size == 1 ? getSingleOctetEncodingCode(): getFourOctetEncodingCode());
+ state = State.SIZE_0;
+ }
+ else
+ {
+ break;
+ }
+
+ case SIZE_0:
+ if(size == 4)
+ {
+ if(buffer.remaining()>=4)
+ {
+ buffer.putInt(typeLength);
+ state = State.COUNT_0;
+ }
+ }
+ else if(size == 1)
+ {
+ if(buffer.hasRemaining())
+ {
+ buffer.put((byte)(typeLength));
+ state = State.COUNT_0;
+ }
+ else
+ {
+ break;
+ }
+
+ }
+ case SIZE_1:
+ case SIZE_2:
+ if(state != State.COUNT_0 && buffer.remaining() >= 2)
+ {
+ buffer.putShort((short)(((typeLength) >> ((3-state.ordinal())<<3)) & 0xFFFF ));
+ state = (state == State.SIZE_0)
+ ? State.SIZE_2
+ : (state == State.SIZE_1)
+ ? State.SIZE_3
+ : State.COUNT_0;
+ }
+ case SIZE_3:
+ if(state != State.COUNT_0 && buffer.hasRemaining())
+ {
+ buffer.put((byte)(((typeLength) >> ((4-state.ordinal())<<3)) & 0xFF ));
+ state = (state == State.SIZE_0)
+ ? State.SIZE_1
+ : (state == State.SIZE_1)
+ ? State.SIZE_2
+ : (state == State.SIZE_2)
+ ? State.SIZE_3
+ : State.COUNT_0;
+ }
+ case COUNT_0:
+ if(size == 4)
+ {
+ if(buffer.remaining()>=4)
+ {
+ buffer.putInt(count);
+ state = State.DELEGATING;
+ }
+ }
+ else if(size == 1)
+ {
+ if(buffer.hasRemaining())
+ {
+ buffer.put((byte)count);
+ state = State.DELEGATING;
+ }
+ else
+ {
+ break;
+ }
+
+ }
+
+ case COUNT_1:
+ case COUNT_2:
+ if(state != State.DELEGATING && buffer.remaining() >= 2)
+ {
+ buffer.putShort((short)((count >> ((7-state.ordinal())<<3)) & 0xFFFF ));
+ state = state == State.COUNT_0
+ ? State.COUNT_2
+ : state == State.COUNT_1
+ ? State.COUNT_3
+ : State.DELEGATING;
+ }
+ case COUNT_3:
+ if(state != State.DELEGATING && buffer.hasRemaining())
+ {
+ buffer.put((byte)((count >> ((8-state.ordinal())<<3)) & 0xFF ));
+ state = state == State.COUNT_0
+ ? State.COUNT_1
+ : state == State.COUNT_1
+ ? State.COUNT_2
+ : state == State.COUNT_2
+ ? State.COUNT_3
+ : State.DELEGATING;
+ }
+ case DELEGATING:
+ while(state == State.DELEGATING && buffer.hasRemaining())
+ {
+ if(_delegate == null || _delegate.isComplete())
+ {
+ if(hasNext())
+ {
+ Object val = next();
+ _delegate = _registry.getValueWriter(val);
+ }
+ else
+ {
+ state = State.DONE;
+ break;
+ }
+ }
+ _delegate.writeToBuffer(buffer);
+ }
+ }
+
+ _state = state;
+
+ }
+
+ return _length;
+ }
+
+ private void writeFirstPass(ByteBuffer buffer, int size)
+ {
+
+ State state = State.FORMAT_CODE;
+ /*ByteBuffer origBuffer = buffer;
+ buffer = buffer.duplicate();*/
+ int origPosition = buffer.position();
+ int length ;
+
+
+ if(size == 4)
+ {
+ if(buffer.hasRemaining())
+ {
+ buffer.put(getFourOctetEncodingCode());
+
+ // Skip the size - we will come back and patch this
+ if(buffer.remaining() >= 4 )
+ {
+ buffer.position(buffer.position()+4);
+ state = State.COUNT_0;
+ }
+ else
+ {
+ state = State.values()[buffer.remaining()+1];
+ buffer.position(buffer.limit());
+ }
+
+
+ switch(buffer.remaining())
+ {
+ case 0:
+ break;
+ case 1:
+ buffer.put((byte)((getCount() >> 24) & 0xFF));
+ state = State.COUNT_1;
+ break;
+ case 2:
+ buffer.putShort((short)((getCount() >> 16) & 0xFFFF));
+ state = State.COUNT_2;
+ break;
+ case 3:
+ buffer.putShort((short)((getCount() >> 16) & 0xFFFF));
+ buffer.put((byte)((getCount() >> 8) & 0xFF));
+ state = State.COUNT_3;
+ break;
+ default:
+ buffer.putInt(getCount());
+ state = State.DELEGATING;
+ }
+
+
+
+ }
+ length = 9;
+
+
+
+ }
+ else
+ {
+ if(buffer.hasRemaining())
+ {
+ buffer.put(getSingleOctetEncodingCode());
+ if(buffer.hasRemaining())
+ {
+ // Size - we will come back and patch this
+ buffer.put((byte) 0);
+
+ if(buffer.hasRemaining())
+ {
+ buffer.put((byte)getCount());
+ state = State.DELEGATING;
+ }
+ else
+ {
+ state = State.COUNT_0;
+ }
+ }
+ else
+ {
+ state = State.SIZE_0;
+ }
+ }
+ length = 3;
+
+ }
+
+
+ int iterPos = -1;
+ for(int i = 0; i < getCount(); i++)
+ {
+ Object val = next();
+ ValueWriter writer = _registry.getValueWriter(val, _writerCache);
+ if(writer == null)
+ {
+ // TODO
+ System.out.println("no writer for " + val);
+ }
+ length += writer.writeToBuffer(buffer);
+ if(iterPos == -1 && !writer.isComplete())
+ {
+ iterPos = i;
+ _delegate = writer;
+ }
+
+ if(size == 1 && length > 255)
+ {
+ reset();
+ buffer.position(origPosition);
+ writeFirstPass(buffer, 4);
+ return;
+ }
+
+ }
+
+ // TODO - back-patch size
+ if(buffer.limit() - origPosition >= 2)
+ {
+ buffer.position(origPosition+1);
+ if(size == 1)
+ {
+ buffer.put((byte)((length & 0xFF)-2));
+ }
+ else
+ {
+ switch(buffer.remaining())
+ {
+ case 1:
+ buffer.put((byte)(((length-5) >> 24) & 0xFF));
+ break;
+ case 2:
+ buffer.putShort((short)(((length-5) >> 16) & 0xFFFF));
+ break;
+ case 3:
+ buffer.putShort((short)(((length-5) >> 16) & 0xFFFF));
+ buffer.put((byte)(((length-5) >> 8) & 0xFF));
+ break;
+ default:
+ buffer.putInt(length-5);
+ }
+ }
+ }
+
+ if(buffer.limit() - origPosition >= length)
+ {
+ buffer.position(origPosition+length);
+ state = State.DONE;
+ }
+ else
+ {
+ reset();
+ while(iterPos-- >= 0)
+ {
+ next();
+ }
+ buffer.position(buffer.limit());
+ }
+ _state = state;
+ _length = length;
+ }
+
+ protected abstract byte getFourOctetEncodingCode();
+
+ protected abstract byte getSingleOctetEncodingCode();
+
+ public void setValue(V value)
+ {
+ _length = -1;
+ _delegate = null;
+ _state = State.FORMAT_CODE;
+ onSetValue(value);
+ }
+
+ public void setRegistry(Registry registry)
+ {
+ _registry = registry;
+ }
+
+ public Registry getRegistry()
+ {
+ return _registry;
+ }
+
+ protected abstract void onSetValue(final V value);
+
+ protected abstract int getCount();
+
+ protected abstract boolean hasNext();
+
+ protected abstract Object next();
+
+ protected abstract void clear();
+
+ protected abstract void reset();
+
+ public boolean isCacheable()
+ {
+ return false;
+ }
+
+ public boolean isComplete()
+ {
+ return _state == State.DONE;
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DecimalConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DecimalConstructor.java
new file mode 100644
index 0000000000..6c3b64aa25
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DecimalConstructor.java
@@ -0,0 +1,230 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+
+public abstract class DecimalConstructor implements TypeConstructor<BigDecimal>
+{
+
+ private static final DecimalConstructor DECIMAL_32 = new DecimalConstructor()
+ {
+
+ public BigDecimal construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+
+
+ int val;
+
+ if(in.remaining()>=4)
+ {
+ val = in.getInt();
+ }
+ else
+ {
+ throw new AmqpErrorException(ConnectionError.FRAMING_ERROR, "Cannot construct decimal32: insufficient input data");
+ }
+
+ return constructFrom32(val);}
+
+ };
+
+
+ private static final DecimalConstructor DECIMAL_64 = new DecimalConstructor()
+ {
+
+ public BigDecimal construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+ long val;
+
+ if(in.remaining()>=8)
+ {
+ val = in.getLong();
+ }
+ else
+ {
+ throw new AmqpErrorException(ConnectionError.FRAMING_ERROR, "Cannot construct decimal64: insufficient input data");
+ }
+
+ return constructFrom64(val);
+
+ }
+
+ };
+
+
+ private static final DecimalConstructor DECIMAL_128 = new DecimalConstructor()
+ {
+
+ public BigDecimal construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+ long high;
+ long low;
+
+ if(in.remaining()>=16)
+ {
+ high = in.getLong();
+ low = in.getLong();
+ }
+ else
+ {
+ throw new AmqpErrorException(ConnectionError.FRAMING_ERROR, "Cannot construct decimal128: insufficient input data");
+ }
+
+ return constructFrom128(high, low);
+
+ }
+
+ };
+
+ private static final BigDecimal TWO_TO_THE_SIXTY_FOUR = new BigDecimal(2).pow(64);
+
+ private static BigDecimal constructFrom128(long high, long low)
+ {
+ int sign = ((high & 0x8000000000000000l) == 0) ? 1 : -1;
+
+ int exponent = 0;
+ long significand = high;
+
+ if((high & 0x6000000000000000l) != 0x6000000000000000l)
+ {
+ exponent = ((int) ((high & 0x7FFE000000000000l) >> 49)) - 6176;
+ significand = high & 0x0001ffffffffffffl;
+ }
+ else if((high & 0x7800000000000000l) != 0x7800000000000000l)
+ {
+ exponent = ((int)((high & 0x1fff800000000000l)>>47)) - 6176;
+ significand = (0x00007fffffffffffl & high) | 0x0004000000000000l;
+ }
+ else
+ {
+ // NaN or infinite
+ return null;
+ }
+
+
+ BigDecimal bigDecimal = new BigDecimal(significand).multiply(TWO_TO_THE_SIXTY_FOUR);
+ if(low >=0)
+ {
+ bigDecimal = bigDecimal.add(new BigDecimal(low));
+ }
+ else
+ {
+ bigDecimal = bigDecimal.add(TWO_TO_THE_SIXTY_FOUR.add(new BigDecimal(low)));
+ }
+ if(((high & 0x8000000000000000l) != 0))
+ {
+ bigDecimal = bigDecimal.negate();
+ }
+ bigDecimal = bigDecimal.scaleByPowerOfTen(exponent);
+ return bigDecimal;
+ }
+
+
+ private static BigDecimal constructFrom64(final long val)
+ {
+ int sign = ((val & 0x8000000000000000l) == 0) ? 1 : -1;
+
+ int exponent = 0;
+ long significand = val;
+
+ if((val & 0x6000000000000000l) != 0x6000000000000000l)
+ {
+ exponent = ((int) ((val & 0x7FE0000000000000l) >> 53)) - 398;
+ significand = val & 0x001fffffffffffffl;
+ }
+ else if((val & 0x7800000000000000l) != 0x7800000000000000l)
+ {
+ exponent = ((int)((val & 0x1ff8000000000000l)>>51)) - 398;
+ significand = (0x0007ffffffffffffl & val) | 0x0020000000000000l;
+ }
+ else
+ {
+ // NaN or infinite
+ return null;
+ }
+
+ BigDecimal bigDecimal = new BigDecimal(sign * significand);
+ bigDecimal = bigDecimal.scaleByPowerOfTen(exponent);
+ return bigDecimal;
+ }
+
+ private static BigDecimal constructFrom32(final int val)
+ {
+ int sign = ((val & 0x80000000) == 0) ? 1 : -1;
+
+ int exponent = 0;
+ int significand = val;
+
+ if((val & 0x60000000) != 0x60000000)
+ {
+ exponent = ((int) ((val & 0x7F800000) >> 23)) - 101;
+ significand = val & 0x007fffffff;
+ }
+ else if((val & 0x78000000) != 0x78000000)
+ {
+ exponent = ((int)((val & 0x1fe00000)>>21)) - 101;
+ significand = (0x001fffff & val) | 0x00800000;
+ }
+ else
+ {
+ // NaN or infinite
+ return null;
+ }
+
+ BigDecimal bigDecimal = new BigDecimal(sign * significand);
+ bigDecimal = bigDecimal.scaleByPowerOfTen(exponent);
+ return bigDecimal;
+ }
+
+/*
+
+ public static void main(String[] args)
+ {
+ System.out.println(constructFrom128(0l,0l));
+ System.out.println(constructFrom128(0x3041ED09BEAD87C0l,0x378D8E63FFFFFFFFl));
+ System.out.println(constructFrom64(0l));
+ System.out.println(constructFrom64(0x5fe0000000000001l));
+ System.out.println(constructFrom64(0xec7386F26FC0FFFFl));
+ System.out.println(constructFrom32(0));
+ System.out.println(constructFrom32(0x6cb8967f));
+
+ }
+*/
+
+ public static TypeConstructor getDecimal32Instance()
+ {
+ return DECIMAL_32;
+ }
+
+ public static TypeConstructor getDecimal64Instance()
+ {
+ return DECIMAL_64;
+ }
+
+ public static TypeConstructor getDecimal128Instance()
+ {
+ return DECIMAL_128;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DefaultDescribedTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DefaultDescribedTypeConstructor.java
new file mode 100644
index 0000000000..48b2045298
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DefaultDescribedTypeConstructor.java
@@ -0,0 +1,70 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class DefaultDescribedTypeConstructor extends DescribedTypeConstructor
+{
+ private Object _descriptor;
+
+ public DefaultDescribedTypeConstructor(final Object descriptor)
+ {
+ _descriptor = descriptor;
+ }
+
+ public Object construct(final Object underlying)
+ {
+ return new DescribedType(_descriptor, underlying);
+ }
+
+
+ public static void main(String[] args) throws IOException, ParseException
+ {
+ LineNumberReader reader = new LineNumberReader(new InputStreamReader(System.in));
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
+ String line;
+ Pattern pattern = Pattern.compile("^\\d+ (\\d{4}-\\d{2}-\\d{2} \\d\\d:\\d\\d:\\d\\d,\\d\\d\\d)");
+
+ long prevTime = Long.MAX_VALUE;
+
+ while((line = reader.readLine()) != null)
+ {
+ Matcher m = pattern.matcher(line);
+ if(m.matches())
+ {
+ String timeStr = m.group(1);
+ long time = df.parse(timeStr).getTime();
+ if(time - prevTime > 20000)
+ {
+ System.out.println(df.format(prevTime) + " - " + df.format(time));
+ }
+ prevTime = time;
+ }
+ }
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DelegatingValueWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DelegatingValueWriter.java
new file mode 100644
index 0000000000..b11530d94f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DelegatingValueWriter.java
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public abstract class DelegatingValueWriter<V> implements ValueWriter<V>
+{
+ private ValueWriter _delegate;
+ private Registry _registry;
+
+
+ protected DelegatingValueWriter(final Registry registry)
+ {
+ _registry = registry;
+ }
+
+ public int writeToBuffer(final ByteBuffer buffer)
+ {
+ return _delegate.writeToBuffer(buffer);
+ }
+
+ public void setValue(final V frameBody)
+ {
+ _delegate = _registry.getValueWriter(getUnderlyingValue(frameBody));
+ }
+
+ protected abstract Object getUnderlyingValue(final V frameBody);
+
+ public boolean isComplete()
+ {
+ return _delegate.isComplete();
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedType.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedType.java
new file mode 100644
index 0000000000..2f171c49b2
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedType.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+public class DescribedType
+{
+ private final Object _descriptor;
+ private final Object _described;
+
+ public DescribedType(final Object descriptor, final Object described)
+ {
+ _descriptor = descriptor;
+ _described = described;
+ }
+
+ public Object getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ public Object getDescribed()
+ {
+ return _described;
+ }
+
+ @Override
+ public boolean equals(final Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ final DescribedType that = (DescribedType) o;
+
+ if (_described != null ? !_described.equals(that._described) : that._described != null)
+ {
+ return false;
+ }
+ if (_descriptor != null ? !_descriptor.equals(that._descriptor) : that._descriptor != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = _descriptor != null ? _descriptor.hashCode() : 0;
+ result = 31 * result + (_described != null ? _described.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "DescribedType{"+ _descriptor +
+ ", " + _described +
+ '}';
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedTypeConstructor.java
new file mode 100644
index 0000000000..4093583441
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedTypeConstructor.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+
+import java.nio.ByteBuffer;
+
+public abstract class DescribedTypeConstructor<T extends Object>
+{
+ public TypeConstructor<T> construct(final TypeConstructor describedConstructor) throws AmqpErrorException
+ {
+ return new TypeConstructor<T>()
+ {
+ public T construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+ return DescribedTypeConstructor.this.construct(describedConstructor.construct(in, handler));
+ }
+ };
+ }
+
+ public abstract T construct(Object underlying);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedTypeConstructorRegistry.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedTypeConstructorRegistry.java
new file mode 100644
index 0000000000..38cfa0f5a7
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DescribedTypeConstructorRegistry.java
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+public interface DescribedTypeConstructorRegistry
+{
+ public static interface Source
+ {
+ public DescribedTypeConstructorRegistry getDescribedTypeRegistry();
+ }
+
+ void register(Object descriptor, DescribedTypeConstructor constructor);
+
+ DescribedTypeConstructor getConstructor(Object descriptor);
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DoubleTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DoubleTypeConstructor.java
new file mode 100644
index 0000000000..439ad73875
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DoubleTypeConstructor.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.nio.ByteBuffer;
+
+public class DoubleTypeConstructor implements TypeConstructor
+{
+ private static final DoubleTypeConstructor INSTANCE = new DoubleTypeConstructor();
+
+
+ public static DoubleTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private DoubleTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.remaining()>=8)
+ {
+ return in.getDouble();
+ }
+ else
+ {
+ Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct double: insufficient input data");
+ throw new AmqpErrorException(error);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DoubleWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DoubleWriter.java
new file mode 100644
index 0000000000..372e739a51
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/DoubleWriter.java
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+public class DoubleWriter extends FixedEightWriter<Double>
+{
+ private static final byte FORMAT_CODE = (byte) 0x82;
+
+
+ @Override
+ byte getFormatCode()
+ {
+ return FORMAT_CODE;
+ }
+
+ @Override
+ long convertValueToLong(Double value)
+ {
+ return Double.doubleToLongBits(value.doubleValue());
+ }
+
+ private static Factory<Double> FACTORY = new Factory<Double>()
+ {
+
+ public ValueWriter<Double> newInstance(Registry registry)
+ {
+ return new DoubleWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Double.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/Encoder.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/Encoder.java
new file mode 100644
index 0000000000..9b2a654f10
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/Encoder.java
@@ -0,0 +1,85 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.Binary;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.UnsignedByte;
+import org.apache.qpid.amqp_1_0.type.UnsignedInteger;
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.UnsignedShort;
+
+import java.nio.ByteBuffer;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+public interface Encoder
+{
+
+ public boolean writeNull();
+
+ public boolean writeBoolean(boolean b);
+
+ public boolean writeByte(byte b);
+
+ public boolean writeUnsignedByte(ByteBuffer buf, UnsignedByte ub);
+
+ public boolean writeShort(ByteBuffer buf, short s);
+
+ public boolean writeUnsignedShort(UnsignedShort s);
+
+ public boolean writeInt(int i);
+
+ public boolean writeUnsignedInt(UnsignedInteger i);
+
+ public boolean writeLong(long l);
+
+ public boolean writeUnsignedLong(UnsignedLong l);
+
+ public boolean writeFloat(float f);
+
+ public boolean writeDouble(double d);
+
+ public boolean writeChar(char c);
+
+ public boolean writeTimestamp(Date d);
+
+ public boolean writeSymbol(Symbol s);
+
+ public boolean writeString(String s);
+
+ public boolean writeBytes(byte[] bytes);
+
+ public boolean writeBytes(Binary bin);
+
+ public boolean writeList(List l);
+
+ public boolean writeMap(Map m);
+
+ public boolean writeEncodable(EncodableValue o);
+
+ public boolean writeDescribedType(EncodableValue descriptor, EncodableValue described);
+
+ interface EncodableValue
+ {
+ void encode(Encoder encoder);
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedEightWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedEightWriter.java
new file mode 100644
index 0000000000..c9cc0b72c3
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedEightWriter.java
@@ -0,0 +1,108 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public abstract class FixedEightWriter<T extends Object> implements ValueWriter<T>
+{
+ private int _written = 9;
+ private long _value;
+
+ public final int writeToBuffer(ByteBuffer buffer)
+ {
+ int remaining = buffer.remaining();
+ int written = _written;
+ switch(written)
+ {
+ case 0:
+ if(buffer.hasRemaining())
+ {
+ buffer.put(getFormatCode());
+ remaining--;
+ written = 1;
+ }
+ else
+ {
+ break;
+ }
+ case 1:
+ if(remaining>=8)
+ {
+ buffer.putLong(_value);
+ written = 9;
+ break;
+ }
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ if(remaining >= 4)
+ {
+ buffer.putInt((int)((_value >> ((5-written)<<3)) & 0xFFFFFFFF ));
+ remaining-=4;
+ written+=4;
+ }
+ case 6:
+ case 7:
+ if(remaining >= 2 && written <= 7)
+ {
+ buffer.putShort((short)((_value >> ((7-written)<<3)) & 0xFFFF ));
+ remaining -= 2;
+ written += 2;
+ }
+ case 8:
+ if(remaining >=1 && written != 9)
+ {
+ buffer.put((byte)((_value >> ((8-written)<<3)) & 0xFF ));
+ written++;
+ }
+
+
+ }
+ _written = written;
+
+ return 9;
+ }
+
+ abstract byte getFormatCode();
+
+ public final void setValue(T value)
+ {
+ _written = 0;
+ _value = convertValueToLong(value);
+ }
+
+ abstract long convertValueToLong(T value);
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public final boolean isComplete()
+ {
+ return _written == 9;
+ }
+
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedFourWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedFourWriter.java
new file mode 100644
index 0000000000..164a869299
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedFourWriter.java
@@ -0,0 +1,122 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public abstract class FixedFourWriter<T extends Object> implements ValueWriter<T>
+{
+ private int _written = 5;
+ private int _value;
+
+ public final int writeToBuffer(ByteBuffer buffer)
+ {
+ int remaining = buffer.remaining();
+ int written = _written;
+ switch(written)
+ {
+ case 0:
+ if(remaining-- != 0)
+ {
+ buffer.put(getFormatCode());
+ written = 1;
+ }
+ else
+ {
+ break;
+ }
+ case 1:
+ if(remaining>=4)
+ {
+ buffer.putInt(_value);
+ written = 5;
+ break;
+ }
+ else if(remaining-- != 0)
+ {
+ buffer.put((byte)((_value >> 24)&0xFF));
+ written = 2;
+ }
+ else
+ {
+ break;
+ }
+ case 2:
+ if(remaining-- != 0)
+ {
+ buffer.put((byte)((_value >> 16)&0xFF));
+ written = 3;
+ }
+ else
+ {
+ break;
+ }
+ case 3:
+ if(remaining-- != 0)
+ {
+ buffer.put((byte)((_value >> 8)&0xFF));
+ written = 4;
+ }
+ else
+ {
+ break;
+ }
+ case 4:
+ if(remaining-- != 0)
+ {
+ buffer.put((byte)(_value&0xFF));
+ written = 5;
+ }
+
+ }
+ _written = written;
+
+ return 5;
+ }
+
+ abstract byte getFormatCode();
+
+ public final void setValue(T value)
+ {
+ if(_written==1)
+ {
+ // TODO - remove
+ System.out.println("Remove");
+ }
+ _written = 0;
+ _value = convertValueToInt(value);
+ }
+
+ abstract int convertValueToInt(T value);
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public final boolean isComplete()
+ {
+ return _written == 5;
+ }
+
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedOneWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedOneWriter.java
new file mode 100644
index 0000000000..805b0743a4
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedOneWriter.java
@@ -0,0 +1,79 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+
+public abstract class FixedOneWriter<T> implements ValueWriter<T>
+{
+ protected int _written = 2;
+ protected byte _value;
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+
+ switch(_written)
+ {
+ case 0:
+ if(buffer.hasRemaining())
+ {
+ buffer.put(getFormatCode());
+ }
+ else
+ {
+ break;
+ }
+ case 1:
+ if(buffer.hasRemaining())
+ {
+ buffer.put(_value);
+ _written = 2;
+ }
+ else
+ {
+ _written = 1;
+ }
+
+ }
+
+ return 2;
+ }
+
+ protected abstract byte getFormatCode();
+
+ public boolean isComplete()
+ {
+ return _written == 2;
+ }
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public void setValue(final T value)
+ {
+ _written = 0;
+ _value = convertToByte(value);
+ }
+
+ protected abstract byte convertToByte(final T value);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedSixteenWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedSixteenWriter.java
new file mode 100644
index 0000000000..20334595db
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedSixteenWriter.java
@@ -0,0 +1,150 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public abstract class FixedSixteenWriter<T extends Object> implements ValueWriter<T>
+{
+ private int _written = 17;
+ private long _msb;
+ private long _lsb;
+
+ public final int writeToBuffer(ByteBuffer buffer)
+ {
+ int remaining = buffer.remaining();
+ int written = _written;
+ switch(written)
+ {
+ case 0:
+ if(buffer.hasRemaining())
+ {
+ buffer.put(getFormatCode());
+ remaining--;
+ written = 1;
+ }
+ else
+ {
+ break;
+ }
+ case 1:
+ if(remaining>=8)
+ {
+ buffer.putLong(_msb);
+ written = 9;
+ break;
+ }
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ if(remaining >= 4)
+ {
+ buffer.putInt((int)((_msb >> ((5-written)<<3)) & 0xFFFFFFFF ));
+ remaining-=4;
+ written+=4;
+ }
+ case 6:
+ case 7:
+ if(remaining >= 2 && written <= 7)
+ {
+ buffer.putShort((short)((_msb >> ((7-written)<<3)) & 0xFFFF ));
+ remaining -= 2;
+ written += 2;
+ }
+ case 8:
+ if(remaining >=1 && written != 9)
+ {
+ buffer.put((byte)((_msb >> ((8-written)<<3)) & 0xFF ));
+ written++;
+ }
+
+
+ }
+ if(remaining != 0)
+ {
+ switch(written)
+ {
+ case 9:
+ if(remaining>=8)
+ {
+ buffer.putLong(_lsb);
+ written = 17;
+ break;
+ }
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ if(remaining >= 4)
+ {
+ buffer.putInt((int)((_lsb >> ((13-written)<<3)) & 0xFFFFFFFF ));
+ remaining-=4;
+ written+=4;
+ }
+ case 14:
+ case 15:
+ if(remaining >= 2 && written <= 15)
+ {
+ buffer.putShort((short)((_lsb >> ((15-written)<<3)) & 0xFFFF ));
+ remaining -= 2;
+ written += 2;
+ }
+ case 16:
+ if(remaining >=1 && written != 17)
+ {
+ buffer.put((byte)((_msb >> ((16-written)<<3)) & 0xFF ));
+ written++;
+ }
+ }
+
+ }
+
+ _written = written;
+
+ return 17;
+ }
+
+ abstract byte getFormatCode();
+
+ public final void setValue(T value)
+ {
+ _written = 0;
+ _msb = convertValueToMSB(value);
+ _lsb = convertValueToLSB(value);
+ }
+
+ abstract long convertValueToMSB(T value);
+ abstract long convertValueToLSB(T value);
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public final boolean isComplete()
+ {
+ return _written == 17;
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedTwoWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedTwoWriter.java
new file mode 100644
index 0000000000..f6da0490a6
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FixedTwoWriter.java
@@ -0,0 +1,96 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public abstract class FixedTwoWriter <T extends Object> implements ValueWriter<T>
+{
+ private int _written = 3;
+ private short _value;
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+
+ switch(_written)
+ {
+ case 0:
+ if(buffer.hasRemaining())
+ {
+ buffer.put(getFormatCode());
+ }
+ else
+ {
+ break;
+ }
+ case 1:
+
+ if(buffer.remaining()>1)
+ {
+ buffer.putShort(_value);
+ _written = 3;
+ }
+ else if(buffer.hasRemaining())
+ {
+ buffer.put((byte) (0xFF & (_value >> 8)));
+ _written = 2;
+ }
+ else
+ {
+ _written = 1;
+ }
+ break;
+ case 2:
+ if(buffer.hasRemaining())
+ {
+ buffer.put((byte)(0xFF & _value));
+ }
+
+
+ }
+
+ return 3;
+ }
+
+
+ public final void setValue(T value)
+ {
+ _written = 0;
+ _value = convertValueToShort(value);
+ }
+
+ abstract short convertValueToShort(T value);
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public boolean isComplete()
+ {
+ return _written == 3;
+ }
+
+ abstract byte getFormatCode();
+
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FloatTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FloatTypeConstructor.java
new file mode 100644
index 0000000000..200fead74e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FloatTypeConstructor.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.nio.ByteBuffer;
+
+public class FloatTypeConstructor implements TypeConstructor
+{
+ private static final FloatTypeConstructor INSTANCE = new FloatTypeConstructor();
+
+
+ public static FloatTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private FloatTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.remaining()>=4)
+ {
+ return in.getFloat();
+ }
+ else
+ {
+ org.apache.qpid.amqp_1_0.type.transport.Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct float: insufficient input data");
+ throw new AmqpErrorException(error);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FloatWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FloatWriter.java
new file mode 100644
index 0000000000..823e33c3f8
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FloatWriter.java
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+public class FloatWriter extends FixedFourWriter<Float>
+{
+ private static final byte FORMAT_CODE = (byte)0x72;
+
+
+ @Override
+ byte getFormatCode()
+ {
+ return FORMAT_CODE;
+ }
+
+ @Override
+ int convertValueToInt(Float value)
+ {
+ return Float.floatToIntBits(value.floatValue());
+ }
+
+ private static Factory<Float> FACTORY = new Factory<Float>()
+ {
+
+ public ValueWriter<Float> newInstance(Registry registry)
+ {
+ return new FloatWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Float.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FrameWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FrameWriter.java
new file mode 100644
index 0000000000..dbf9306366
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/FrameWriter.java
@@ -0,0 +1,245 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.framing.AMQFrame;
+
+import java.nio.ByteBuffer;
+
+public class FrameWriter implements ValueWriter<AMQFrame>
+{
+ private Registry _registry;
+ private AMQFrame _frame;
+ private State _state = State.DONE;
+ private ValueWriter _typeWriter;
+ private int _size = -1;
+ private static final byte[] EMPTY_BYTE_ARRAY = new byte[] {};
+ private ByteBuffer _payload;
+
+ enum State
+ {
+ SIZE_0,
+ SIZE_1,
+ SIZE_2,
+ SIZE_3,
+ DOFF,
+ TYPE,
+ CHANNEL_0,
+ CHANNEL_1,
+ DELEGATE,
+ PAYLOAD,
+ DONE
+ }
+
+ public FrameWriter(final Registry registry)
+ {
+ _registry = registry;
+ }
+
+ public boolean isComplete()
+ {
+ return _state == State.DONE;
+ }
+
+ public boolean isCacheable()
+ {
+ return false;
+ }
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+ int remaining;
+
+
+
+ while((remaining = buffer.remaining()) != 0 && _state != State.DONE)
+ {
+ switch(_state)
+ {
+ case SIZE_0:
+
+ _typeWriter.setValue(_frame.getFrameBody());
+
+ int payloadLength = _payload == null ? 0 : _payload.remaining();
+
+ _size = _typeWriter.writeToBuffer(remaining > 8
+ ? (ByteBuffer)buffer.duplicate().position(buffer.position()+8)
+ : ByteBuffer.wrap(EMPTY_BYTE_ARRAY)) + 8 + payloadLength;
+ if(remaining >= 4)
+ {
+ buffer.putInt(_size);
+
+ if(remaining >= 8)
+ {
+ buffer.put((byte)2); // DOFF
+ buffer.put(_frame.getFrameType()); // AMQP Frame Type
+ buffer.putShort(_frame.getChannel());
+
+ if(_size - payloadLength > remaining)
+ {
+ buffer.position(buffer.limit());
+ _state = State.DELEGATE;
+ }
+ else if(_size > remaining )
+ {
+ buffer.position(buffer.position()+_size-8-payloadLength);
+ if(payloadLength > 0)
+ {
+
+ ByteBuffer dup = _payload.slice();
+ int payloadUsed = buffer.remaining();
+ dup.limit(payloadUsed);
+ buffer.put(dup);
+ _payload.position(_payload.position()+payloadUsed);
+ }
+ _state = State.PAYLOAD;
+ }
+ else
+ {
+
+ buffer.position(buffer.position()+_size-8-payloadLength);
+ if(payloadLength > 0)
+ {
+ buffer.put(_payload);
+ }
+ _state = State.DONE;
+ }
+
+ }
+ else
+ {
+ _state = State.DOFF;
+ }
+ break;
+ }
+ else
+ {
+ buffer.put((byte)((_size >> 24) & 0xFF));
+ if(!buffer.hasRemaining())
+ {
+ _state = State.SIZE_1;
+ break;
+ }
+ }
+
+ case SIZE_1:
+ buffer.put((byte)((_size >> 16) & 0xFF));
+ if(!buffer.hasRemaining())
+ {
+ _state = State.SIZE_2;
+ break;
+ }
+ case SIZE_2:
+ buffer.put((byte)((_size >> 8) & 0xFF));
+ if(!buffer.hasRemaining())
+ {
+ _state = State.SIZE_3;
+ break;
+ }
+ case SIZE_3:
+ buffer.put((byte)(_size & 0xFF));
+ if(!buffer.hasRemaining())
+ {
+ _state = State.DOFF;
+ break;
+ }
+ case DOFF:
+ buffer.put((byte)2); // Always 2 (8 bytes)
+ if(!buffer.hasRemaining())
+ {
+ _state = State.TYPE;
+ break;
+ }
+ case TYPE:
+ buffer.put((byte)0);
+ if(!buffer.hasRemaining())
+ {
+ _state = State.CHANNEL_0;
+ break;
+ }
+ case CHANNEL_0:
+ buffer.put((byte)((_frame.getChannel() >> 8) & 0xFF));
+ if(!buffer.hasRemaining())
+ {
+ _state = State.CHANNEL_1;
+ break;
+ }
+ case CHANNEL_1:
+ buffer.put((byte)(_frame.getChannel() & 0xFF));
+ if(!buffer.hasRemaining())
+ {
+ _state = State.DELEGATE;
+ break;
+ }
+ case DELEGATE:
+ _typeWriter.writeToBuffer(buffer);
+ if(_typeWriter.isComplete())
+ {
+ _state = State.PAYLOAD;
+ _frame = null;
+ _typeWriter = null;
+ }
+ else
+ {
+ break;
+ }
+ case PAYLOAD:
+ if(_payload == null || _payload.remaining() == 0)
+ {
+ _state = State.DONE;
+ _frame = null;
+ _typeWriter = null;
+ _payload = null;
+
+ }
+ else if(buffer.hasRemaining())
+ {
+ buffer.put(_payload);
+ if(_payload.remaining() == 0)
+ {
+ _state = State.DONE;
+ _frame = null;
+ _typeWriter = null;
+ _payload = null;
+ }
+ }
+
+ }
+ }
+ if(_size == -1)
+ {
+ _size = _typeWriter.writeToBuffer(ByteBuffer.wrap(EMPTY_BYTE_ARRAY)) + 8 + (_payload == null ? 0 : _payload.remaining());
+ }
+ return _size;
+ }
+
+ public void setValue(AMQFrame frame)
+ {
+ _frame = frame;
+ _state = State.SIZE_0;
+ _size = -1;
+ _payload = null;
+ final Object frameBody = frame.getFrameBody();
+ _typeWriter = _registry.getValueWriter(frameBody);
+ _payload = frame.getPayload() == null ? null : frame.getPayload().duplicate();
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/IntTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/IntTypeConstructor.java
new file mode 100644
index 0000000000..b3e774de5c
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/IntTypeConstructor.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.nio.ByteBuffer;
+
+public class IntTypeConstructor implements TypeConstructor
+{
+ private static final IntTypeConstructor INSTANCE = new IntTypeConstructor();
+
+
+ public static IntTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private IntTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.remaining()>=4)
+ {
+ return in.getInt();
+ }
+ else
+ {
+ org.apache.qpid.amqp_1_0.type.transport.Error error = new org.apache.qpid.amqp_1_0.type.transport.Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct int: insufficient input data");
+ throw new AmqpErrorException(error);
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/IntegerWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/IntegerWriter.java
new file mode 100644
index 0000000000..91c3151494
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/IntegerWriter.java
@@ -0,0 +1,106 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public class IntegerWriter implements ValueWriter<Integer>
+{
+ private static final byte EIGHT_BYTE_FORMAT_CODE = (byte)0x71;
+ private static final byte ONE_BYTE_FORMAT_CODE = (byte) 0x54;
+
+ private ValueWriter<Integer> _delegate;
+
+ private final FixedFourWriter<Integer> _eightByteWriter = new FixedFourWriter<Integer>()
+ {
+
+ @Override
+ byte getFormatCode()
+ {
+ return EIGHT_BYTE_FORMAT_CODE;
+ }
+
+ @Override
+ int convertValueToInt(Integer value)
+ {
+ return value.intValue();
+ }
+ };
+
+ private final ValueWriter<Integer> _oneByteWriter = new FixedOneWriter<Integer>()
+ {
+
+ @Override protected byte getFormatCode()
+ {
+ return ONE_BYTE_FORMAT_CODE;
+ }
+
+ @Override protected byte convertToByte(final Integer value)
+ {
+ return value.byteValue();
+ }
+ };
+
+
+ public int writeToBuffer(final ByteBuffer buffer)
+ {
+ return _delegate.writeToBuffer(buffer);
+ }
+
+ public void setValue(final Integer i)
+ {
+ if(i >= -128 && i <= 127)
+ {
+ _delegate = _oneByteWriter;
+ }
+ else
+ {
+ _delegate = _eightByteWriter;
+ }
+ _delegate.setValue(i);
+ }
+
+ public boolean isComplete()
+ {
+ return _delegate.isComplete();
+ }
+
+ public boolean isCacheable()
+ {
+ return false;
+ }
+
+
+ private static Factory<Integer> FACTORY = new Factory<Integer>()
+ {
+
+ public ValueWriter<Integer> newInstance(Registry registry)
+ {
+ return new IntegerWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Integer.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ListWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ListWriter.java
new file mode 100644
index 0000000000..3e0164705f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ListWriter.java
@@ -0,0 +1,172 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+import java.util.List;
+
+public class ListWriter implements ValueWriter<List>
+{
+ private static class NonEmptyListWriter extends AbstractListWriter<List>
+ {
+ private List _list;
+ private int _position = 0;
+
+ public NonEmptyListWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final List value)
+ {
+ _list = value;
+ _position = 0;
+
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _list.size();
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _position < getCount();
+ }
+
+ @Override
+ protected Object next()
+ {
+ return _list.get(_position++);
+ }
+
+ @Override
+ protected void clear()
+ {
+ _list = null;
+ _position = 0;
+ }
+
+ @Override
+ protected void reset()
+ {
+ _position = 0;
+ }
+
+ }
+
+ private final NonEmptyListWriter _nonEmptyListWriter;
+ private static final byte ZERO_BYTE_FORMAT_CODE = (byte) 0x45;
+
+ private final ValueWriter<List> _emptyListWriter = new EmptyListValueWriter();
+
+
+ private ValueWriter<List> _delegate;
+
+ public ListWriter(final Registry registry)
+ {
+ _nonEmptyListWriter = new NonEmptyListWriter(registry);
+
+ }
+
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+ return _delegate.writeToBuffer(buffer);
+ }
+
+ public void setValue(List frameBody)
+ {
+ if(frameBody.isEmpty())
+ {
+ _delegate = _emptyListWriter;
+ }
+ else
+ {
+ _delegate = _nonEmptyListWriter;
+ }
+ _delegate.setValue(frameBody);
+ }
+
+ public boolean isComplete()
+ {
+ return _delegate.isComplete();
+ }
+
+ public boolean isCacheable()
+ {
+ return false;
+ }
+
+
+
+ private static Factory<List> FACTORY = new Factory<List>()
+ {
+
+ public ValueWriter<List> newInstance(Registry registry)
+ {
+ return new ListWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(List.class, FACTORY);
+ }
+
+ public static class EmptyListValueWriter implements ValueWriter<List>
+ {
+ private boolean _complete;
+
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+
+ if(!_complete && buffer.hasRemaining())
+ {
+ buffer.put(ZERO_BYTE_FORMAT_CODE);
+ _complete = true;
+ }
+
+ return 1;
+ }
+
+ public void setValue(List list)
+ {
+ _complete = false;
+ }
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public boolean isComplete()
+ {
+ return _complete;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/LongTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/LongTypeConstructor.java
new file mode 100644
index 0000000000..b9a4509a04
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/LongTypeConstructor.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.nio.ByteBuffer;
+
+public class LongTypeConstructor implements TypeConstructor
+{
+ private static final LongTypeConstructor INSTANCE = new LongTypeConstructor();
+
+
+ public static LongTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private LongTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.remaining()>=8)
+ {
+ return in.getLong();
+ }
+ else
+ {
+ org.apache.qpid.amqp_1_0.type.transport.Error error = new org.apache.qpid.amqp_1_0.type.transport.Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct long: insufficient input data");
+ throw new AmqpErrorException(error);
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/LongWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/LongWriter.java
new file mode 100644
index 0000000000..984775cc74
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/LongWriter.java
@@ -0,0 +1,111 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public class LongWriter implements ValueWriter<Long>
+{
+ private static final byte EIGHT_BYTE_FORMAT_CODE = (byte) 0x81;
+
+
+ private static final byte ONE_BYTE_FORMAT_CODE = (byte) 0x55;
+
+ private ValueWriter<Long> _delegate;
+
+ private final FixedEightWriter<Long> _eightByteWriter = new FixedEightWriter<Long>()
+ {
+
+ @Override
+ byte getFormatCode()
+ {
+ return EIGHT_BYTE_FORMAT_CODE;
+ }
+
+ @Override
+ long convertValueToLong(Long value)
+ {
+ return value;
+ }
+
+ };
+
+ private final ValueWriter<Long> _oneByteWriter = new FixedOneWriter<Long>()
+ {
+
+ @Override protected byte getFormatCode()
+ {
+ return ONE_BYTE_FORMAT_CODE;
+ }
+
+ @Override protected byte convertToByte(final Long value)
+ {
+ return value.byteValue();
+ }
+ };
+
+ public int writeToBuffer(final ByteBuffer buffer)
+ {
+ return _delegate.writeToBuffer(buffer);
+ }
+
+ public void setValue(final Long l)
+ {
+ if(l >= -128 && l <= 127)
+ {
+ _delegate = _oneByteWriter;
+ }
+ else
+ {
+ _delegate = _eightByteWriter;
+ }
+ _delegate.setValue(l);
+ }
+
+ public boolean isComplete()
+ {
+ return _delegate.isComplete();
+ }
+
+ public boolean isCacheable()
+ {
+ return false;
+ }
+
+
+
+
+ private static Factory<Long> FACTORY = new Factory<Long>()
+ {
+
+ public ValueWriter<Long> newInstance(Registry registry)
+ {
+ return new LongWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Long.class, FACTORY);
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/MapWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/MapWriter.java
new file mode 100644
index 0000000000..b239d4a397
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/MapWriter.java
@@ -0,0 +1,102 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.util.Iterator;
+import java.util.Map;
+
+public class MapWriter extends AbstractMapWriter<Map>
+{
+ private Map _map;
+ private Object _value;
+ private Iterator<Map.Entry> _iterator;
+
+ public MapWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Map value)
+ {
+ _map = value;
+ _iterator = value.entrySet().iterator();
+ }
+
+ @Override
+ protected int getMapCount()
+ {
+ return _map.size();
+ }
+
+ @Override
+ protected boolean hasMapNext()
+ {
+ return _iterator.hasNext();
+ }
+
+ @Override
+ protected Object nextKey()
+ {
+ Map.Entry entry = _iterator.next();
+ _value = entry.getValue();
+ return entry.getKey();
+ }
+ @Override
+ protected Object nextValue()
+ {
+ Object value = _value;
+ _value = null;
+ return value;
+ }
+
+
+ @Override
+ protected void onClear()
+ {
+ _map = null;
+ _iterator = null;
+ _value = null;
+ }
+
+ @Override
+ protected void onReset()
+ {
+ _iterator = _map.entrySet().iterator();
+ _value = null;
+ }
+
+
+ private static Factory<Map> FACTORY = new Factory<Map>()
+ {
+
+ public ValueWriter<Map> newInstance(Registry registry)
+ {
+ return new MapWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Map.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/NullTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/NullTypeConstructor.java
new file mode 100644
index 0000000000..6b46895708
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/NullTypeConstructor.java
@@ -0,0 +1,44 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+
+import java.nio.ByteBuffer;
+
+class NullTypeConstructor implements TypeConstructor<Void>
+{
+ private static final NullTypeConstructor INSTANCE = new NullTypeConstructor();
+
+ NullTypeConstructor()
+ {
+ }
+
+ public Void construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+ return null;
+ }
+
+ public static NullTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/NullWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/NullWriter.java
new file mode 100644
index 0000000000..690a2222ab
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/NullWriter.java
@@ -0,0 +1,70 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public class NullWriter implements ValueWriter<Void>
+{
+ private boolean _complete = true;
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+
+ if(!_complete && buffer.hasRemaining())
+ {
+ buffer.put((byte)0x40);
+ _complete = true;
+ }
+
+ return 1;
+ }
+
+ public void setValue(Void frameBody)
+ {
+ _complete = false;
+ }
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public boolean isComplete()
+ {
+ return _complete;
+ }
+
+ private static Factory<Void> FACTORY = new Factory<Void>()
+ {
+
+ public ValueWriter<Void> newInstance(Registry registry)
+ {
+ return new NullWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Void.TYPE, FACTORY);
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ProtocolHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ProtocolHandler.java
new file mode 100644
index 0000000000..a954c6db50
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ProtocolHandler.java
@@ -0,0 +1,30 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public interface ProtocolHandler
+{
+ ProtocolHandler parse(ByteBuffer in);
+
+ boolean isDone();
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ProtocolHeaderHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ProtocolHeaderHandler.java
new file mode 100644
index 0000000000..f72fea56b2
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ProtocolHeaderHandler.java
@@ -0,0 +1,146 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.framing.AMQPProtocolHeaderHandler;
+import org.apache.qpid.amqp_1_0.framing.SASLProtocolHeaderHandler;
+
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+import java.nio.ByteBuffer;
+
+public class ProtocolHeaderHandler implements ProtocolHandler
+{
+ private final ConnectionEndpoint _connection;
+ private ProtocolHandler[] _protocolHandlers = new ProtocolHandler[4];
+ private boolean _done;
+
+ enum State {
+ AWAITING_A,
+ AWAITING_M,
+ AWAITING_Q,
+ AWAITING_P,
+ AWAITING_PROTOCOL_ID,
+ ERROR
+ }
+
+ private State _state = State.AWAITING_A;
+
+ public ProtocolHeaderHandler(final ConnectionEndpoint connection)
+ {
+ _connection = connection;
+ _protocolHandlers[0] = new AMQPProtocolHeaderHandler(connection);
+ _protocolHandlers[1] = null ; // historic apache.qpid.amqp_1_0
+ _protocolHandlers[2] = null ; // TLS
+ _protocolHandlers[3] = new SASLProtocolHeaderHandler(connection); // SASL
+
+
+ }
+
+ public ProtocolHandler parse(final ByteBuffer in)
+ {
+ if(!in.hasRemaining())
+ {
+ return this;
+ }
+
+ switch(_state)
+ {
+ case AWAITING_A:
+ if(transition(in, (byte)'A', State.AWAITING_M))
+ {
+ break;
+ }
+ case AWAITING_M:
+ if(transition(in, (byte)'M', State.AWAITING_Q))
+ {
+ break;
+ }
+ case AWAITING_Q:
+ if(transition(in, (byte)'Q', State.AWAITING_P))
+ {
+ break;
+ }
+
+ case AWAITING_P:
+ if(transition(in, (byte)'P', State.AWAITING_PROTOCOL_ID))
+ {
+ break;
+ }
+ case AWAITING_PROTOCOL_ID:
+ int protocolId = ((int) in.get()) & 0xff;
+ ProtocolHandler delegate;
+
+ try
+ {
+ delegate = _protocolHandlers[protocolId];
+ }
+ catch(IndexOutOfBoundsException e)
+ {
+ delegate = null;
+ }
+
+ if(delegate == null)
+ {
+ _state = State.ERROR;
+ }
+ else
+ {
+ return delegate.parse(in);
+ }
+ }
+ if(_state == State.ERROR)
+ {
+ _connection.invalidHeaderReceived();
+ _done = true;
+ }
+ return this;
+
+ }
+
+ boolean transition(ByteBuffer in, byte expected, State next)
+ {
+ byte b = in.get();
+ if(b == expected)
+ {
+ if(!in.hasRemaining())
+ {
+ _state = next;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ _state = State.ERROR;
+ return true;
+ }
+ }
+
+
+ public boolean isDone()
+ {
+ return _done;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/RestrictedTypeValueWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/RestrictedTypeValueWriter.java
new file mode 100644
index 0000000000..cbc8277dc8
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/RestrictedTypeValueWriter.java
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.RestrictedType;
+
+public class RestrictedTypeValueWriter<V> extends DelegatingValueWriter<RestrictedType<V>>
+{
+ public RestrictedTypeValueWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected Object getUnderlyingValue(final RestrictedType<V> restrictedType)
+ {
+ return restrictedType.getValue();
+ }
+
+ private static Factory FACTORY = new Factory()
+ {
+
+ public ValueWriter newInstance(Registry registry)
+ {
+ return new RestrictedTypeValueWriter(registry);
+ }
+ };
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public static void register(ValueWriter.Registry registry, Class clazz)
+ {
+ registry.register(clazz, FACTORY);
+ }}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ShortTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ShortTypeConstructor.java
new file mode 100644
index 0000000000..648ed36c69
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ShortTypeConstructor.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.nio.ByteBuffer;
+
+public class ShortTypeConstructor implements TypeConstructor
+{
+ private static final ShortTypeConstructor INSTANCE = new ShortTypeConstructor();
+
+
+ public static ShortTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private ShortTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.remaining()>=2)
+ {
+ return in.getShort();
+ }
+ else
+ {
+ org.apache.qpid.amqp_1_0.type.transport.Error error = new org.apache.qpid.amqp_1_0.type.transport.Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct short: insufficient input data");
+ throw new AmqpErrorException(error);
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ShortWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ShortWriter.java
new file mode 100644
index 0000000000..52ec577c3e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ShortWriter.java
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+public class ShortWriter extends FixedTwoWriter<Short>
+{
+
+ private static final byte FORMAT_CODE = (byte)0x61;
+
+
+ @Override
+ short convertValueToShort(Short value)
+ {
+ return value.shortValue();
+ }
+
+ @Override
+ byte getFormatCode()
+ {
+ return FORMAT_CODE;
+ }
+
+ private static Factory<Short> FACTORY = new Factory<Short>()
+ {
+
+ public ValueWriter<Short> newInstance(Registry registry)
+ {
+ return new ShortWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Short.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SimpleVariableWidthWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SimpleVariableWidthWriter.java
new file mode 100644
index 0000000000..bd14483361
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SimpleVariableWidthWriter.java
@@ -0,0 +1,68 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public abstract class SimpleVariableWidthWriter<V> extends VariableWidthWriter<V>
+{
+ private byte[] _buf;
+
+
+ public void setValue(V value)
+ {
+ _buf = getByteArray(value);
+ super.setValue(value);
+ }
+
+ protected int getLength()
+ {
+ return _buf.length;
+ }
+
+ protected void writeBytes(ByteBuffer buf, int offset, int length)
+ {
+ buf.put(_buf, getOffset()+offset, length);
+ }
+
+ @Override
+ protected void clearValue()
+ {
+ _buf = null;
+ }
+
+ @Override
+ protected boolean hasValue()
+ {
+ return _buf != null;
+ }
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ protected abstract byte[] getByteArray(V value);
+
+ protected abstract int getOffset();
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallIntConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallIntConstructor.java
new file mode 100644
index 0000000000..07fa853dce
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallIntConstructor.java
@@ -0,0 +1,58 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.nio.ByteBuffer;
+
+public class SmallIntConstructor implements TypeConstructor
+{
+ private static final SmallIntConstructor INSTANCE = new SmallIntConstructor();
+
+
+ public static SmallIntConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private SmallIntConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.hasRemaining())
+ {
+ byte b = in.get();
+ return (int) b;
+ }
+ else
+ {
+ Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct int: insufficient input data");
+ throw new AmqpErrorException(error);
+ }
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallLongConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallLongConstructor.java
new file mode 100644
index 0000000000..013b9bef64
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallLongConstructor.java
@@ -0,0 +1,58 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.nio.ByteBuffer;
+
+public class SmallLongConstructor implements TypeConstructor
+{
+ private static final SmallLongConstructor INSTANCE = new SmallLongConstructor();
+
+
+ public static SmallLongConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private SmallLongConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.hasRemaining())
+ {
+ byte b = in.get();
+ return (long) b;
+ }
+ else
+ {
+ Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct long: insufficient input data");
+ throw new AmqpErrorException(error);
+ }
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallUIntConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallUIntConstructor.java
new file mode 100644
index 0000000000..b3a9e3ef19
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallUIntConstructor.java
@@ -0,0 +1,58 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.UnsignedInteger;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.nio.ByteBuffer;
+
+public class SmallUIntConstructor implements TypeConstructor
+{
+ private static final SmallUIntConstructor INSTANCE = new SmallUIntConstructor();
+
+
+ public static SmallUIntConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private SmallUIntConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.hasRemaining())
+ {
+ byte b = in.get();
+ return UnsignedInteger.valueOf(((int) b) & 0xff);
+ }
+ else
+ {
+ Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct uint: insufficient input data");
+ throw new AmqpErrorException(error);
+ }
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallULongConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallULongConstructor.java
new file mode 100644
index 0000000000..38cd0b65ac
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SmallULongConstructor.java
@@ -0,0 +1,59 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.nio.ByteBuffer;
+
+public class SmallULongConstructor implements TypeConstructor
+{
+ private static final SmallULongConstructor INSTANCE = new SmallULongConstructor();
+
+
+ public static SmallULongConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private SmallULongConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.hasRemaining())
+ {
+ byte b = in.get();
+ return UnsignedLong.valueOf(((long) b) & 0xffL);
+ }
+ else
+ {
+ Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct ulong: insufficient input data");
+ throw new AmqpErrorException(error);
+ }
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/StringTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/StringTypeConstructor.java
new file mode 100644
index 0000000000..73b85d4163
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/StringTypeConstructor.java
@@ -0,0 +1,132 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class StringTypeConstructor extends VariableWidthTypeConstructor
+{
+ private Charset _charSet;
+
+ private BinaryString _defaultBinaryString = new BinaryString();
+ private ValueCache<BinaryString, String> _cachedValues = new ValueCache<BinaryString, String>(10);
+
+ private static final class ValueCache<K,V> extends LinkedHashMap<K,V>
+ {
+ private final int _cacheSize;
+
+ public ValueCache(int cacheSize)
+ {
+ _cacheSize = cacheSize;
+ }
+
+ @Override
+ protected boolean removeEldestEntry(Map.Entry<K, V> eldest)
+ {
+ return size() > _cacheSize;
+ }
+
+ public boolean isFull()
+ {
+ return size() == _cacheSize;
+ }
+ }
+
+
+ public static StringTypeConstructor getInstance(int i, Charset c)
+ {
+ return new StringTypeConstructor(i, c);
+ }
+
+
+ private StringTypeConstructor(int size, Charset c)
+ {
+ super(size);
+ _charSet = c;
+ }
+
+ @Override
+ public Object construct(final ByteBuffer in, boolean isCopy, ValueHandler handler) throws AmqpErrorException
+ {
+ int size;
+
+ if(getSize() == 1)
+ {
+ size = in.get() & 0xFF;
+ }
+ else
+ {
+ size = in.getInt();
+ }
+
+ int origPosition = in.position();
+ _defaultBinaryString.setData(in.array(), in.arrayOffset()+ origPosition, size);
+
+ BinaryString binaryStr = _defaultBinaryString;
+
+ boolean isFull = _cachedValues.isFull();
+
+ String str = isFull ? _cachedValues.remove(binaryStr) : _cachedValues.get(binaryStr);
+
+ if(str == null)
+ {
+
+ ByteBuffer dup = in.duplicate();
+ try
+ {
+ dup.limit(dup.position()+size);
+ }
+ catch(IllegalArgumentException e)
+ {
+ throw new IllegalArgumentException("position: " + dup.position() + "size: " + size + " capacity: " + dup.capacity());
+ }
+ CharBuffer charBuf = _charSet.decode(dup);
+
+ str = charBuf.toString();
+
+ byte[] data = new byte[size];
+ in.get(data);
+ binaryStr = new BinaryString(data, 0, size);
+
+ _cachedValues.put(binaryStr, str);
+ }
+ else if(isFull)
+ {
+ byte[] data = new byte[size];
+ in.get(data);
+ binaryStr = new BinaryString(data, 0, size);
+
+ _cachedValues.put(binaryStr, str);
+ }
+
+ in.position(origPosition+size);
+
+ return str;
+
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/StringWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/StringWriter.java
new file mode 100644
index 0000000000..39f759e54d
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/StringWriter.java
@@ -0,0 +1,146 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class StringWriter extends SimpleVariableWidthWriter<String>
+{
+ private static final Charset ENCODING_CHARSET;
+ private static final byte ONE_BYTE_CODE;
+ private static final byte FOUR_BYTE_CODE;
+ static
+ {
+ Charset defaultCharset = Charset.defaultCharset();
+ if(defaultCharset.name().equals("UTF-16") || defaultCharset.name().equals("UTF-16BE"))
+ {
+ ENCODING_CHARSET = defaultCharset;
+ ONE_BYTE_CODE = (byte) 0xa2;
+ FOUR_BYTE_CODE = (byte) 0xb2;
+ }
+ else
+ {
+ ENCODING_CHARSET = Charset.forName("UTF-8");
+ ONE_BYTE_CODE = (byte) 0xa1;
+ FOUR_BYTE_CODE = (byte) 0xb1;
+ }
+ }
+
+ private static final class ValueCache<K,V> extends LinkedHashMap<K,V>
+ {
+ private final int _cacheSize;
+
+ public ValueCache(int cacheSize)
+ {
+ _cacheSize = cacheSize;
+ }
+
+ @Override
+ protected boolean removeEldestEntry(Map.Entry<K, V> eldest)
+ {
+ return size() > _cacheSize;
+ }
+
+ public boolean isFull()
+ {
+ return size() == _cacheSize;
+ }
+ }
+
+ private final ValueCache<String, byte[]> _cachedEncodings = new ValueCache<String, byte[]>(10);
+
+
+ @Override
+ protected byte getFourOctetEncodingCode()
+ {
+ return FOUR_BYTE_CODE;
+ }
+
+ @Override
+ protected byte getSingleOctetEncodingCode()
+ {
+ return ONE_BYTE_CODE;
+ }
+
+ @Override
+ protected byte[] getByteArray(String value)
+ {
+
+ byte[] encoding;
+ boolean isFull = _cachedEncodings.isFull();
+ if(isFull)
+ {
+ encoding = _cachedEncodings.remove(value);
+ }
+ else
+ {
+ encoding = _cachedEncodings.get(value);
+ }
+
+
+ if(encoding == null)
+ {
+ ByteBuffer buf = ENCODING_CHARSET.encode(value);
+ if(buf.hasArray() && buf.arrayOffset() == 0 && buf.limit()==buf.capacity())
+ {
+ encoding = buf.array();
+ }
+ else
+ {
+ byte[] bufArray = new byte[buf.limit()-buf.position()];
+ buf.get(bufArray);
+ encoding = bufArray;
+ }
+ _cachedEncodings.put(value,encoding);
+
+ }
+ else if(isFull)
+ {
+ _cachedEncodings.put(value,encoding);
+ }
+
+ return encoding;
+ }
+
+ @Override
+ protected int getOffset()
+ {
+ return 0;
+ }
+
+ private static Factory<String> FACTORY = new Factory<String>()
+ {
+
+ public ValueWriter<String> newInstance(Registry registry)
+ {
+ return new StringWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(String.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolArrayWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolArrayWriter.java
new file mode 100644
index 0000000000..234a6afe24
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolArrayWriter.java
@@ -0,0 +1,170 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.Symbol;
+
+import java.nio.ByteBuffer;
+
+public class SymbolArrayWriter extends VariableWidthWriter<Symbol[]>
+{
+
+ private int _length;
+ private byte[] _encodedVal;
+
+ @Override protected void clearValue()
+ {
+ _encodedVal = null;
+ }
+
+ @Override protected boolean hasValue()
+ {
+ return _encodedVal != null;
+ }
+
+ @Override protected byte getFourOctetEncodingCode()
+ {
+ return (byte) 0xf0;
+ }
+
+ @Override protected byte getSingleOctetEncodingCode()
+ {
+ return (byte) 0xe0;
+ }
+
+ @Override protected int getLength()
+ {
+ return _length;
+ }
+
+ @Override protected void writeBytes(final ByteBuffer buf, final int offset, final int length)
+ {
+ buf.put(_encodedVal,offset,length);
+ }
+
+ public boolean isCacheable()
+ {
+ return false;
+ }
+
+ public void setValue(final Symbol[] value)
+ {
+
+ boolean useSmallConstructor = useSmallConstructor(value);
+ boolean isSmall = useSmallConstructor && canFitInSmall(value);
+ if(isSmall)
+ {
+ _length = 2;
+ }
+ else
+ {
+ _length = 5;
+ }
+ for(Symbol symbol : value)
+ {
+ _length += symbol.length() ;
+ }
+ _length += value.length * (useSmallConstructor ? 1 : 4);
+
+
+ _encodedVal = new byte[_length];
+
+ ByteBuffer buf = ByteBuffer.wrap(_encodedVal);
+ if(isSmall)
+ {
+ buf.put((byte)value.length);
+ buf.put(SymbolWriter.SMALL_ENCODING_CODE);
+ }
+ else
+ {
+ buf.putInt(value.length);
+ buf.put(SymbolWriter.LARGE_ENCODING_CODE);
+ }
+
+ for(Symbol symbol : value)
+ {
+ if(isSmall)
+ {
+ buf.put((byte)symbol.length());
+ }
+ else
+ {
+ buf.putInt(symbol.length());
+ }
+
+
+ for(int i = 0; i < symbol.length(); i++)
+ {
+ buf.put((byte)symbol.charAt(i));
+ }
+ }
+
+
+
+ super.setValue(value);
+ }
+
+ private boolean useSmallConstructor(final Symbol[] value)
+ {
+ for(Symbol sym : value)
+ {
+ if(sym.length()>255)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean canFitInSmall(final Symbol[] value)
+ {
+ if(value.length>=127)
+ {
+ return false;
+ }
+
+ int remaining = 253 - value.length;
+ for(Symbol symbol : value)
+ {
+
+ if((remaining -= symbol.length()) < 0)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+ private static Factory<Symbol[]> FACTORY = new Factory<Symbol[]>()
+ {
+
+ public ValueWriter<Symbol[]> newInstance(Registry registry)
+ {
+ return new SymbolArrayWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Symbol[].class, FACTORY);
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolTypeConstructor.java
new file mode 100644
index 0000000000..ce0f5cb26b
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolTypeConstructor.java
@@ -0,0 +1,109 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class SymbolTypeConstructor extends VariableWidthTypeConstructor
+{
+ private static final Charset ASCII = Charset.forName("US-ASCII");
+
+ private BinaryString _defaultBinaryString = new BinaryString();
+
+ private static final ConcurrentHashMap<BinaryString, Symbol> SYMBOL_MAP =
+ new ConcurrentHashMap<BinaryString, Symbol>(2048);
+
+ public static SymbolTypeConstructor getInstance(int i)
+ {
+ return new SymbolTypeConstructor(i);
+ }
+
+
+ private SymbolTypeConstructor(int size)
+ {
+ super(size);
+ }
+
+ @Override
+ public Object construct(final ByteBuffer in, boolean isCopy, ValueHandler handler) throws AmqpErrorException
+ {
+ int size;
+
+ if(getSize() == 1)
+ {
+ size = in.get() & 0xFF;
+ }
+ else
+ {
+ size = in.getInt();
+ }
+
+ _defaultBinaryString.setData(in.array(), in.arrayOffset()+in.position(), size);
+
+ BinaryString binaryStr = _defaultBinaryString;
+
+ Symbol symbolVal = SYMBOL_MAP.get(binaryStr);
+ if(symbolVal == null)
+ {
+ ByteBuffer dup = in.duplicate();
+ try
+ {
+ dup.limit(in.position()+size);
+ }
+ catch (IllegalArgumentException e)
+ {
+ System.err.println("in.position(): " + in.position());
+ System.err.println("size: " + size);
+ System.err.println("dup.position(): " + dup.position());
+ System.err.println("dup.capacity(): " + dup.capacity());
+ System.err.println("dup.limit(): " + dup.limit());
+ throw e;
+
+ }
+ CharBuffer charBuf = ASCII.decode(dup);
+
+
+ symbolVal = Symbol.getSymbol(charBuf.toString());
+
+
+
+
+ byte[] data = new byte[size];
+ in.get(data);
+ binaryStr = new BinaryString(data, 0, size);
+ SYMBOL_MAP.putIfAbsent(binaryStr, symbolVal);
+ }
+ else
+ {
+ in.position(in.position()+size);
+ }
+
+ return symbolVal;
+
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolWriter.java
new file mode 100644
index 0000000000..ae43c7ebd2
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolWriter.java
@@ -0,0 +1,102 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.Symbol;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+public class SymbolWriter extends VariableWidthWriter<Symbol>
+{
+ private static final Charset ENCODING_CHARSET = Charset.forName("US-ASCII");
+ public static final byte LARGE_ENCODING_CODE = (byte) 0xb3;
+ public static final byte SMALL_ENCODING_CODE = (byte) 0xa3;
+ private Symbol _value;
+
+
+ @Override
+ protected byte getFourOctetEncodingCode()
+ {
+ return LARGE_ENCODING_CODE;
+ }
+
+ @Override
+ protected byte getSingleOctetEncodingCode()
+ {
+ return SMALL_ENCODING_CODE;
+ }
+
+ @Override
+ public void setValue(Symbol value)
+ {
+ _value = value;
+ super.setValue(value);
+ }
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ @Override
+ protected void clearValue()
+ {
+ _value = null;
+ }
+
+ @Override
+ protected boolean hasValue()
+ {
+ return _value != null;
+ }
+
+ @Override
+ protected int getLength()
+ {
+ return _value.length();
+ }
+
+ @Override
+ protected void writeBytes(ByteBuffer buf, int offset, int length)
+ {
+ int end = offset + length;
+ for(int i = offset; i < end; i++)
+ {
+ buf.put((byte)_value.charAt(i));
+ }
+ }
+
+ private static Factory<Symbol> FACTORY = new Factory<Symbol>()
+ {
+
+ public ValueWriter<Symbol> newInstance(Registry registry)
+ {
+ return new SymbolWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Symbol.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TimestampTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TimestampTypeConstructor.java
new file mode 100644
index 0000000000..d826e0ee56
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TimestampTypeConstructor.java
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.nio.ByteBuffer;
+import java.util.Date;
+
+public class TimestampTypeConstructor implements TypeConstructor
+{
+ private static final TimestampTypeConstructor INSTANCE = new TimestampTypeConstructor();
+
+
+ public static TimestampTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private TimestampTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.remaining()>=8)
+ {
+ long l = in.getLong();
+ return new Date(l);
+ }
+ else
+ {
+ org.apache.qpid.amqp_1_0.type.transport.Error error = new org.apache.qpid.amqp_1_0.type.transport.Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct timestamp: insufficient input data");
+ throw new AmqpErrorException(error);
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TimestampWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TimestampWriter.java
new file mode 100644
index 0000000000..153c51b7c7
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TimestampWriter.java
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.util.Date;
+
+public class TimestampWriter extends FixedEightWriter<Date>
+{
+ private static final byte FORMAT_CODE = (byte) 0x83;
+
+
+ @Override
+ byte getFormatCode()
+ {
+ return FORMAT_CODE;
+ }
+
+ @Override
+ long convertValueToLong(Date value)
+ {
+ return value.getTime();
+ }
+
+ private static Factory<Date> FACTORY = new Factory<Date>()
+ {
+
+ public ValueWriter<Date> newInstance(Registry registry)
+ {
+ return new TimestampWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Date.class, FACTORY);
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TypeConstructor.java
new file mode 100644
index 0000000000..8b433e4b20
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/TypeConstructor.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+
+public interface TypeConstructor<T>
+{
+
+ public T construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException;
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UByteTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UByteTypeConstructor.java
new file mode 100644
index 0000000000..7ff5abc558
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UByteTypeConstructor.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.nio.ByteBuffer;
+
+public class UByteTypeConstructor implements TypeConstructor
+{
+ private static final UByteTypeConstructor INSTANCE = new UByteTypeConstructor();
+
+
+ public static UByteTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private UByteTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.hasRemaining())
+ {
+ byte b = in.get();
+ return UnsignedByte.valueOf(b);
+ }
+ else
+ {
+ Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct ubyte: insufficient input data");
+ throw new AmqpErrorException(error);
+ }
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UIntTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UIntTypeConstructor.java
new file mode 100644
index 0000000000..fc0c433d7c
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UIntTypeConstructor.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.nio.ByteBuffer;
+
+public class UIntTypeConstructor implements TypeConstructor
+{
+ private static final UIntTypeConstructor INSTANCE = new UIntTypeConstructor();
+
+
+ public static UIntTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private UIntTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.remaining()>=4)
+ {
+ final int i = in.getInt();
+ return UnsignedInteger.valueOf(i);
+ }
+ else
+ {
+ org.apache.qpid.amqp_1_0.type.transport.Error error = new org.apache.qpid.amqp_1_0.type.transport.Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct uint: insufficient input data");
+ throw new AmqpErrorException(error);
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ULongTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ULongTypeConstructor.java
new file mode 100644
index 0000000000..550a61b4fa
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ULongTypeConstructor.java
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.nio.ByteBuffer;
+
+public class ULongTypeConstructor implements TypeConstructor
+{
+ private static final ULongTypeConstructor INSTANCE = new ULongTypeConstructor();
+
+
+ public static ULongTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private ULongTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.remaining()>=8)
+ {
+ long l = in.getLong();
+
+ return UnsignedLong.valueOf(l);
+
+ }
+ else
+ {
+ org.apache.qpid.amqp_1_0.type.transport.Error error = new org.apache.qpid.amqp_1_0.type.transport.Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct ulong: insufficient input data");
+ throw new AmqpErrorException(error);
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UShortTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UShortTypeConstructor.java
new file mode 100644
index 0000000000..6cf7cb5dca
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UShortTypeConstructor.java
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.nio.ByteBuffer;
+
+public class UShortTypeConstructor implements TypeConstructor
+{
+ private static final UShortTypeConstructor INSTANCE = new UShortTypeConstructor();
+
+
+ public static UShortTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private UShortTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.remaining()>=2)
+ {
+ short s = in.getShort();
+ return UnsignedShort.valueOf(s);
+ }
+ else
+ {
+ org.apache.qpid.amqp_1_0.type.transport.Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct ushort: insufficient input data");
+ throw new AmqpErrorException(error);
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UUIDTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UUIDTypeConstructor.java
new file mode 100644
index 0000000000..c34a8fca65
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UUIDTypeConstructor.java
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.nio.ByteBuffer;
+import java.util.UUID;
+
+public class UUIDTypeConstructor implements TypeConstructor
+{
+ private static final UUIDTypeConstructor INSTANCE = new UUIDTypeConstructor();
+
+
+ public static UUIDTypeConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private UUIDTypeConstructor()
+ {
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ if(in.remaining()>=16)
+ {
+ long msb = in.getLong();
+ long lsb = in.getLong();
+ return new UUID(msb, lsb);
+ }
+ else
+ {
+ org.apache.qpid.amqp_1_0.type.transport.Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct UUID: insufficient input data");
+ throw new AmqpErrorException(error);
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UUIDWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UUIDWriter.java
new file mode 100644
index 0000000000..b900fd63ce
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UUIDWriter.java
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.util.UUID;
+
+public class UUIDWriter extends FixedSixteenWriter<UUID>
+{
+ private static final byte FORMAT_CODE = (byte) 0x98;
+
+
+ @Override
+ byte getFormatCode()
+ {
+ return FORMAT_CODE;
+ }
+
+ @Override
+ long convertValueToMSB(UUID value)
+ {
+ return value.getMostSignificantBits();
+ }
+
+ @Override
+ long convertValueToLSB(UUID value)
+ {
+ return value.getLeastSignificantBits();
+ }
+
+ private static Factory<UUID> FACTORY = new Factory<UUID>()
+ {
+
+ public ValueWriter<UUID> newInstance(Registry registry)
+ {
+ return new UUIDWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(UUID.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedByteWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedByteWriter.java
new file mode 100644
index 0000000000..aedf3811d9
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedByteWriter.java
@@ -0,0 +1,92 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedByte;
+
+import java.nio.ByteBuffer;
+
+public class UnsignedByteWriter implements ValueWriter<UnsignedByte>
+{
+ private int _written;
+ private byte _value;
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+
+ switch(_written)
+ {
+ case 0:
+ if(buffer.hasRemaining())
+ {
+ buffer.put((byte)0x50);
+ }
+ else
+ {
+ break;
+ }
+ case 1:
+ if(buffer.hasRemaining())
+ {
+ buffer.put(_value);
+ _written = 2;
+ }
+ else
+ {
+ _written = 1;
+ }
+
+ }
+
+ return 2;
+ }
+
+ public void setValue(UnsignedByte value)
+ {
+ _written = 0;
+ _value = value.byteValue();
+ }
+
+ public boolean isComplete()
+ {
+ return _written == 2;
+ }
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ private static Factory<UnsignedByte> FACTORY = new Factory<UnsignedByte>()
+ {
+
+ public ValueWriter<UnsignedByte> newInstance(Registry registry)
+ {
+ return new UnsignedByteWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(UnsignedByte.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedIntegerWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedIntegerWriter.java
new file mode 100644
index 0000000000..9517bd9c6e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedIntegerWriter.java
@@ -0,0 +1,148 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedInteger;
+
+import java.nio.ByteBuffer;
+
+public class UnsignedIntegerWriter implements ValueWriter<UnsignedInteger>
+{
+ private static final byte EIGHT_BYTE_FORMAT_CODE = (byte)0x70;
+ private static final byte ONE_BYTE_FORMAT_CODE = (byte) 0x52;
+ private static final byte ZERO_BYTE_FORMAT_CODE = (byte) 0x43;
+
+ private ValueWriter<UnsignedInteger> _delegate;
+
+ private final FixedFourWriter<UnsignedInteger> _eightByteWriter = new FixedFourWriter<UnsignedInteger>()
+ {
+
+ @Override
+ byte getFormatCode()
+ {
+ return EIGHT_BYTE_FORMAT_CODE;
+ }
+
+ @Override
+ int convertValueToInt(UnsignedInteger value)
+ {
+ return value.intValue();
+ }
+ };
+
+ private final ValueWriter<UnsignedInteger> _oneByteWriter = new FixedOneWriter<UnsignedInteger>()
+ {
+
+ @Override protected byte getFormatCode()
+ {
+ return ONE_BYTE_FORMAT_CODE;
+ }
+
+ @Override protected byte convertToByte(final UnsignedInteger value)
+ {
+ return value.byteValue();
+ }
+ };
+
+ private final ValueWriter<UnsignedInteger> _zeroByteWriter = new ValueWriter<UnsignedInteger>()
+ {
+ private boolean _complete;
+
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+
+ if(!_complete && buffer.hasRemaining())
+ {
+ buffer.put(ZERO_BYTE_FORMAT_CODE);
+ _complete = true;
+ }
+
+ return 1;
+ }
+
+ public void setValue(UnsignedInteger uint)
+ {
+ _complete = false;
+ }
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public boolean isComplete()
+ {
+ return _complete;
+ }
+
+ };
+
+
+
+ public int writeToBuffer(final ByteBuffer buffer)
+ {
+ return _delegate.writeToBuffer(buffer);
+ }
+
+ public void setValue(final UnsignedInteger uint)
+ {
+ if(uint.equals(UnsignedInteger.ZERO))
+ {
+ _delegate = _zeroByteWriter;
+ }
+ else if(uint.compareTo(UnsignedInteger.valueOf(256))<0)
+ {
+ _delegate = _oneByteWriter;
+ }
+ else
+ {
+ _delegate = _eightByteWriter;
+ }
+ _delegate.setValue(uint);
+ }
+
+ public boolean isComplete()
+ {
+ return _delegate.isComplete();
+ }
+
+ public boolean isCacheable()
+ {
+ return false;
+ }
+
+
+ private static Factory<UnsignedInteger> FACTORY = new Factory<UnsignedInteger>()
+ {
+
+ public ValueWriter<UnsignedInteger> newInstance(Registry registry)
+ {
+ return new UnsignedIntegerWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(UnsignedInteger.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedLongWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedLongWriter.java
new file mode 100644
index 0000000000..4345187d61
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedLongWriter.java
@@ -0,0 +1,152 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+
+import java.nio.ByteBuffer;
+
+public class UnsignedLongWriter implements ValueWriter<UnsignedLong>
+{
+
+
+ private static final byte EIGHT_BYTE_FORMAT_CODE = (byte) 0x80;
+ private static final byte ONE_BYTE_FORMAT_CODE = (byte) 0x53;
+ private static final byte ZERO_BYTE_FORMAT_CODE = (byte) 0x44;
+
+ private ValueWriter<UnsignedLong> _delegate;
+
+ private final FixedEightWriter<UnsignedLong> _eightByteWriter = new FixedEightWriter<UnsignedLong>()
+ {
+
+ @Override
+ byte getFormatCode()
+ {
+ return EIGHT_BYTE_FORMAT_CODE;
+ }
+
+ @Override
+ long convertValueToLong(UnsignedLong value)
+ {
+ return value.longValue();
+ }
+
+ };
+
+ private final ValueWriter<UnsignedLong> _oneByteWriter = new FixedOneWriter<UnsignedLong>()
+ {
+
+ @Override protected byte getFormatCode()
+ {
+ return ONE_BYTE_FORMAT_CODE;
+ }
+
+ @Override protected byte convertToByte(final UnsignedLong value)
+ {
+ return value.byteValue();
+ }
+ };
+
+ private final ValueWriter<UnsignedLong> _zeroByteWriter = new ValueWriter<UnsignedLong>()
+ {
+ private boolean _complete;
+
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+
+ if(!_complete && buffer.hasRemaining())
+ {
+ buffer.put(ZERO_BYTE_FORMAT_CODE);
+ _complete = true;
+ }
+
+ return 1;
+ }
+
+ public void setValue(UnsignedLong ulong)
+ {
+ _complete = false;
+ }
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public boolean isComplete()
+ {
+ return _complete;
+ }
+
+ };
+
+
+
+ private static Factory<UnsignedLong> FACTORY = new Factory<UnsignedLong>()
+ {
+
+ public ValueWriter<UnsignedLong> newInstance(Registry registry)
+ {
+ return new UnsignedLongWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(UnsignedLong.class, FACTORY);
+ }
+
+ public int writeToBuffer(final ByteBuffer buffer)
+ {
+ return _delegate.writeToBuffer(buffer);
+ }
+
+ public void setValue(final UnsignedLong ulong)
+ {
+ if(ulong.equals(UnsignedLong.ZERO))
+ {
+ _delegate = _zeroByteWriter;
+ }
+ else if(ulong.compareTo(UnsignedLong.valueOf(256))<0)
+ {
+ _delegate = _oneByteWriter;
+ }
+ else
+ {
+ _delegate = _eightByteWriter;
+ }
+
+ _delegate.setValue(ulong);
+ }
+
+ public boolean isComplete()
+ {
+ return _delegate.isComplete();
+ }
+
+ public boolean isCacheable()
+ {
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedShortWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedShortWriter.java
new file mode 100644
index 0000000000..63d8bf0d7b
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/UnsignedShortWriter.java
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedShort;
+
+public class UnsignedShortWriter extends FixedTwoWriter<UnsignedShort>
+{
+ private static final byte FORMAT_CODE = (byte)0x60;
+
+
+ @Override
+ short convertValueToShort(UnsignedShort value)
+ {
+ return value.shortValue();
+ }
+
+ @Override
+ byte getFormatCode()
+ {
+ return FORMAT_CODE;
+ }
+
+ private static Factory<UnsignedShort> FACTORY = new Factory<UnsignedShort>()
+ {
+
+ public ValueWriter<UnsignedShort> newInstance(Registry registry)
+ {
+ return new UnsignedShortWriter();
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(UnsignedShort.class, FACTORY);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueHandler.java
new file mode 100644
index 0000000000..57351a91d7
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueHandler.java
@@ -0,0 +1,159 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.transport.AmqpError;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+public class ValueHandler implements DescribedTypeConstructorRegistry.Source
+{
+ private static final byte DESCRIBED_TYPE = (byte)0;
+
+ private final DescribedTypeConstructorRegistry _describedTypeConstructorRegistry;
+
+
+ private static final TypeConstructor[][] TYPE_CONSTRUCTORS =
+ {
+ {},
+ {},
+ {},
+ {},
+ { NullTypeConstructor.getInstance(), BooleanConstructor.getTrueInstance(),
+ BooleanConstructor.getFalseInstance(), ZeroUIntConstructor.getInstance(),
+ ZeroULongConstructor.getInstance(), ZeroListConstructor.getInstance() },
+ { UByteTypeConstructor.getInstance(), ByteTypeConstructor.getInstance(),
+ SmallUIntConstructor.getInstance(), SmallULongConstructor.getInstance(),
+ SmallIntConstructor.getInstance(), SmallLongConstructor.getInstance(),
+ BooleanConstructor.getByteInstance()},
+ { UShortTypeConstructor.getInstance(), ShortTypeConstructor.getInstance() },
+ { UIntTypeConstructor.getInstance(), IntTypeConstructor.getInstance(),
+ FloatTypeConstructor.getInstance(), CharTypeConstructor.getInstance(),
+ DecimalConstructor.getDecimal32Instance()},
+ { ULongTypeConstructor.getInstance(), LongTypeConstructor.getInstance(),
+ DoubleTypeConstructor.getInstance(), TimestampTypeConstructor.getInstance(),
+ DecimalConstructor.getDecimal64Instance()},
+ { null, null,
+ null, null,
+ DecimalConstructor.getDecimal128Instance(), null,
+ null, null,
+ UUIDTypeConstructor.getInstance() },
+ { BinaryTypeConstructor.getInstance(1),
+ StringTypeConstructor.getInstance(1, Charset.forName("UTF8")),
+ StringTypeConstructor.getInstance(1, Charset.forName("UTF16")),
+ SymbolTypeConstructor.getInstance(1) },
+ { BinaryTypeConstructor.getInstance(4),
+ StringTypeConstructor.getInstance(4, Charset.forName("UTF8")),
+ StringTypeConstructor.getInstance(4, Charset.forName("UTF16")),
+ SymbolTypeConstructor.getInstance(4) },
+ { CompoundTypeConstructor.getInstance(1, CompoundTypeConstructor.LIST_ASSEMBLER_FACTORY),
+ CompoundTypeConstructor.getInstance(1, CompoundTypeConstructor.MAP_ASSEMBLER_FACTORY) },
+ { CompoundTypeConstructor.getInstance(4, CompoundTypeConstructor.LIST_ASSEMBLER_FACTORY),
+ CompoundTypeConstructor.getInstance(4, CompoundTypeConstructor.MAP_ASSEMBLER_FACTORY) },
+ {
+ ArrayTypeConstructor.getOneByteSizeTypeConstructor()
+ },
+ {
+ ArrayTypeConstructor.getFourByteSizeTypeConstructor()
+ }
+ };
+
+
+ public ValueHandler(DescribedTypeConstructorRegistry registry)
+ {
+ _describedTypeConstructorRegistry = registry;
+ }
+
+ public Object parse(final ByteBuffer in) throws AmqpErrorException
+ {
+ TypeConstructor constructor = readConstructor(in);
+ return constructor.construct(in, this);
+ }
+
+
+ public TypeConstructor readConstructor(ByteBuffer in) throws AmqpErrorException
+ {
+ if(!in.hasRemaining())
+ {
+ throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data - expected type, no data remaining");
+ }
+ byte formatCode = in.get();
+
+ if(formatCode == DESCRIBED_TYPE)
+ {
+ Object descriptor = parse(in);
+ DescribedTypeConstructor describedTypeConstructor = _describedTypeConstructorRegistry.getConstructor(descriptor);
+ if(describedTypeConstructor==null)
+ {
+ describedTypeConstructor=new DefaultDescribedTypeConstructor(descriptor);
+ }
+ TypeConstructor typeConstructor = readConstructor(in);
+
+ return describedTypeConstructor.construct(typeConstructor);
+
+ }
+ else
+ {
+ int subCategory = (formatCode >> 4) & 0x0F;
+ int subtype = formatCode & 0x0F;
+
+ TypeConstructor tc;
+ try
+ {
+ tc = TYPE_CONSTRUCTORS[subCategory][subtype];
+ }
+ catch(IndexOutOfBoundsException e)
+ {
+ tc = null;
+ }
+
+ if(tc == null)
+ {
+ throw new AmqpErrorException(ConnectionError.FRAMING_ERROR,"Unknown type format-code 0x%02x", formatCode);
+ }
+
+ return tc;
+ }
+ }
+
+
+
+
+
+ @Override
+ public String toString()
+ {
+ return "ValueHandler{" +
+ ", _describedTypeConstructorRegistry=" + _describedTypeConstructorRegistry +
+ '}';
+ }
+
+
+ public DescribedTypeConstructorRegistry getDescribedTypeRegistry()
+ {
+ return _describedTypeConstructorRegistry;
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueProducingProtocolHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueProducingProtocolHandler.java
new file mode 100644
index 0000000000..48db222aa0
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueProducingProtocolHandler.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+public interface ValueProducingProtocolHandler extends ProtocolHandler
+{
+ Object getValue();
+ public boolean hasError();
+ public Error getError();
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueWriter.java
new file mode 100644
index 0000000000..7918397994
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ValueWriter.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+import java.util.Map;
+
+public interface ValueWriter<T extends Object>
+{
+
+
+
+ public static interface Factory<V extends Object>
+ {
+ ValueWriter<V> newInstance(Registry registry);
+ }
+
+ public static interface Registry
+ {
+ public static interface Source
+ {
+ public Registry getDescribedTypeRegistry();
+ }
+
+ <V extends Object> ValueWriter<V> getValueWriter(V value);
+ <V extends Object> ValueWriter<V> getValueWriter(V value, Map<Class, ValueWriter> localCache);
+ <V extends Object> ValueWriter<V> register(Class<V> clazz, ValueWriter.Factory<V> writer);
+
+ }
+
+
+ int writeToBuffer(ByteBuffer buffer);
+
+ void setValue(T frameBody);
+
+ boolean isComplete();
+
+ boolean isCacheable();
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthTypeConstructor.java
new file mode 100644
index 0000000000..35ce253623
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthTypeConstructor.java
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+
+import java.nio.ByteBuffer;
+
+public abstract class VariableWidthTypeConstructor implements TypeConstructor
+{
+ protected int _size;
+
+ public VariableWidthTypeConstructor(int size)
+ {
+ _size = size;
+ }
+
+ public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ {
+ return construct(in, false, handler);
+ }
+
+ public int getSize()
+ {
+ return _size;
+ }
+
+ public abstract Object construct(ByteBuffer in, boolean isCopy, ValueHandler handler) throws AmqpErrorException;
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthWriter.java
new file mode 100644
index 0000000000..93b2b5e6d8
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/VariableWidthWriter.java
@@ -0,0 +1,169 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import java.nio.ByteBuffer;
+
+public abstract class VariableWidthWriter<V> implements ValueWriter<V>
+{
+ private int _written;
+ private int _size;
+
+ public int writeToBuffer(ByteBuffer buffer)
+ {
+
+ int written = _written;
+ final int length = getLength();
+ boolean singleOctetSize = _size == 1;
+ if(singleOctetSize)
+ {
+ switch(written)
+ {
+ case 0:
+ if(buffer.hasRemaining())
+ {
+ buffer.put(getSingleOctetEncodingCode());
+ }
+ else
+ {
+ break;
+ }
+ case 1:
+ if(buffer.hasRemaining())
+ {
+ buffer.put((byte)length);
+ written = 2;
+ }
+ else
+ {
+ written = 1;
+ break;
+ }
+ default:
+
+ final int toWrite = 2 + length - written;
+ if(buffer.remaining() >= toWrite)
+ {
+ writeBytes(buffer, written-2,toWrite);
+ written = length + 2;
+ clearValue();
+ }
+ else
+ {
+ final int remaining = buffer.remaining();
+
+ writeBytes(buffer, written-2, remaining);
+ written += remaining;
+ }
+
+ }
+ }
+ else
+ {
+
+ int remaining = buffer.remaining();
+
+ switch(written)
+ {
+
+ case 0:
+ if(buffer.hasRemaining())
+ {
+ buffer.put(getFourOctetEncodingCode());
+ remaining--;
+ written = 1;
+ }
+ else
+ {
+ break;
+ }
+ case 1:
+ if(remaining >= 4)
+ {
+ buffer.putInt(length);
+ remaining-=4;
+ written+=4;
+ }
+ case 2:
+ case 3:
+ if(remaining >= 2 && written <= 3)
+ {
+ buffer.putShort((short)((length >> ((3-written)<<3)) & 0xFFFF ));
+ remaining -= 2;
+ written += 2;
+ }
+ case 4:
+ if(remaining >=1 && written <=4)
+ {
+ buffer.put((byte)((length>> ((4-written)<<3)) & 0xFF ));
+ written++;
+ }
+
+ default:
+
+ final int toWrite = 5 + length - written;
+ if(buffer.remaining() >= toWrite)
+ {
+ writeBytes(buffer, written-5,toWrite);
+ written = length + 5;
+ clearValue();
+ }
+ else if(buffer.hasRemaining())
+ {
+ written += buffer.remaining();
+ writeBytes(buffer, written-5, buffer.remaining());
+ }
+
+ }
+
+ }
+
+ _written = written;
+ return 1 + _size + length;
+ }
+
+ protected abstract void clearValue();
+
+ protected abstract boolean hasValue();
+
+ protected abstract byte getFourOctetEncodingCode();
+
+ protected abstract byte getSingleOctetEncodingCode();
+
+ public void setValue(V value)
+ {
+ _written = 0;
+ _size = (getLength() & 0xFFFFFF00) == 0 ? 1 : 4;
+ }
+
+ protected abstract int getLength();
+
+ protected abstract void writeBytes(ByteBuffer buf, int offset, int length);
+
+
+ public boolean isComplete()
+ {
+ return !hasValue() || _written == getLength() + _size + 1;
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/WrapperTypeValueWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/WrapperTypeValueWriter.java
new file mode 100644
index 0000000000..85a3196f6c
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/WrapperTypeValueWriter.java
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.WrapperType;
+
+public class WrapperTypeValueWriter extends DelegatingValueWriter<WrapperType>
+{
+ public WrapperTypeValueWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected Object getUnderlyingValue(final WrapperType wrapperType)
+ {
+ return wrapperType.getValue();
+ }
+
+ private static Factory FACTORY = new Factory()
+ {
+
+ public ValueWriter newInstance(Registry registry)
+ {
+ return new WrapperTypeValueWriter(registry);
+ }
+ };
+
+ public boolean isCacheable()
+ {
+ return true;
+ }
+
+ public static void register(Registry registry, Class<? extends WrapperType> clazz)
+ {
+ registry.register(clazz, FACTORY);
+ }}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroListConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroListConstructor.java
new file mode 100644
index 0000000000..b9d6a50425
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroListConstructor.java
@@ -0,0 +1,46 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.List;
+
+class ZeroListConstructor implements TypeConstructor<List>
+{
+ private static final ZeroListConstructor INSTANCE = new ZeroListConstructor();
+
+ ZeroListConstructor()
+ {
+ }
+
+ public List construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ public static ZeroListConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroUIntConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroUIntConstructor.java
new file mode 100644
index 0000000000..b3c57ceaf7
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroUIntConstructor.java
@@ -0,0 +1,45 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.UnsignedInteger;
+
+import java.nio.ByteBuffer;
+
+class ZeroUIntConstructor implements TypeConstructor<UnsignedInteger>
+{
+ private static final ZeroUIntConstructor INSTANCE = new ZeroUIntConstructor();
+
+ ZeroUIntConstructor()
+ {
+ }
+
+ public UnsignedInteger construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+ return UnsignedInteger.ZERO;
+ }
+
+ public static ZeroUIntConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroULongConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroULongConstructor.java
new file mode 100644
index 0000000000..b2ab2a4158
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/ZeroULongConstructor.java
@@ -0,0 +1,45 @@
+/*
+ * 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.amqp_1_0.codec;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+
+import java.nio.ByteBuffer;
+
+class ZeroULongConstructor implements TypeConstructor<UnsignedLong>
+{
+ private static final ZeroULongConstructor INSTANCE = new ZeroULongConstructor();
+
+ ZeroULongConstructor()
+ {
+ }
+
+ public UnsignedLong construct(final ByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ {
+ return UnsignedLong.ZERO;
+ }
+
+ public static ZeroULongConstructor getInstance()
+ {
+ return INSTANCE;
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQFrame.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQFrame.java
new file mode 100644
index 0000000000..769fe13d29
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQFrame.java
@@ -0,0 +1,68 @@
+/*
+ *
+ * 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.amqp_1_0.framing;
+
+import org.apache.qpid.amqp_1_0.type.FrameBody;
+
+import java.nio.ByteBuffer;
+
+public abstract class AMQFrame<T>
+{
+ private T _frameBody;
+ private ByteBuffer _payload;
+
+ AMQFrame(T frameBody)
+ {
+ _frameBody = frameBody;
+ }
+
+ protected AMQFrame(T frameBody, ByteBuffer payload)
+ {
+ _frameBody = frameBody;
+ _payload = payload;
+ }
+
+ public ByteBuffer getPayload()
+ {
+ return _payload;
+ }
+
+ public static TransportFrame createAMQFrame(short channel, FrameBody frameBody)
+ {
+ return createAMQFrame(channel, frameBody, null);
+ }
+
+ public static TransportFrame createAMQFrame(short channel, FrameBody frameBody, ByteBuffer payload)
+ {
+ return new TransportFrame(channel, frameBody, payload);
+ }
+
+ abstract public short getChannel();
+
+ abstract public byte getFrameType();
+
+ public T getFrameBody()
+ {
+ return _frameBody;
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQPProtocolHeaderHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQPProtocolHeaderHandler.java
new file mode 100644
index 0000000000..007df77f55
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/AMQPProtocolHeaderHandler.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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.amqp_1_0.framing;
+
+import org.apache.qpid.amqp_1_0.codec.ProtocolHandler;
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+import java.nio.ByteBuffer;
+
+public class AMQPProtocolHeaderHandler implements ProtocolHandler
+{
+ private ConnectionEndpoint _connection;
+ private static final byte MAJOR_VERSION = (byte) 1;
+ private static final byte MINOR_VERSION = (byte) 0;
+
+ enum State {
+ AWAITING_MAJOR,
+ AWAITING_MINOR,
+ AWAITING_REVISION,
+ ERROR
+ }
+
+ private State _state = State.AWAITING_MAJOR;
+
+ public AMQPProtocolHeaderHandler(final ConnectionEndpoint connection)
+ {
+ _connection = connection;
+ }
+
+ public ProtocolHandler parse(final ByteBuffer in)
+ {
+ while(in.hasRemaining() && _state != State.ERROR)
+ {
+ switch(_state)
+ {
+ case AWAITING_MAJOR:
+ _state = in.get() == MAJOR_VERSION ? State.AWAITING_MINOR : State.ERROR;
+ if(!in.hasRemaining())
+ {
+ break;
+ }
+ case AWAITING_MINOR:
+ _state = in.get() == MINOR_VERSION ? State.AWAITING_MINOR : State.ERROR;
+ if(!in.hasRemaining())
+ {
+ break;
+ }
+ case AWAITING_REVISION:
+ byte revision = in.get();
+ _connection.protocolHeaderReceived(MAJOR_VERSION, MINOR_VERSION, revision);
+ ProtocolHandler handler = new FrameHandler(_connection);
+ return handler.parse(in);
+ }
+ }
+ if(_state == State.ERROR)
+ {
+ _connection.invalidHeaderReceived();
+ }
+ return this;
+
+ }
+
+ public boolean isDone()
+ {
+ return _state != State.ERROR && !_connection.closedForInput();
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/ConnectionHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/ConnectionHandler.java
new file mode 100644
index 0000000000..78bed8a71e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/ConnectionHandler.java
@@ -0,0 +1,559 @@
+/*
+ *
+ * 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.amqp_1_0.framing;
+
+import org.apache.qpid.amqp_1_0.codec.FrameWriter;
+import org.apache.qpid.amqp_1_0.codec.ProtocolHandler;
+import org.apache.qpid.amqp_1_0.codec.ProtocolHeaderHandler;
+import org.apache.qpid.amqp_1_0.codec.ValueHandler;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+import org.apache.qpid.amqp_1_0.transport.BytesProcessor;
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+import org.apache.qpid.amqp_1_0.transport.FrameOutputHandler;
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.Binary;
+import org.apache.qpid.amqp_1_0.type.transport.Open;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.UnsignedShort;
+import org.apache.qpid.amqp_1_0.type.codec.AMQPDescribedTypeRegistry;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class ConnectionHandler
+{
+ private final ConnectionEndpoint _connection;
+ private ProtocolHandler _delegate;
+
+ private static final Logger FRAME_LOGGER = Logger.getLogger("FRM");
+ private static final Logger RAW_LOGGER = Logger.getLogger("RAW");
+
+ public ConnectionHandler(final ConnectionEndpoint connection)
+ {
+ _connection = connection;
+ _delegate = new ProtocolHeaderHandler(connection);
+ }
+
+
+ public boolean parse(ByteBuffer in)
+ {
+
+ while(in.hasRemaining() && !isDone())
+ {
+ _delegate = _delegate.parse(in);
+
+ }
+ return isDone();
+ }
+
+ public boolean isDone()
+ {
+ return _delegate.isDone();
+ }
+
+
+ // ----------------------------------------------------------------
+
+ public static class FrameOutput<T> implements FrameOutputHandler<T>, FrameSource
+ {
+
+ private static final ByteBuffer EMPTY_BYTEBUFFER = ByteBuffer.wrap(new byte[0]);
+ private final BlockingQueue<AMQFrame<T>> _queue = new ArrayBlockingQueue<AMQFrame<T>>(100);
+ private ConnectionEndpoint _conn;
+
+ private final AMQFrame<T> _endOfFrameMarker = new AMQFrame<T>(null)
+ {
+ @Override public short getChannel()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override public byte getFrameType()
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ private boolean _setForClose;
+ private boolean _closed;
+
+ public FrameOutput(final ConnectionEndpoint conn)
+ {
+ _conn = conn;
+ }
+
+ public boolean canSend()
+ {
+ return _queue.remainingCapacity() != 0;
+ }
+
+ public void send(AMQFrame<T> frame)
+ {
+ send(frame, null);
+ }
+
+ public void send(final AMQFrame<T> frame, final ByteBuffer payload)
+ {
+ synchronized(_conn.getLock())
+ {
+ try
+ {
+// TODO HACK - check frame length
+ int size = _conn.getDescribedTypeRegistry()
+ .getValueWriter(frame.getFrameBody()).writeToBuffer(EMPTY_BYTEBUFFER) + 8;
+
+ if(size > _conn.getMaxFrameSize())
+ {
+ throw new OversizeFrameException(frame, size);
+ }
+
+ while(!_queue.offer(frame))
+ {
+ _conn.getLock().wait(1000L);
+
+ }
+ _conn.getLock().notifyAll();
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+ }
+
+
+ public void close()
+ {
+ synchronized (_conn.getLock())
+ {
+ if(!_queue.offer(_endOfFrameMarker))
+ {
+ _setForClose = true;
+ }
+ _conn.getLock().notifyAll();
+ }
+ }
+
+ public AMQFrame<T> getNextFrame(final boolean wait)
+ {
+ synchronized(_conn.getLock())
+ {
+ try
+ {
+ AMQFrame frame = null;
+ while(!closed() && (frame = _queue.poll()) == null && wait)
+ {
+ _conn.getLock().wait();
+ }
+
+ if(frame == _endOfFrameMarker)
+ {
+ _closed = true;
+ frame = null;
+ }
+ else if(_setForClose && frame != null)
+ {
+ _setForClose = !_queue.offer(_endOfFrameMarker);
+ }
+
+
+ if(frame != null && FRAME_LOGGER.isLoggable(Level.FINE))
+ {
+ FRAME_LOGGER.fine("SEND[" + _conn.getRemoteAddress() + "|" + frame.getChannel() + "] : " + frame.getFrameBody());
+ }
+
+ _conn.getLock().notifyAll();
+
+ return frame;
+ }
+ catch (InterruptedException e)
+ {
+ _conn.setClosedForOutput(true);
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ return null;
+ }
+ }
+ }
+
+ public boolean closed()
+ {
+ return _closed;
+ }
+ }
+
+ public static interface FrameSource<T>
+ {
+ AMQFrame<T> getNextFrame(boolean wait);
+ boolean closed();
+ }
+
+
+ public static interface BytesSource
+ {
+ void getBytes(BytesProcessor processor, boolean wait);
+ boolean closed();
+ }
+
+ public static class FrameToBytesSourceAdapter implements BytesSource
+ {
+
+ private final FrameSource _frameSource;
+ private final FrameWriter _writer;
+ private static final int BUF_SIZE = 1<<16;
+ private final byte[] _bytes = new byte[BUF_SIZE];
+ private final ByteBuffer _buffer = ByteBuffer.wrap(_bytes);
+
+ public FrameToBytesSourceAdapter(final FrameSource frameSource, ValueWriter.Registry registry)
+ {
+ _frameSource = frameSource;
+ _writer = new FrameWriter(registry);
+ }
+
+ public void getBytes(final BytesProcessor processor, final boolean wait)
+ {
+
+ AMQFrame frame;
+
+ if(_buffer.position() == 0 && !_frameSource.closed())
+ {
+ if(!_writer.isComplete())
+ {
+ _writer.writeToBuffer(_buffer);
+ }
+
+ while(_buffer.hasRemaining())
+ {
+
+ if((frame = _frameSource.getNextFrame(wait && _buffer.position()==0)) != null)
+ {
+ _writer.setValue(frame);
+
+ try
+ {
+ _writer.writeToBuffer(_buffer);
+ }
+ catch(RuntimeException e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ catch(Error e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+
+
+ }
+ else
+ {
+ break;
+ }
+ }
+ _buffer.flip();
+ }
+ if(_buffer.limit() != 0)
+ {
+ processor.processBytes(_buffer);
+ if(_buffer.remaining() == 0)
+ {
+ _buffer.clear();
+ }
+ }
+ }
+
+ public boolean closed()
+ {
+ return _buffer.position() == 0 && _frameSource.closed();
+ }
+ }
+
+
+ public static class HeaderBytesSource implements BytesSource
+ {
+
+ private final ByteBuffer _buffer;
+ private ConnectionEndpoint _conn;
+
+ public HeaderBytesSource(ConnectionEndpoint conn, byte... headerBytes)
+ {
+ _conn = conn;
+ _buffer = ByteBuffer.wrap(headerBytes);
+ }
+
+ public void getBytes(final BytesProcessor processor, final boolean wait)
+ {
+ if(!_conn.closedForOutput())
+ {
+ processor.processBytes(_buffer);
+ }
+ }
+
+ public boolean closed()
+ {
+ return !_conn.closedForOutput() && !_buffer.hasRemaining();
+ }
+ }
+
+ public static class SequentialBytesSource implements BytesSource
+ {
+ private Queue<BytesSource> _sources = new LinkedList<BytesSource>();
+
+ public SequentialBytesSource(BytesSource... sources)
+ {
+ _sources.addAll(Arrays.asList(sources));
+ }
+
+ public synchronized void addSource(BytesSource source)
+ {
+ _sources.add(source);
+ }
+
+ public synchronized void getBytes(final BytesProcessor processor, final boolean wait)
+ {
+ BytesSource src = _sources.peek();
+ while (src != null && src.closed())
+ {
+ _sources.poll();
+ src = _sources.peek();
+ }
+
+ if(src != null)
+ {
+ src.getBytes(processor, wait);
+ }
+ }
+
+ public boolean closed()
+ {
+ return _sources.isEmpty();
+ }
+ }
+
+
+ public static class BytesOutputHandler implements Runnable, BytesProcessor
+ {
+
+ private final OutputStream _outputStream;
+ private BytesSource _bytesSource;
+ private boolean _closed;
+ private ConnectionEndpoint _conn;
+
+ public BytesOutputHandler(OutputStream outputStream, BytesSource source, ConnectionEndpoint conn)
+ {
+ _outputStream = outputStream;
+ _bytesSource = source;
+ _conn = conn;
+ }
+
+ public void run()
+ {
+
+ final BytesSource bytesSource = _bytesSource;
+
+ while(!(_closed || bytesSource.closed()))
+ {
+ _bytesSource.getBytes(this, true);
+ }
+
+ }
+
+ public void processBytes(final ByteBuffer buf)
+ {
+ try
+ {
+ if(RAW_LOGGER.isLoggable(Level.FINE))
+ {
+ Binary bin = new Binary(buf.array(),buf.arrayOffset()+buf.position(), buf.limit()-buf.position());
+ RAW_LOGGER.fine("SEND["+ _conn.getRemoteAddress() +"] : " + bin.toString());
+ }
+ _outputStream.write(buf.array(),buf.arrayOffset()+buf.position(), buf.limit()-buf.position());
+ buf.position(buf.limit());
+ }
+ catch (IOException e)
+ {
+ _closed = true;
+ e.printStackTrace(); //TODO
+ }
+ }
+ }
+
+
+ public static class OutputHandler implements Runnable
+ {
+
+
+
+ private final OutputStream _outputStream;
+ private FrameSource _frameSource;
+
+ private static final int BUF_SIZE = 1<<16;
+ private ValueWriter.Registry _registry;
+
+
+ public OutputHandler(OutputStream outputStream, FrameSource source, ValueWriter.Registry registry)
+ {
+ _outputStream = outputStream;
+ _frameSource = source;
+ _registry = registry;
+ }
+
+ public void run()
+ {
+ int i=0;
+
+
+ try
+ {
+
+ byte[] buffer = new byte[BUF_SIZE];
+ ByteBuffer buf = ByteBuffer.wrap(buffer);
+
+ buf.put((byte)'A');
+ buf.put((byte)'M');
+ buf.put((byte)'Q');
+ buf.put((byte)'P');
+ buf.put((byte) 0);
+ buf.put((byte) 1);
+ buf.put((byte) 0);
+ buf.put((byte) 0);
+
+
+
+ final FrameSource frameSource = _frameSource;
+
+ AMQFrame frame;
+ FrameWriter writer = new FrameWriter(_registry);
+
+ while(!frameSource.closed())
+ {
+
+ if(!writer.isComplete())
+ {
+ writer.writeToBuffer(buf);
+ }
+
+ while(buf.hasRemaining())
+ {
+
+ if((frame = frameSource.getNextFrame(buf.position()==0)) != null)
+ {
+ writer.setValue(frame);
+
+ int size = writer.writeToBuffer(buf);
+
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if(buf.limit() != 0)
+ {
+ _outputStream.write(buffer,0, buf.position());
+ buf.clear();
+ }
+ }
+
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ public static void main(String[] args) throws AmqpErrorException
+ {
+ byte[] buffer = new byte[76];
+ ByteBuffer buf = ByteBuffer.wrap(buffer);
+ AMQPDescribedTypeRegistry registry = AMQPDescribedTypeRegistry.newInstance()
+ .registerTransportLayer()
+ .registerMessagingLayer()
+ .registerTransactionLayer();
+
+ Open open = new Open();
+ // Open(container_id="venture", channel_max=10, hostname="foo", offered_capabilities=[Symbol("one"), Symbol("two"), Symbol("three")])
+ open.setContainerId("venture");
+ open.setChannelMax(UnsignedShort.valueOf((short) 10));
+ open.setHostname("foo");
+ open.setOfferedCapabilities(new Symbol[] {Symbol.valueOf("one"),Symbol.valueOf("two"),Symbol.valueOf("three")});
+
+ ValueWriter<Open> writer = registry.getValueWriter(open);
+
+ System.out.println("------ Encode (time in ms for 1 million opens)");
+ Long myLong = Long.valueOf(32);
+ ValueWriter<Long> writer2 = registry.getValueWriter(myLong);
+ Double myDouble = Double.valueOf(3.14159265359);
+ ValueWriter<Double> writer3 = registry.getValueWriter(myDouble);
+ for(int n = 0; n < 1/*00*/; n++)
+ {
+ long startTime = System.currentTimeMillis();
+ for(int i = 1/*000000*/; i !=0; i--)
+ {
+ buf.position(0);
+ writer.setValue(open);
+ writer.writeToBuffer(buf);
+ writer2.setValue(myLong);
+ writer.writeToBuffer(buf);
+ writer3.setValue(myDouble);
+ writer3.writeToBuffer(buf);
+
+
+ }
+ long midTime = System.currentTimeMillis();
+ System.out.println((midTime - startTime));
+
+ }
+
+
+ ValueHandler handler = new ValueHandler(registry);
+ System.out.println("------ Decode (time in ms for 1 million opens)");
+ for(int n = 0; n < 100; n++)
+ {
+ long startTime = System.currentTimeMillis();
+ for(int i = 1000000; i !=0; i--)
+ {
+ buf.flip();
+ handler.parse(buf);
+ handler.parse(buf);
+ handler.parse(buf);
+
+ }
+ long midTime = System.currentTimeMillis();
+ System.out.println((midTime - startTime));
+ }
+
+
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameHandler.java
new file mode 100644
index 0000000000..76a28d23e9
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameHandler.java
@@ -0,0 +1,329 @@
+/*
+ *
+ * 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.amqp_1_0.framing;
+
+import org.apache.qpid.amqp_1_0.codec.BinaryWriter;
+import org.apache.qpid.amqp_1_0.codec.ProtocolHandler;
+import org.apache.qpid.amqp_1_0.codec.ValueHandler;
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.ErrorCondition;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+import org.apache.qpid.amqp_1_0.type.transport.Transfer;
+
+import java.nio.ByteBuffer;
+import java.util.Formatter;
+
+public class FrameHandler implements ProtocolHandler
+{
+ private ConnectionEndpoint _connection;
+ private ValueHandler _typeHandler;
+
+ enum State {
+ SIZE_0,
+ SIZE_1,
+ SIZE_2,
+ SIZE_3,
+ PRE_PARSE,
+ BUFFERING,
+ PARSING,
+ ERROR
+ }
+
+ private State _state = State.SIZE_0;
+ private int _size;
+
+ private ByteBuffer _buffer;
+
+
+
+ public FrameHandler(final ConnectionEndpoint connection)
+ {
+ _connection = connection;
+ _typeHandler = new ValueHandler(connection.getDescribedTypeRegistry());
+
+ }
+
+ public ProtocolHandler parse(ByteBuffer in)
+ {
+ try
+ {
+ Error frameParsingError = null;
+ int size = _size;
+ State state = _state;
+ ByteBuffer oldIn = null;
+
+ while(in.hasRemaining() && state != State.ERROR)
+ {
+
+ final int remaining = in.remaining();
+ if(remaining == 0)
+ {
+ return this;
+ }
+
+
+ switch(state)
+ {
+ case SIZE_0:
+ if(remaining >= 4)
+ {
+ size = in.getInt();
+ state = State.PRE_PARSE;
+ break;
+ }
+ else
+ {
+ size = (in.get() << 24) & 0xFF000000;
+ if(!in.hasRemaining())
+ {
+ state = State.SIZE_1;
+ break;
+ }
+ }
+ case SIZE_1:
+ size |= (in.get() << 16) & 0xFF0000;
+ if(!in.hasRemaining())
+ {
+ state = State.SIZE_2;
+ break;
+ }
+ case SIZE_2:
+ size |= (in.get() << 8) & 0xFF00;
+ if(!in.hasRemaining())
+ {
+ state = State.SIZE_3;
+ break;
+ }
+ case SIZE_3:
+ size |= in.get() & 0xFF;
+ state = State.PRE_PARSE;
+
+ case PRE_PARSE:
+
+ if(size < 8)
+ {
+ frameParsingError = createFramingError("specified frame size %d smaller than minimum frame header size %d", _size, 8);
+ state = State.ERROR;
+ break;
+ }
+
+ else if(size > _connection.getMaxFrameSize())
+ {
+ frameParsingError = createFramingError("specified frame size %d larger than maximum frame header size %d", size, _connection.getMaxFrameSize());
+ state = State.ERROR;
+ break;
+ }
+
+ if(in.remaining() < size-4)
+ {
+ _buffer = ByteBuffer.allocate(size-4);
+ _buffer.put(in);
+ state = State.BUFFERING;
+ break;
+ }
+ case BUFFERING:
+ if(_buffer != null)
+ {
+ if(in.remaining() < _buffer.remaining())
+ {
+ _buffer.put(in);
+ break;
+ }
+ else
+ {
+ ByteBuffer dup = in.duplicate();
+ dup.limit(dup.position()+_buffer.remaining());
+ int i = _buffer.remaining();
+ int d = dup.remaining();
+ in.position(in.position()+_buffer.remaining());
+ _buffer.put(dup);
+ oldIn = in;
+ _buffer.flip();
+ in = _buffer;
+ state = State.PARSING;
+ }
+ }
+
+ case PARSING:
+
+ int dataOffset = (in.get() << 2) & 0x3FF;
+
+ if(dataOffset < 8)
+ {
+ frameParsingError = createFramingError("specified frame data offset %d smaller than minimum frame header size %d", dataOffset, 8);
+ state = State.ERROR;
+ break;
+ }
+ else if(dataOffset > size)
+ {
+ frameParsingError = createFramingError("specified frame data offset %d larger than the frame size %d", dataOffset, _size);
+ state = State.ERROR;
+ break;
+ }
+
+ // type
+
+ int type = in.get() & 0xFF;
+ int channel = in.getShort() & 0xFF;
+
+ if(type != 0 && type != 1)
+ {
+ frameParsingError = createFramingError("unknown frame type: %d", type);
+ state = State.ERROR;
+ break;
+ }
+
+ // channel
+
+ /*if(channel > _connection.getChannelMax())
+ {
+ frameParsingError = createError(AmqpError.DECODE_ERROR,
+ "frame received on invalid channel %d above channel-max %d",
+ channel, _connection.getChannelMax());
+
+ state = State.ERROR;
+ }
+*/
+ // ext header
+ if(dataOffset!=8)
+ {
+ in.position(in.position()+dataOffset-8);
+ }
+
+ // oldIn null iff not working on duplicated buffer
+ if(oldIn == null)
+ {
+ oldIn = in;
+ in = in.duplicate();
+ final int endPos = in.position() + size - dataOffset;
+ in.limit(endPos);
+ oldIn.position(endPos);
+
+ }
+
+ int inPos = in.position();
+ int inLimit = in.limit();
+ // PARSE HERE
+ try
+ {
+ Object val = _typeHandler.parse(in);
+
+ if(in.hasRemaining())
+ {
+ if(val instanceof Transfer)
+ {
+ ByteBuffer buf = ByteBuffer.allocate(in.remaining());
+ buf.put(in);
+ buf.flip();
+ ((Transfer)val).setPayload(buf);
+ }
+ }
+
+ _connection.receive((short)channel,val);
+ reset();
+ in = oldIn;
+ oldIn = null;
+ _buffer = null;
+ state = State.SIZE_0;
+ break;
+
+
+ }
+ catch (AmqpErrorException ex)
+ {
+ state = State.ERROR;
+ frameParsingError = ex.getError();
+ }
+ catch (RuntimeException e)
+ {
+ in.position(inPos);
+ in.limit(inLimit);
+ System.err.println(toHex(in));
+ throw e;
+ }
+ }
+
+ }
+
+ _state = state;
+ _size = size;
+
+ if(_state == State.ERROR)
+ {
+ _connection.handleError(frameParsingError);
+ }
+ return this;
+ }
+ catch(RuntimeException e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ private static String toHex(ByteBuffer in)
+ {
+ Formatter formatter = new Formatter();
+ int count = 0;
+ while(in.hasRemaining())
+ {
+ formatter.format("%02x ", in.get() & 0xFF);
+ if(count++ == 16)
+ {
+ formatter.format("\n");
+ count = 0;
+ }
+
+ }
+ return formatter.toString();
+ }
+
+ private Error createFramingError(String description, Object... args)
+ {
+ return createError(ConnectionError.FRAMING_ERROR, description, args);
+ }
+
+ private Error createError(final ErrorCondition framingError,
+ final String description,
+ final Object... args)
+ {
+ Error error = new Error();
+ error.setCondition(framingError);
+ Formatter formatter = new Formatter();
+ error.setDescription(formatter.format(description, args).toString());
+ return error;
+ }
+
+
+ private void reset()
+ {
+ _size = 0;
+ _state = State.SIZE_0;
+ }
+
+
+ public boolean isDone()
+ {
+ return _state == State.ERROR || _connection.closedForInput();
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameParsingError.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameParsingError.java
new file mode 100644
index 0000000000..e8bd462b87
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameParsingError.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.amqp_1_0.framing;
+
+public enum FrameParsingError
+{
+ UNDERSIZED_FRAME_HEADER,
+ OVERSIZED_FRAME_HEADER,
+ DATA_OFFSET_IN_HEADER,
+ DATA_OFFSET_TOO_LARGE,
+ UNKNOWN_FRAME_TYPE,
+ CHANNEL_ID_BEYOND_MAX,
+ SPARE_OCTETS_IN_FRAME_BODY,
+ INSUFFICIENT_OCTETS_IN_FRAME_BODY,
+ UNKNOWN_TYPE_CODE, UNPARSABLE_TYPE;
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameTypeHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameTypeHandler.java
new file mode 100644
index 0000000000..6d680c8b02
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/FrameTypeHandler.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.amqp_1_0.framing;
+
+import org.apache.qpid.amqp_1_0.codec.ProtocolHandler;
+
+public interface FrameTypeHandler extends ProtocolHandler
+{
+ void setExtHeaderRemaining(int size);
+
+ void setBodySize(int size);
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/OversizeFrameException.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/OversizeFrameException.java
new file mode 100644
index 0000000000..37897d9cb5
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/OversizeFrameException.java
@@ -0,0 +1,42 @@
+/*
+ * 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.amqp_1_0.framing;
+
+public class OversizeFrameException extends RuntimeException
+{
+ private final AMQFrame _frame;
+ private int _size;
+
+ public OversizeFrameException(final AMQFrame frame, final int size)
+ {
+ _frame = frame;
+ _size = size;
+ }
+
+ public AMQFrame getFrame()
+ {
+ return _frame;
+ }
+
+ public int getSize()
+ {
+ return _size;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLFrame.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLFrame.java
new file mode 100644
index 0000000000..4155b605c4
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLFrame.java
@@ -0,0 +1,42 @@
+/*
+ * 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.amqp_1_0.framing;
+
+import org.apache.qpid.amqp_1_0.type.SaslFrameBody;
+
+public final class SASLFrame extends AMQFrame<SaslFrameBody>
+{
+
+ public SASLFrame(SaslFrameBody frameBody)
+ {
+ super(frameBody);
+ }
+
+ @Override public short getChannel()
+ {
+ return (short)0;
+ }
+
+ @Override public byte getFrameType()
+ {
+ return (byte)1;
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLFrameHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLFrameHandler.java
new file mode 100644
index 0000000000..be7023bfdc
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLFrameHandler.java
@@ -0,0 +1,311 @@
+/*
+ * 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.amqp_1_0.framing;
+
+import org.apache.qpid.amqp_1_0.codec.ProtocolHandler;
+import org.apache.qpid.amqp_1_0.codec.ProtocolHeaderHandler;
+import org.apache.qpid.amqp_1_0.codec.ValueHandler;
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.ErrorCondition;
+import org.apache.qpid.amqp_1_0.type.transport.ConnectionError;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.nio.ByteBuffer;
+import java.util.Formatter;
+
+public class SASLFrameHandler implements ProtocolHandler
+{
+ private ConnectionEndpoint _connection;
+ private ValueHandler _typeHandler;
+
+ enum State {
+ SIZE_0,
+ SIZE_1,
+ SIZE_2,
+ SIZE_3,
+ PRE_PARSE,
+ BUFFERING,
+ PARSING,
+ ERROR
+ }
+
+ private State _state = State.SIZE_0;
+ private int _size;
+
+ private ByteBuffer _buffer;
+
+
+
+ public SASLFrameHandler(final ConnectionEndpoint connection)
+ {
+ _connection = connection;
+ _typeHandler = new ValueHandler(connection.getDescribedTypeRegistry());
+
+ }
+
+ public ProtocolHandler parse(ByteBuffer in)
+ {
+ try
+ {
+ Error frameParsingError = null;
+ int size = _size;
+ State state = _state;
+ ByteBuffer oldIn = null;
+
+ while(in.hasRemaining() && !_connection.isSASLComplete() && state != State.ERROR)
+ {
+
+ final int remaining = in.remaining();
+ if(remaining == 0)
+ {
+ return this;
+ }
+
+
+ switch(state)
+ {
+ case SIZE_0:
+ if(remaining >= 4)
+ {
+ size = in.getInt();
+ state = State.PRE_PARSE;
+ break;
+ }
+ else
+ {
+ size = (in.get() << 24) & 0xFF000000;
+ if(!in.hasRemaining())
+ {
+ state = State.SIZE_1;
+ break;
+ }
+ }
+ case SIZE_1:
+ size |= (in.get() << 16) & 0xFF0000;
+ if(!in.hasRemaining())
+ {
+ state = State.SIZE_2;
+ break;
+ }
+ case SIZE_2:
+ size |= (in.get() << 8) & 0xFF00;
+ if(!in.hasRemaining())
+ {
+ state = State.SIZE_3;
+ break;
+ }
+ case SIZE_3:
+ size |= in.get() & 0xFF;
+ state = State.PRE_PARSE;
+
+ case PRE_PARSE:
+
+ if(size < 8)
+ {
+ frameParsingError = createFramingError("specified frame size %d smaller than minimum frame header size %d", _size, 8);
+ state = State.ERROR;
+ break;
+ }
+
+ else if(size > _connection.getMaxFrameSize())
+ {
+ frameParsingError = createFramingError("specified frame size %d larger than maximum frame header size %d", size, _connection.getMaxFrameSize());
+ state = State.ERROR;
+ break;
+ }
+
+ if(in.remaining() < size-4)
+ {
+ _buffer = ByteBuffer.allocate(size-4);
+ _buffer.put(in);
+ state = State.BUFFERING;
+ break;
+ }
+ case BUFFERING:
+ if(_buffer != null)
+ {
+ if(in.remaining() < _buffer.remaining())
+ {
+ _buffer.put(in);
+ break;
+ }
+ else
+ {
+ ByteBuffer dup = in.duplicate();
+ dup.limit(dup.position()+_buffer.remaining());
+ int i = _buffer.remaining();
+ int d = dup.remaining();
+ in.position(in.position()+_buffer.remaining());
+ _buffer.put(dup);
+ oldIn = in;
+ _buffer.flip();
+ in = _buffer;
+ state = State.PARSING;
+ }
+ }
+
+ case PARSING:
+
+ int dataOffset = (in.get() << 2) & 0x3FF;
+
+ if(dataOffset < 8)
+ {
+ frameParsingError = createFramingError("specified frame data offset %d smaller than minimum frame header size %d", dataOffset, 8);
+ state = State.ERROR;
+ break;
+ }
+ else if(dataOffset > size)
+ {
+ frameParsingError = createFramingError("specified frame data offset %d larger than the frame size %d", dataOffset, _size);
+ state = State.ERROR;
+ break;
+ }
+
+ // type
+
+ int type = in.get() & 0xFF;
+ int channel = in.getShort() & 0xFF;
+
+ if(type != 0 && type != 1)
+ {
+ frameParsingError = createFramingError("unknown frame type: %d", type);
+ state = State.ERROR;
+ break;
+ }
+
+ if(type != 1)
+ {
+ System.err.println("Wrong frame type for SASL Frame");
+ }
+
+ // channel
+
+ /*if(channel > _connection.getChannelMax())
+ {
+ frameParsingError = createError(AmqpError.DECODE_ERROR,
+ "frame received on invalid channel %d above channel-max %d",
+ channel, _connection.getChannelMax());
+
+ state = State.ERROR;
+ }
+*/
+ // ext header
+ if(dataOffset!=8)
+ {
+ in.position(in.position()+dataOffset-8);
+ }
+
+ // oldIn null iff not working on duplicated buffer
+ if(oldIn == null)
+ {
+ oldIn = in;
+ in = in.duplicate();
+ final int endPos = in.position() + size - dataOffset;
+ in.limit(endPos);
+ oldIn.position(endPos);
+
+ }
+
+
+ // PARSE HERE
+ try
+ {
+ Object val = _typeHandler.parse(in);
+
+ if(in.hasRemaining())
+ {
+ state = State.ERROR;
+ frameParsingError = createFramingError("Frame length %d larger than contained frame body %s.", size, val);
+
+ }
+ else
+ {
+ _connection.receive((short)channel,val);
+ reset();
+ in = oldIn;
+ oldIn = null;
+ _buffer = null;
+ state = State.SIZE_0;
+ break;
+ }
+
+
+ }
+ catch (AmqpErrorException ex)
+ {
+ state = State.ERROR;
+ frameParsingError = ex.getError();
+ }
+ }
+
+ }
+
+ _state = state;
+ _size = size;
+
+ if(_state == State.ERROR)
+ {
+ _connection.handleError(frameParsingError);
+ }
+ if(_connection.isSASLComplete())
+ {
+ return new ProtocolHeaderHandler(_connection);
+ }
+ else
+ {
+ return this;
+ }
+ }
+ catch(RuntimeException e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ private Error createFramingError(String description, Object... args)
+ {
+ return createError(ConnectionError.FRAMING_ERROR, description, args);
+ }
+
+ private Error createError(final ErrorCondition framingError,
+ final String description,
+ final Object... args)
+ {
+ Error error = new Error();
+ error.setCondition(framingError);
+ Formatter formatter = new Formatter();
+ error.setDescription(formatter.format(description, args).toString());
+ return error;
+ }
+
+
+ private void reset()
+ {
+ _size = 0;
+ _state = State.SIZE_0;
+ }
+
+
+ public boolean isDone()
+ {
+ return _state == State.ERROR || _connection.closedForInput();
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLProtocolHeaderHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLProtocolHeaderHandler.java
new file mode 100644
index 0000000000..4ab90df92a
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/SASLProtocolHeaderHandler.java
@@ -0,0 +1,86 @@
+/*
+ * 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.amqp_1_0.framing;
+
+import org.apache.qpid.amqp_1_0.codec.ProtocolHandler;
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+import java.nio.ByteBuffer;
+
+public class SASLProtocolHeaderHandler implements ProtocolHandler
+{
+ private ConnectionEndpoint _connection;
+ private static final byte MAJOR_VERSION = (byte) 1;
+ private static final byte MINOR_VERSION = (byte) 0;
+
+ enum State {
+ AWAITING_MAJOR,
+ AWAITING_MINOR,
+ AWAITING_REVISION,
+ ERROR
+ }
+
+ private State _state = State.AWAITING_MAJOR;
+
+
+
+ public SASLProtocolHeaderHandler(final ConnectionEndpoint connection)
+ {
+ _connection = connection;
+ }
+
+ public ProtocolHandler parse(final ByteBuffer in)
+ {
+ while(in.hasRemaining() && _state != State.ERROR)
+ {
+ switch(_state)
+ {
+ case AWAITING_MAJOR:
+ _state = in.get() == MAJOR_VERSION ? State.AWAITING_MINOR : State.ERROR;
+ if(!in.hasRemaining())
+ {
+ break;
+ }
+ case AWAITING_MINOR:
+ _state = in.get() == MINOR_VERSION ? State.AWAITING_MINOR : State.ERROR;
+ if(!in.hasRemaining())
+ {
+ break;
+ }
+ case AWAITING_REVISION:
+ byte revision = in.get();
+ _connection.protocolHeaderReceived(MAJOR_VERSION, MINOR_VERSION, revision);
+ ProtocolHandler handler = new SASLFrameHandler(_connection);
+ return handler.parse(in);
+ }
+ }
+ if(_state == State.ERROR)
+ {
+ _connection.invalidHeaderReceived();
+ }
+ return this;
+
+ }
+
+ public boolean isDone()
+ {
+ return _state != State.ERROR && !_connection.closedForInput();
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/TransportFrame.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/TransportFrame.java
new file mode 100644
index 0000000000..b66d36ebeb
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/framing/TransportFrame.java
@@ -0,0 +1,51 @@
+/*
+ * 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.amqp_1_0.framing;
+
+import org.apache.qpid.amqp_1_0.type.FrameBody;
+
+import java.nio.ByteBuffer;
+
+public final class TransportFrame extends AMQFrame<FrameBody>
+{
+
+ private final short _channel;
+
+ TransportFrame(short channel, FrameBody frameBody)
+ {
+ super(frameBody);
+ _channel = channel;
+ }
+
+ public TransportFrame(short channel, FrameBody frameBody, ByteBuffer payload)
+ {
+ super(frameBody, payload);
+ _channel = channel;
+ }
+
+ @Override public short getChannel()
+ {
+ return _channel;
+ }
+
+ @Override public byte getFrameType()
+ {
+ return (byte)0;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/MessageAttributes.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/MessageAttributes.java
new file mode 100644
index 0000000000..7c1c62388d
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/MessageAttributes.java
@@ -0,0 +1,27 @@
+/*
+ * 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.amqp_1_0.messaging;
+
+import org.apache.qpid.amqp_1_0.type.Symbol;
+
+import java.util.Map;
+
+public interface MessageAttributes extends Map<Symbol, Object>
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionDecoder.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionDecoder.java
new file mode 100644
index 0000000000..f72d5848b6
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionDecoder.java
@@ -0,0 +1,35 @@
+/*
+ * 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.amqp_1_0.messaging;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.Section;
+
+import java.nio.ByteBuffer;
+import java.util.List;
+
+
+public interface SectionDecoder
+{
+
+ public List<Section> parseAll(ByteBuffer buf) throws AmqpErrorException;
+ public Section readSection(ByteBuffer buf) throws AmqpErrorException;
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionDecoderImpl.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionDecoderImpl.java
new file mode 100644
index 0000000000..ed2b0094f9
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionDecoderImpl.java
@@ -0,0 +1,62 @@
+/*
+ * 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.amqp_1_0.messaging;
+
+import org.apache.qpid.amqp_1_0.codec.ValueHandler;
+
+import org.apache.qpid.amqp_1_0.type.AmqpErrorException;
+import org.apache.qpid.amqp_1_0.type.Section;
+import org.apache.qpid.amqp_1_0.type.codec.AMQPDescribedTypeRegistry;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SectionDecoderImpl implements SectionDecoder
+{
+
+ private ValueHandler _valueHandler;
+
+
+ public SectionDecoderImpl(final AMQPDescribedTypeRegistry describedTypeRegistry)
+ {
+ _valueHandler = new ValueHandler(describedTypeRegistry);
+ }
+
+ public List<Section> parseAll(ByteBuffer buf) throws AmqpErrorException
+ {
+
+ List<Section> obj = new ArrayList<Section>();
+ while(buf.hasRemaining())
+ {
+ Section section = (Section) _valueHandler.parse(buf);
+ obj.add(section);
+ }
+
+ return obj;
+ }
+
+ public Section readSection(ByteBuffer buf) throws AmqpErrorException
+ {
+ return (Section) _valueHandler.parse(buf);
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionEncoder.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionEncoder.java
new file mode 100644
index 0000000000..bcb9112d14
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionEncoder.java
@@ -0,0 +1,34 @@
+/*
+ * 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.amqp_1_0.messaging;
+
+import org.apache.qpid.amqp_1_0.type.Binary;
+
+
+public interface SectionEncoder
+{
+ void reset();
+
+ Binary getEncoding();
+
+ void encodeObject(Object obj);
+
+ void encodeRaw(byte[] data);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionEncoderImpl.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionEncoderImpl.java
new file mode 100644
index 0000000000..9636dea4b7
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/messaging/SectionEncoderImpl.java
@@ -0,0 +1,111 @@
+/*
+ * 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.amqp_1_0.messaging;
+
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.Binary;
+import org.apache.qpid.amqp_1_0.type.codec.AMQPDescribedTypeRegistry;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SectionEncoderImpl implements SectionEncoder
+{
+ private static final ByteBuffer EMPTY_BYTE_BUFFER = ByteBuffer.wrap(new byte[0]);
+ private ValueWriter.Registry _registry;
+
+ private int _totalSize = 0;
+
+ private List<byte[]> _output = new ArrayList<byte[]>();
+ private static final int DEFAULT_BUFFER_SIZE = 64 * 1024;
+ private ByteBuffer _current;
+
+ public SectionEncoderImpl(final AMQPDescribedTypeRegistry describedTypeRegistry)
+ {
+ _registry = describedTypeRegistry;
+ reset();
+ }
+
+ public void reset()
+ {
+ _totalSize = 0;
+ _output.clear();
+ _current = null;
+
+ }
+
+ public Binary getEncoding()
+ {
+ byte[] data = new byte[_totalSize];
+ int offset = 0;
+ for(byte[] src : _output)
+ {
+ int length = src.length;
+ System.arraycopy(src, 0, data, offset, _totalSize - offset < length ? _totalSize - offset : length);
+ offset+= length;
+ }
+ return new Binary(data);
+ }
+
+ public void encodeObject(Object obj)
+ {
+ final ValueWriter<Object> valueWriter = _registry.getValueWriter(obj);
+ valueWriter.setValue(obj);
+ int size = valueWriter.writeToBuffer(EMPTY_BYTE_BUFFER);
+
+ byte[] data = new byte[size];
+ _current = ByteBuffer.wrap(data);
+ valueWriter.writeToBuffer(_current);
+ _output.add(data);
+
+
+ _totalSize += size;
+
+
+ }
+
+ public void encodeRaw(byte[] data)
+ {
+ if(_current == null)
+ {
+ byte[] buf = new byte[data.length];
+ _current = ByteBuffer.wrap(buf);
+ _output.add(buf);
+ }
+ int remaining = _current.remaining();
+ int length = data.length;
+
+ if(remaining < length)
+ {
+ _current.put(data,0,remaining);
+ byte[] dst = new byte[length-remaining];
+ _output.add(dst);
+ _current = ByteBuffer.wrap(dst).put(data,remaining,length-remaining);
+ }
+ else
+ {
+ _current.put(data);
+ }
+ _totalSize += data.length;
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/AMQPFrameTransport.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/AMQPFrameTransport.java
new file mode 100644
index 0000000000..7cb10b923f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/AMQPFrameTransport.java
@@ -0,0 +1,179 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+import org.apache.qpid.amqp_1_0.framing.AMQFrame;
+import org.apache.qpid.amqp_1_0.type.FrameBody;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+
+
+public class AMQPFrameTransport implements FrameTransport<AMQFrame<FrameBody>>, FrameOutputHandler<FrameBody>
+{
+ private final Object _inputLock = new Object();
+ private final Object _outputLock = new Object();
+
+ private volatile boolean _inputOpen = true;
+ private volatile boolean _outputOpen = true;
+
+ private final ConnectionEndpoint _endpoint;
+ private final BlockingQueue<AMQFrame<FrameBody>> _queue = new ArrayBlockingQueue<AMQFrame<FrameBody>>(100);
+ private StateChangeListener _inputListener;
+ private StateChangeListener _outputListener;
+
+
+ public AMQPFrameTransport(final ConnectionEndpoint endpoint)
+ {
+ _endpoint = endpoint;
+
+ _endpoint.setFrameOutputHandler(this);
+ }
+
+ public boolean isOpenForInput()
+ {
+ return _inputOpen;
+ }
+
+ public void closeForInput()
+ {
+ synchronized(_inputLock)
+ {
+ _inputOpen = false;
+ _inputLock.notifyAll();
+ }
+ }
+
+ public void processIncomingFrame(final AMQFrame<FrameBody> frame)
+ {
+ frame.getFrameBody().invoke(frame.getChannel(), _endpoint);
+ }
+
+
+ public boolean canSend()
+ {
+ return _queue.remainingCapacity() != 0;
+ }
+
+ public void send(AMQFrame<FrameBody> frame)
+ {
+ send(frame, null);
+ }
+
+
+ public void send(final AMQFrame<FrameBody> frame, final ByteBuffer payload)
+ {
+ synchronized(_endpoint.getLock())
+ {
+ boolean empty = _queue.isEmpty();
+ try
+ {
+
+ while(!_queue.offer(frame))
+ {
+ _endpoint.getLock().wait(1000L);
+
+ }
+ if(empty && _outputListener != null)
+ {
+ _outputListener.onStateChange(true);
+ }
+
+ _endpoint.getLock().notifyAll();
+ }
+ catch (InterruptedException e)
+ {
+
+ }
+ }
+ }
+
+ public void close()
+ {
+ synchronized (_endpoint.getLock())
+ {
+ _endpoint.getLock().notifyAll();
+ }
+ }
+
+ public AMQFrame<FrameBody> getNextFrame()
+ {
+ synchronized(_endpoint.getLock())
+ {
+ AMQFrame<FrameBody> frame = null;
+ if(isOpenForOutput())
+ {
+ frame = _queue.poll();
+ }
+ return frame;
+ }
+ }
+
+ public void closeForOutput()
+ {
+ synchronized (_outputLock)
+ {
+ _outputOpen = false;
+ _outputLock.notifyAll();
+ }
+ }
+
+ public boolean isOpenForOutput()
+ {
+ return _outputOpen;
+ }
+
+ public ValueWriter.Registry getRegistry()
+ {
+ return _endpoint.getDescribedTypeRegistry();
+ }
+
+ public void setInputStateChangeListener(final StateChangeListener listener)
+ {
+ _inputListener = listener;
+ }
+
+ public void setOutputStateChangeListener(final StateChangeListener listener)
+ {
+ _outputListener = listener;
+ }
+
+ public void setVersion(final byte major, final byte minor, final byte revision)
+ {
+
+ }
+
+ public byte getMajorVersion()
+ {
+ return _endpoint.getMajorVersion();
+ }
+
+ public byte getMinorVersion()
+ {
+ return _endpoint.getMinorVersion();
+ }
+
+ public byte getRevision()
+ {
+ return _endpoint.getRevision();
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/AMQPTransport.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/AMQPTransport.java
new file mode 100644
index 0000000000..8327cf6f26
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/AMQPTransport.java
@@ -0,0 +1,170 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.codec.FrameWriter;
+import org.apache.qpid.amqp_1_0.framing.AMQFrame;
+import org.apache.qpid.amqp_1_0.framing.TransportFrame;
+import org.apache.qpid.amqp_1_0.type.FrameBody;
+
+import java.nio.ByteBuffer;
+
+public class AMQPTransport implements BytesTransport
+{
+ private volatile boolean _inputOpen = true;
+ private volatile boolean _outputOpen = true;
+
+ private static final int INPUT_BUFFER_SIZE = 1 << 16;
+ private static final int OUTPUT_BUFFER_SIZE = 1 << 16;
+
+
+ private final CircularBytesBuffer _inputBuffer = new CircularBytesBuffer(INPUT_BUFFER_SIZE);
+ private TransportFrame _currentInputFrame;
+ private boolean _readingFrames;
+
+
+ private final CircularBytesBuffer _outputBuffer = new CircularBytesBuffer(OUTPUT_BUFFER_SIZE);
+
+ private AMQFrame<FrameBody> _currentOutputFrame;
+
+
+ private AMQPFrameTransport _frameTransport;
+
+ private FrameWriter _frameWriter;
+
+ private final BytesProcessor _frameWriterProcessor = new BytesProcessor()
+ {
+ public void processBytes(final ByteBuffer buf)
+ {
+ _frameWriter.writeToBuffer(buf);
+
+ if(_frameWriter.isComplete())
+ {
+ _currentOutputFrame = null;
+ }
+ }
+ };
+
+ private StateChangeListener _inputListener;
+ private StateChangeListener _outputListener;
+
+
+ public AMQPTransport(AMQPFrameTransport frameTransport)
+ {
+ _frameTransport = frameTransport;
+ _frameWriter = new FrameWriter(_frameTransport.getRegistry());
+ _outputBuffer.put( ByteBuffer.wrap( new byte[] { (byte) 'A',
+ (byte) 'M',
+ (byte) 'Q',
+ (byte) 'P',
+ (byte) 0,
+ _frameTransport.getMajorVersion(),
+ _frameTransport.getMajorVersion(),
+ _frameTransport.getRevision(),
+ } ) );
+
+
+ }
+
+ public boolean isOpenForInput()
+ {
+ return _inputOpen;
+ }
+
+ public void inputClosed()
+ {
+ _inputOpen = false;
+ }
+
+ public void processBytes(final ByteBuffer buf)
+ {
+ _inputBuffer.put(buf);
+
+ if(!_readingFrames)
+ {
+ if(_inputBuffer.size()>=8)
+ {
+ final byte[] incomingHeader = new byte[8];
+ _inputBuffer.get(new BytesProcessor()
+ {
+ public void processBytes(final ByteBuffer buf)
+ {
+ buf.get(incomingHeader);
+ }
+ });
+ _frameTransport.setVersion(incomingHeader[5], incomingHeader[6], incomingHeader[7]);
+ _readingFrames = true;
+ }
+ }
+ else
+ {
+
+ }
+
+
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setInputStateChangeListener(final StateChangeListener listener)
+ {
+ _inputListener = listener;
+ _frameTransport.setInputStateChangeListener(listener);
+ }
+
+ public void getNextBytes(final BytesProcessor processor)
+ {
+ // First try to fill the buffer as much as possible with frames
+ while(!_outputBuffer.isFull())
+ {
+ if(_currentOutputFrame == null)
+ {
+ _currentOutputFrame = _frameTransport.getNextFrame();
+ _frameWriter.setValue(_currentOutputFrame);
+ }
+
+ if(_currentOutputFrame == null)
+ {
+ break;
+ }
+
+
+ _outputBuffer.put(_frameWriterProcessor);
+
+
+
+ }
+
+ }
+
+ public void outputClosed()
+ {
+ _outputOpen = false;
+ }
+
+ public boolean isOpenForOutput()
+ {
+ return _outputOpen;
+ }
+
+ public void setOutputStateChangeListener(final StateChangeListener listener)
+ {
+ _outputListener = listener;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/BytesProcessor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/BytesProcessor.java
new file mode 100644
index 0000000000..d26eda302f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/BytesProcessor.java
@@ -0,0 +1,27 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import java.nio.ByteBuffer;
+
+public interface BytesProcessor
+{
+ void processBytes(ByteBuffer buf);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/BytesTransport.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/BytesTransport.java
new file mode 100644
index 0000000000..6932e7628b
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/BytesTransport.java
@@ -0,0 +1,38 @@
+/*
+ * 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.amqp_1_0.transport;
+
+
+import java.nio.ByteBuffer;
+
+public interface BytesTransport extends BytesProcessor
+{
+
+ boolean isOpenForInput();
+ void inputClosed();
+ void processBytes(ByteBuffer buf);
+ void setInputStateChangeListener(StateChangeListener listener);
+
+ void getNextBytes(BytesProcessor processor);
+ void outputClosed();
+ boolean isOpenForOutput();
+ void setOutputStateChangeListener(StateChangeListener listener);
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/CallbackHandlerSource.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/CallbackHandlerSource.java
new file mode 100644
index 0000000000..604279a21f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/CallbackHandlerSource.java
@@ -0,0 +1,28 @@
+/*
+ * 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.amqp_1_0.transport;
+
+
+import javax.security.auth.callback.CallbackHandler;
+
+public interface CallbackHandlerSource
+{
+ CallbackHandler getHandler(String mechanism);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/CircularBytesBuffer.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/CircularBytesBuffer.java
new file mode 100644
index 0000000000..e71eedd1e1
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/CircularBytesBuffer.java
@@ -0,0 +1,174 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import java.nio.ByteBuffer;
+
+public class CircularBytesBuffer
+{
+
+ private final byte[] _buffer;
+ private final int _mask;
+ private final ByteBuffer _inputBuffer;
+ private final ByteBuffer _outputBuffer;
+
+ private volatile int _start;
+ private volatile int _size;
+
+ public CircularBytesBuffer(int size)
+ {
+ size = calculateSize(size);
+ _buffer = new byte[size];
+ _mask = size - 1;
+ _inputBuffer = ByteBuffer.wrap(_buffer);
+ _outputBuffer = ByteBuffer.wrap(_buffer);
+
+ }
+
+
+ public int size()
+ {
+ return _size;
+ }
+
+ public boolean isFull()
+ {
+ return _size == _buffer.length;
+ }
+
+ public boolean isEmpty()
+ {
+ return _size == 0;
+ }
+
+ public void put(ByteBuffer buffer)
+ {
+ if(!isFull())
+ {
+ int start;
+ int size;
+
+ synchronized(this)
+ {
+ start = _start;
+ size = _size;
+ }
+
+ int pos = (start + size) & _mask;
+ int length = ((_buffer.length - pos) > size ? start : _buffer.length) - pos;
+ int remaining = length > buffer.remaining() ? buffer.remaining() : length;
+ buffer.get(_buffer, pos, remaining);
+
+ synchronized(this)
+ {
+ _size += remaining;
+ }
+
+ // We may still have space left if we have to wrap from the end to the start of the buffer
+ if(buffer.hasRemaining())
+ {
+ put(buffer);
+ }
+ }
+ }
+
+ public synchronized void put(BytesProcessor processor)
+ {
+ if(!isFull())
+ {
+ int start;
+ int size;
+
+ synchronized(this)
+ {
+ start = _start;
+ size = _size;
+ }
+ int pos = (start + size) & _mask;
+ int length = ((_buffer.length - pos) > size ? start : _buffer.length) - pos;
+ _outputBuffer.position(pos);
+ _outputBuffer.limit(pos+length);
+ processor.processBytes(_outputBuffer);
+
+ synchronized (this)
+ {
+ _size += length - _outputBuffer.remaining();
+ }
+
+ if(_outputBuffer.remaining() == 0)
+ {
+ put(processor);
+ }
+ }
+ }
+
+ public synchronized void get(BytesProcessor processor)
+ {
+ if(!isEmpty())
+ {
+ int start;
+ int size;
+
+ synchronized(this)
+ {
+ start = _start;
+ size = _size;
+ }
+
+
+ int length = start + size > _buffer.length ? _buffer.length - start : size;
+
+ _inputBuffer.position(start);
+ _inputBuffer.limit(start+length);
+ processor.processBytes(_inputBuffer);
+ final int consumed = length - _inputBuffer.remaining();
+
+ synchronized(this)
+ {
+ _start += consumed;
+ _size -= consumed;
+ }
+
+ if(!_inputBuffer.hasRemaining())
+ {
+ get(processor);
+ }
+ }
+ }
+
+ private int calculateSize(int size)
+ {
+ int n = 0;
+ int s = size;
+ do
+ {
+ s>>=1;
+ n++;
+ }
+ while(s > 0);
+
+ s = 1 << n;
+ if(s < size)
+ {
+ s<<= 1;
+ }
+ return s;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEndpoint.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEndpoint.java
new file mode 100644
index 0000000000..4ad8b4196e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEndpoint.java
@@ -0,0 +1,934 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+import org.apache.qpid.amqp_1_0.framing.AMQFrame;
+import org.apache.qpid.amqp_1_0.framing.SASLFrame;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.security.SaslChallenge;
+import org.apache.qpid.amqp_1_0.type.security.SaslCode;
+import org.apache.qpid.amqp_1_0.type.security.SaslInit;
+import org.apache.qpid.amqp_1_0.type.security.SaslMechanisms;
+import org.apache.qpid.amqp_1_0.type.security.SaslOutcome;
+import org.apache.qpid.amqp_1_0.type.security.SaslResponse;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+import org.apache.qpid.amqp_1_0.type.codec.AMQPDescribedTypeRegistry;
+
+
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+import javax.security.sasl.SaslServerFactory;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+public class ConnectionEndpoint implements DescribedTypeConstructorRegistry.Source, ValueWriter.Registry.Source,
+ ErrorHandler, SASLEndpoint
+
+{
+ private static final short CONNECTION_CONTROL_CHANNEL = (short) 0;
+ private static final ByteBuffer EMPTY_BYTE_BUFFER = ByteBuffer.wrap(new byte[0]);
+
+ private final Container _container;
+ private Principal _user;
+
+ private static final short DEFAULT_CHANNEL_MAX = 255;
+ private static final int DEFAULT_MAX_FRAME = Integer.getInteger("amqp.max_frame_size",1<<15);
+
+
+ private ConnectionState _state = ConnectionState.UNOPENED;
+ private short _channelMax;
+ private int _maxFrameSize = 4096;
+ private String _remoteContainerId;
+
+ private SocketAddress _remoteAddress;
+
+ // positioned by the *outgoing* channel
+ private SessionEndpoint[] _sendingSessions = new SessionEndpoint[DEFAULT_CHANNEL_MAX+1];
+
+ // positioned by the *incoming* channel
+ private SessionEndpoint[] _receivingSessions = new SessionEndpoint[DEFAULT_CHANNEL_MAX+1];
+ private boolean _closedForInput;
+ private boolean _closedForOutput;
+
+ private AMQPDescribedTypeRegistry _describedTypeRegistry = AMQPDescribedTypeRegistry.newInstance()
+ .registerTransportLayer()
+ .registerMessagingLayer()
+ .registerTransactionLayer()
+ .registerSecurityLayer();
+
+ private FrameOutputHandler<FrameBody> _frameOutputHandler;
+
+ private byte _majorVersion;
+ private byte _minorVersion;
+ private byte _revision;
+ private UnsignedInteger _handleMax = UnsignedInteger.MAX_VALUE;
+ private ConnectionEventListener _connectionEventListener = ConnectionEventListener.DEFAULT;
+ private String _password;
+ private final boolean _requiresSASLClient;
+ private final boolean _requiresSASLServer;
+
+
+ private FrameOutputHandler<SaslFrameBody> _saslFrameOutput;
+
+ private boolean _saslComplete;
+
+ private UnsignedInteger _desiredMaxFrameSize = UnsignedInteger.valueOf(DEFAULT_MAX_FRAME);
+ private Runnable _onSaslCompleteTask;
+
+ private CallbackHandlerSource _callbackHandlersource;
+ private SaslServer _saslServer;
+ private boolean _authenticated;
+ private String _remoteHostname;
+
+ public ConnectionEndpoint(Container container, CallbackHandlerSource cbs)
+ {
+ _container = container;
+ _callbackHandlersource = cbs;
+ _requiresSASLClient = false;
+ _requiresSASLServer = cbs != null;
+ }
+
+ public ConnectionEndpoint(Container container, Principal user, String password)
+ {
+ _container = container;
+ _user = user;
+ _password = password;
+ _requiresSASLClient = user != null;
+ _requiresSASLServer = false;
+ }
+
+
+ public synchronized void open()
+ {
+ if(_requiresSASLClient)
+ {
+ synchronized (getLock())
+ {
+ while(!_saslComplete)
+ {
+ try
+ {
+ getLock().wait();
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+ }
+ if(!_authenticated)
+ {
+ throw new RuntimeException("Could not connect - authentication error");
+ }
+ }
+ if(_state == ConnectionState.UNOPENED)
+ {
+ sendOpen(DEFAULT_CHANNEL_MAX, DEFAULT_MAX_FRAME);
+ _state = ConnectionState.AWAITING_OPEN;
+ }
+ }
+
+ public void setFrameOutputHandler(final FrameOutputHandler<FrameBody> frameOutputHandler)
+ {
+ _frameOutputHandler = frameOutputHandler;
+ }
+
+ public synchronized SessionEndpoint createSession(String name)
+ {
+ // todo assert connection state
+ SessionEndpoint endpoint = new SessionEndpoint(this);
+ short channel = getFirstFreeChannel();
+ if(channel != -1)
+ {
+ _sendingSessions[channel] = endpoint;
+ endpoint.setSendingChannel(channel);
+ Begin begin = new Begin();
+ begin.setNextOutgoingId(endpoint.getNextOutgoingId());
+ begin.setOutgoingWindow(endpoint.getOutgoingWindowSize());
+ begin.setIncomingWindow(endpoint.getIncomingWindowSize());
+
+ begin.setHandleMax(_handleMax);
+ send(channel, begin);
+
+ }
+ else
+ {
+ // todo error
+ }
+ return endpoint;
+ }
+
+
+ public Container getContainer()
+ {
+ return _container;
+ }
+
+ public Principal getUser()
+ {
+ return _user;
+ }
+
+ public short getChannelMax()
+ {
+ return _channelMax;
+ }
+
+ public int getMaxFrameSize()
+ {
+ return _maxFrameSize;
+ }
+
+ public String getRemoteContainerId()
+ {
+ return _remoteContainerId;
+ }
+
+ private void sendOpen(final short channelMax, final int maxFrameSize)
+ {
+ Open open = new Open();
+
+ open.setChannelMax(UnsignedShort.valueOf(DEFAULT_CHANNEL_MAX));
+ open.setContainerId(_container.getId());
+ open.setMaxFrameSize(getDesiredMaxFrameSize());
+ open.setHostname(getRemoteHostname());
+
+
+ send(CONNECTION_CONTROL_CHANNEL, open);
+ }
+
+ public UnsignedInteger getDesiredMaxFrameSize()
+ {
+ return _desiredMaxFrameSize;
+ }
+
+
+ public void setDesiredMaxFrameSize(UnsignedInteger size)
+ {
+ _desiredMaxFrameSize = size;
+ }
+
+
+
+
+ private void closeSender()
+ {
+ setClosedForOutput(true);
+ _frameOutputHandler.close();
+ }
+
+
+ short getFirstFreeChannel()
+ {
+ for(int i = 0; i<_sendingSessions.length;i++)
+ {
+ if(_sendingSessions[i]==null)
+ {
+ return (short) i;
+ }
+ }
+ return -1;
+ }
+
+ private SessionEndpoint getSession(final short channel)
+ {
+ // TODO assert existence, check channel state
+ return _receivingSessions[channel];
+ }
+
+
+ public synchronized void receiveOpen(short channel, Open open)
+ {
+
+ _channelMax = open.getChannelMax() == null ? DEFAULT_CHANNEL_MAX
+ : open.getChannelMax().shortValue() < DEFAULT_CHANNEL_MAX
+ ? DEFAULT_CHANNEL_MAX
+ : open.getChannelMax().shortValue();
+
+ UnsignedInteger remoteDesiredMaxFrameSize = open.getMaxFrameSize() == null ? UnsignedInteger.valueOf(DEFAULT_MAX_FRAME) : open.getMaxFrameSize();
+
+ _maxFrameSize = (remoteDesiredMaxFrameSize.compareTo(_desiredMaxFrameSize) < 0 ? remoteDesiredMaxFrameSize : _desiredMaxFrameSize).intValue();
+
+ _remoteContainerId = open.getContainerId();
+
+ switch(_state)
+ {
+ case UNOPENED:
+ sendOpen(_channelMax, _maxFrameSize);
+ case AWAITING_OPEN:
+ _state = ConnectionState.OPEN;
+ default:
+ // TODO bad stuff (connection already open)
+
+ }
+ /*if(_state == ConnectionState.AWAITING_OPEN)
+ {
+ _state = ConnectionState.OPEN;
+ }
+*/
+ }
+
+ public synchronized void receiveClose(short channel, Close close)
+ {
+ setClosedForInput(true);
+ _connectionEventListener.closeReceived();
+ switch(_state)
+ {
+ case UNOPENED:
+ case AWAITING_OPEN:
+ Error error = new Error();
+ error.setCondition(ConnectionError.CONNECTION_FORCED);
+ error.setDescription("Connection close sent before connection was opened");
+ connectionError(error);
+ break;
+ case OPEN:
+ sendClose(new Close());
+ break;
+ case CLOSE_SENT:
+ default:
+ }
+ }
+
+ protected synchronized void connectionError(Error error)
+ {
+ Close close = new Close();
+ close.setError(error);
+ switch(_state)
+ {
+ case UNOPENED:
+ _state = ConnectionState.CLOSED;
+ break;
+ case AWAITING_OPEN:
+ case OPEN:
+ sendClose(close);
+ _state = ConnectionState.CLOSE_SENT;
+ case CLOSE_SENT:
+ case CLOSED:
+ // already sent our close - too late to do anything more
+ break;
+ default:
+ // TODO Unknown state
+ }
+ }
+
+ public synchronized void inputClosed()
+ {
+ if(!_closedForInput)
+ {
+ _closedForInput = true;
+ for(int i = 0; i < _receivingSessions.length; i++)
+ {
+ if(_receivingSessions[i] != null)
+ {
+ _receivingSessions[i].end();
+ _receivingSessions[i]=null;
+
+ }
+ }
+ }
+ notifyAll();
+ }
+
+ private void sendClose(Close closeToSend)
+ {
+ send(CONNECTION_CONTROL_CHANNEL, closeToSend);
+ closeSender();
+ }
+
+ private synchronized void setClosedForInput(boolean closed)
+ {
+ _closedForInput = closed;
+
+ notifyAll();
+ }
+
+ public synchronized void receiveBegin(short channel, Begin begin)
+ {
+ short myChannelId;
+
+
+
+ if(begin.getRemoteChannel() != null)
+ {
+ myChannelId = begin.getRemoteChannel().shortValue();
+ SessionEndpoint endpoint;
+ try
+ {
+ endpoint = _sendingSessions[myChannelId];
+ }
+ catch(IndexOutOfBoundsException e)
+ {
+ final Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("BEGIN received on channel " + channel + " with given remote-channel "
+ + begin.getRemoteChannel() + " which is outside the valid range of 0 to "
+ + _channelMax + ".");
+ connectionError(error);
+ return;
+ }
+ if(endpoint != null)
+ {
+ if(_receivingSessions[channel] == null)
+ {
+ _receivingSessions[channel] = endpoint;
+ endpoint.setReceivingChannel(channel);
+ endpoint.setNextIncomingId(begin.getNextOutgoingId());
+ endpoint.setOutgoingSessionCredit(begin.getIncomingWindow());
+ }
+ else
+ {
+ final Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("BEGIN received on channel " + channel + " which is already in use.");
+ connectionError(error);
+ }
+ }
+ else
+ {
+ final Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("BEGIN received on channel " + channel + " with given remote-channel "
+ + begin.getRemoteChannel() + " which is not known as a begun session.");
+ connectionError(error);
+ }
+
+
+ }
+ else // Peer requesting session creation
+ {
+
+ myChannelId = getFirstFreeChannel();
+ if(myChannelId == -1)
+ {
+ // close any half open channel
+ myChannelId = getFirstFreeChannel();
+
+ }
+
+ if(_receivingSessions[channel] == null)
+ {
+ SessionEndpoint endpoint = new SessionEndpoint(this,begin);
+
+ _receivingSessions[channel] = endpoint;
+ _sendingSessions[myChannelId] = endpoint;
+
+ Begin beginToSend = new Begin();
+
+ endpoint.setReceivingChannel(channel);
+ endpoint.setSendingChannel(myChannelId);
+ beginToSend.setRemoteChannel(UnsignedShort.valueOf(channel));
+ beginToSend.setNextOutgoingId(endpoint.getNextOutgoingId());
+ beginToSend.setOutgoingWindow(endpoint.getOutgoingWindowSize());
+ beginToSend.setIncomingWindow(endpoint.getIncomingWindowSize());
+ send(myChannelId, beginToSend);
+
+ _connectionEventListener.remoteSessionCreation(endpoint);
+ }
+ else
+ {
+ final Error error = new Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("BEGIN received on channel " + channel + " which is already in use.");
+ connectionError(error);
+ }
+
+ }
+
+
+
+ }
+
+
+
+ public synchronized void receiveEnd(short channel, End end)
+ {
+ SessionEndpoint endpoint = _receivingSessions[channel];
+ if(endpoint != null)
+ {
+ _receivingSessions[channel] = null;
+
+ endpoint.end(end);
+ }
+ else
+ {
+ // TODO error
+ }
+
+ }
+
+
+ public synchronized void sendEnd(short channel, End end)
+ {
+ send(channel, end);
+ _sendingSessions[channel] = null;
+ }
+
+ public synchronized void receiveAttach(short channel, Attach attach)
+ {
+ SessionEndpoint endPoint = getSession(channel);
+ endPoint.receiveAttach(attach);
+ }
+
+
+ public synchronized void receiveDetach(short channel, Detach detach)
+ {
+ SessionEndpoint endPoint = getSession(channel);
+ endPoint.receiveDetach(detach);
+ }
+
+ public synchronized void receiveTransfer(short channel, Transfer transfer)
+ {
+ SessionEndpoint endPoint = getSession(channel);
+ endPoint.receiveTransfer(transfer);
+ }
+
+ public synchronized void receiveDisposition(short channel, Disposition disposition)
+ {
+ SessionEndpoint endPoint = getSession(channel);
+ endPoint.receiveDisposition(disposition);
+ }
+
+ public synchronized void receiveFlow(short channel, Flow flow)
+ {
+ SessionEndpoint endPoint = getSession(channel);
+ endPoint.receiveFlow(flow);
+ }
+
+
+ public synchronized void send(short channel, FrameBody body)
+ {
+ send(channel, body, null);
+ }
+
+
+ public synchronized int send(short channel, FrameBody body, ByteBuffer payload)
+ {
+ if(!_closedForOutput)
+ {
+ ValueWriter<FrameBody> writer = _describedTypeRegistry.getValueWriter(body);
+ int size = writer.writeToBuffer(EMPTY_BYTE_BUFFER);
+ ByteBuffer payloadDup = payload == null ? null : payload.duplicate();
+ int payloadSent = getMaxFrameSize() - (size + 9);
+ if(payloadSent < (payload == null ? 0 : payload.remaining()))
+ {
+
+ if(body instanceof Transfer)
+ {
+ ((Transfer)body).setMore(Boolean.TRUE);
+ }
+
+ writer = _describedTypeRegistry.getValueWriter(body);
+ size = writer.writeToBuffer(EMPTY_BYTE_BUFFER);
+ payloadSent = getMaxFrameSize() - (size + 9);
+
+ try
+ {
+ payloadDup.limit(payloadDup.position()+payloadSent);
+ }
+ catch(NullPointerException npe)
+ {
+ throw npe;
+ }
+ }
+ else
+ {
+ payloadSent = payload == null ? 0 : payload.remaining();
+ }
+ _frameOutputHandler.send(AMQFrame.createAMQFrame(channel, body, payloadDup));
+ return payloadSent;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+
+
+ public void invalidHeaderReceived()
+ {
+ // TODO
+ _closedForInput = true;
+ }
+
+ public synchronized boolean closedForInput()
+ {
+ return _closedForInput;
+ }
+
+ public synchronized void protocolHeaderReceived(final byte major, final byte minorVersion, final byte revision)
+ {
+ if(_requiresSASLServer && _state != ConnectionState.UNOPENED)
+ {
+ // TODO - bad stuff
+ }
+
+ _majorVersion = major;
+ _minorVersion = minorVersion;
+ _revision = revision;
+ }
+
+ public synchronized void handleError(final Error error)
+ {
+ if(!closedForOutput())
+ {
+ Close close = new Close();
+ close.setError(error);
+ send((short) 0, close);
+ }
+ _closedForInput = true;
+ }
+
+ private final Logger _logger = Logger.getLogger("FRM");
+
+ public synchronized void receive(final short channel, final Object frame)
+ {
+ if(_logger.isLoggable(Level.FINE))
+ {
+ _logger.fine("RECV["+ _remoteAddress + "|"+channel+"] : " + frame);
+ }
+ if(frame instanceof FrameBody)
+ {
+ ((FrameBody)frame).invoke(channel, this);
+ }
+ else if(frame instanceof SaslFrameBody)
+ {
+ ((SaslFrameBody)frame).invoke(this);
+ }
+ }
+
+ public AMQPDescribedTypeRegistry getDescribedTypeRegistry()
+ {
+ return _describedTypeRegistry;
+ }
+
+ public synchronized void setClosedForOutput(boolean b)
+ {
+ _closedForOutput = true;
+ notifyAll();
+ }
+
+ public synchronized boolean closedForOutput()
+ {
+ return _closedForOutput;
+ }
+
+
+ public Object getLock()
+ {
+ return this;
+ }
+
+ public synchronized void close()
+ {
+ switch(_state)
+ {
+ case AWAITING_OPEN:
+ case OPEN:
+ Close closeToSend = new Close();
+ sendClose(closeToSend);
+ _state = ConnectionState.CLOSE_SENT;
+ break;
+ case CLOSE_SENT:
+ default:
+ }
+
+ }
+
+ public void setConnectionEventListener(final ConnectionEventListener connectionEventListener)
+ {
+ _connectionEventListener = connectionEventListener;
+ }
+
+ public ConnectionEventListener getConnectionEventListener()
+ {
+ return _connectionEventListener;
+ }
+
+ public byte getMinorVersion()
+ {
+ return _minorVersion;
+ }
+
+ public byte getRevision()
+ {
+ return _revision;
+ }
+
+ public byte getMajorVersion()
+ {
+ return _majorVersion;
+ }
+
+ public void receiveSaslInit(final SaslInit saslInit)
+ {
+ Symbol mechanism = saslInit.getMechanism();
+ final Binary initialResponse = saslInit.getInitialResponse();
+ byte[] response = initialResponse == null ? new byte[0] : initialResponse.getArray();
+
+
+ try
+ {
+ _saslServer = Sasl.createSaslServer(mechanism.toString(),
+ "AMQP",
+ "localhost",
+ null,
+ _callbackHandlersource.getHandler(mechanism.toString()));
+
+ // Process response from the client
+ byte[] challenge = _saslServer.evaluateResponse(response != null ? response : new byte[0]);
+
+ if (_saslServer.isComplete())
+ {
+ SaslOutcome outcome = new SaslOutcome();
+
+ outcome.setCode(SaslCode.OK);
+ _saslFrameOutput.send(new SASLFrame(outcome), null);
+ synchronized (getLock())
+ {
+ _saslComplete = true;
+ _authenticated = true;
+ getLock().notifyAll();
+ }
+
+ if(_onSaslCompleteTask != null)
+ {
+ _onSaslCompleteTask.run();
+ }
+
+ }
+ else
+ {
+ SaslChallenge challengeBody = new SaslChallenge();
+ challengeBody.setChallenge(new Binary(challenge));
+ _saslFrameOutput.send(new SASLFrame(challengeBody), null);
+
+ }
+ }
+ catch (SaslException e)
+ {
+ SaslOutcome outcome = new SaslOutcome();
+
+ outcome.setCode(SaslCode.AUTH);
+ _saslFrameOutput.send(new SASLFrame(outcome), null);
+ synchronized (getLock())
+ {
+ _saslComplete = true;
+ _authenticated = false;
+ getLock().notifyAll();
+ }
+ if(_onSaslCompleteTask != null)
+ {
+ _onSaslCompleteTask.run();
+ }
+
+ }
+ }
+
+ public void receiveSaslMechanisms(final SaslMechanisms saslMechanisms)
+ {
+ if(Arrays.asList(saslMechanisms.getSaslServerMechanisms()).contains(Symbol.valueOf("PLAIN")))
+ {
+ SaslInit init = new SaslInit();
+ init.setMechanism(Symbol.valueOf("PLAIN"));
+ init.setHostname(_remoteHostname);
+ byte[] usernameBytes = _user.getName().getBytes(Charset.forName("UTF-8"));
+ byte[] passwordBytes = _password.getBytes(Charset.forName("UTF-8"));
+ byte[] initResponse = new byte[usernameBytes.length+passwordBytes.length+2];
+ System.arraycopy(usernameBytes,0,initResponse,1,usernameBytes.length);
+ System.arraycopy(passwordBytes,0,initResponse,usernameBytes.length+2,passwordBytes.length);
+ init.setInitialResponse(new Binary(initResponse));
+ _saslFrameOutput.send(new SASLFrame(init),null);
+ }
+ }
+
+ public void receiveSaslChallenge(final SaslChallenge saslChallenge)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void receiveSaslResponse(final SaslResponse saslResponse)
+ {
+ final Binary responseBinary = saslResponse.getResponse();
+ byte[] response = responseBinary == null ? new byte[0] : responseBinary.getArray();
+
+
+ try
+ {
+
+ // Process response from the client
+ byte[] challenge = _saslServer.evaluateResponse(response != null ? response : new byte[0]);
+
+ if (_saslServer.isComplete())
+ {
+ SaslOutcome outcome = new SaslOutcome();
+
+ outcome.setCode(SaslCode.OK);
+ _saslFrameOutput.send(new SASLFrame(outcome),null);
+ synchronized (getLock())
+ {
+ _saslComplete = true;
+ _authenticated = true;
+ getLock().notifyAll();
+ }
+ if(_onSaslCompleteTask != null)
+ {
+ _onSaslCompleteTask.run();
+ }
+
+ }
+ else
+ {
+ SaslChallenge challengeBody = new SaslChallenge();
+ challengeBody.setChallenge(new Binary(challenge));
+ _saslFrameOutput.send(new SASLFrame(challengeBody), null);
+
+ }
+ }
+ catch (SaslException e)
+ {
+ SaslOutcome outcome = new SaslOutcome();
+
+ outcome.setCode(SaslCode.AUTH);
+ _saslFrameOutput.send(new SASLFrame(outcome),null);
+ synchronized (getLock())
+ {
+ _saslComplete = true;
+ _authenticated = false;
+ getLock().notifyAll();
+ }
+ if(_onSaslCompleteTask != null)
+ {
+ _onSaslCompleteTask.run();
+ }
+
+ }
+ }
+
+ public void receiveSaslOutcome(final SaslOutcome saslOutcome)
+ {
+ if(saslOutcome.getCode() == SaslCode.OK)
+ {
+ _saslFrameOutput.close();
+ synchronized (getLock())
+ {
+ _saslComplete = true;
+ _authenticated = true;
+ getLock().notifyAll();
+ }
+ if(_onSaslCompleteTask != null)
+ {
+ _onSaslCompleteTask.run();
+ }
+ }
+ else
+ {
+ synchronized (getLock())
+ {
+ _saslComplete = true;
+ _authenticated = false;
+ getLock().notifyAll();
+ }
+ setClosedForInput(true);
+ _saslFrameOutput.close();
+ }
+ }
+
+ public boolean requiresSASL()
+ {
+ return _requiresSASLClient || _requiresSASLServer;
+ }
+
+ public void setSaslFrameOutput(final FrameOutputHandler<SaslFrameBody> saslFrameOutput)
+ {
+ _saslFrameOutput = saslFrameOutput;
+ }
+
+ public void setOnSaslComplete(Runnable task)
+ {
+ _onSaslCompleteTask = task;
+
+ }
+
+ public boolean isAuthenticated()
+ {
+ return _authenticated;
+ }
+
+ public void initiateSASL()
+ {
+ SaslMechanisms mechanisms = new SaslMechanisms();
+ final Enumeration<SaslServerFactory> saslServerFactories = Sasl.getSaslServerFactories();
+
+ SaslServerFactory f;
+ ArrayList<Symbol> mechanismsList = new ArrayList<Symbol>();
+ while(saslServerFactories.hasMoreElements())
+ {
+ f = saslServerFactories.nextElement();
+ final String[] mechanismNames = f.getMechanismNames(null);
+ for(String name : mechanismNames)
+ {
+ mechanismsList.add(Symbol.valueOf(name));
+ }
+
+ }
+ mechanisms.setSaslServerMechanisms(mechanismsList.toArray(new Symbol[mechanismsList.size()]));
+ _saslFrameOutput.send(new SASLFrame(mechanisms), null);
+ }
+
+ public boolean isSASLComplete()
+ {
+ return _saslComplete;
+ }
+
+ public SocketAddress getRemoteAddress()
+ {
+ return _remoteAddress;
+ }
+
+ public void setRemoteAddress(SocketAddress remoteAddress)
+ {
+ _remoteAddress = remoteAddress;
+ }
+
+ public String getRemoteHostname()
+ {
+ return _remoteHostname;
+ }
+
+ public void setRemoteHostname(final String remoteHostname)
+ {
+ _remoteHostname = remoteHostname;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEventListener.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEventListener.java
new file mode 100644
index 0000000000..17163598d2
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionEventListener.java
@@ -0,0 +1,43 @@
+/*
+ * 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.amqp_1_0.transport;
+
+public interface ConnectionEventListener
+{
+ class DefaultConnectionEventListener implements ConnectionEventListener
+ {
+ public void remoteSessionCreation(final SessionEndpoint endpoint)
+ {
+ endpoint.end();
+ }
+
+ public void closeReceived()
+ {
+
+ }
+ }
+
+ public static final ConnectionEventListener DEFAULT = new DefaultConnectionEventListener();
+
+ void remoteSessionCreation(SessionEndpoint endpoint);
+
+ public void closeReceived();
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionState.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionState.java
new file mode 100644
index 0000000000..a46526b58f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ConnectionState.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+public enum ConnectionState
+{
+ UNOPENED,
+ AWAITING_OPEN,
+ OPEN,
+ CLOSE_SENT,
+ CLOSED
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Container.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Container.java
new file mode 100644
index 0000000000..1fa5df4640
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Container.java
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+public class Container
+{
+
+ private String _id;
+
+ public Container()
+ {
+ String hostname;
+ try
+ {
+ InetAddress addr = InetAddress.getLocalHost();
+
+
+ // Get hostname
+ hostname = addr.getHostName();
+ }
+ catch (UnknownHostException e)
+ {
+ hostname="127.0.0.1";
+ }
+
+ String pid;
+ String hackForPid = ManagementFactory.getRuntimeMXBean().getName();
+ if(hackForPid != null && hackForPid.contains("@"))
+ {
+ pid = hackForPid.split("@")[0];
+ }
+ else
+ {
+ pid = "unknown";
+ }
+
+ _id = hostname + '(' + pid + ')';
+
+ }
+
+
+ public Container(String id)
+ {
+ _id = id;
+ }
+
+ public String getId()
+ {
+ return _id;
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Delivery.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Delivery.java
new file mode 100644
index 0000000000..4135199045
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Delivery.java
@@ -0,0 +1,95 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.Binary;
+import org.apache.qpid.amqp_1_0.type.UnsignedInteger;
+import org.apache.qpid.amqp_1_0.type.transport.Transfer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Delivery
+{
+ private boolean _complete;
+ private boolean _settled;
+ private final List<Transfer> _transfers = new ArrayList<Transfer>(1);
+ private final UnsignedInteger _deliveryId;
+ private final Binary _deliveryTag;
+ private final LinkEndpoint _linkEndpoint;
+
+ public Delivery(Transfer transfer, final LinkEndpoint endpoint)
+ {
+ _settled = Boolean.TRUE.equals(transfer.getSettled());
+ _deliveryId = transfer.getDeliveryId();
+ _deliveryTag = transfer.getDeliveryTag();
+ _linkEndpoint = endpoint;
+ addTransfer(transfer);
+ }
+
+ public boolean isComplete()
+ {
+ return _complete;
+ }
+
+ public void setComplete(final boolean complete)
+ {
+ _complete = complete;
+ }
+
+ public boolean isSettled()
+ {
+ return _settled;
+ }
+
+ public void setSettled(final boolean settled)
+ {
+ _settled = settled;
+ }
+
+ public void addTransfer(Transfer transfer)
+ {
+ _transfers.add(transfer);
+ if(Boolean.TRUE.equals(transfer.getAborted()) || !Boolean.TRUE.equals(transfer.getMore()))
+ {
+ setComplete(true);
+ }
+ }
+
+ public List<Transfer> getTransfers()
+ {
+ return _transfers;
+ }
+
+ public UnsignedInteger getDeliveryId()
+ {
+ return _deliveryId;
+ }
+
+ public LinkEndpoint getLinkEndpoint()
+ {
+ return _linkEndpoint;
+ }
+
+ public Binary getDeliveryTag()
+ {
+ return _deliveryTag;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/DeliveryStateHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/DeliveryStateHandler.java
new file mode 100644
index 0000000000..95a16d375f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/DeliveryStateHandler.java
@@ -0,0 +1,28 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.Binary;
+import org.apache.qpid.amqp_1_0.type.DeliveryState;
+
+public interface DeliveryStateHandler
+{
+ public void handle(final Binary deliveryTag, final DeliveryState state, final Boolean settled);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ErrorHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ErrorHandler.java
new file mode 100644
index 0000000000..e3bd37b225
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ErrorHandler.java
@@ -0,0 +1,9 @@
+package org.apache.qpid.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.transport.*;
+
+
+public interface ErrorHandler
+{
+ void handleError(org.apache.qpid.amqp_1_0.type.transport.Error error);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/FrameOutputHandler.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/FrameOutputHandler.java
new file mode 100644
index 0000000000..77933702ba
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/FrameOutputHandler.java
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.framing.AMQFrame;
+
+import java.nio.ByteBuffer;
+
+public interface FrameOutputHandler<T>
+{
+ boolean canSend();
+
+ void send(AMQFrame<T> frame);
+ void send(AMQFrame<T> frame, ByteBuffer payload);
+
+ void close();
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/FrameTransport.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/FrameTransport.java
new file mode 100644
index 0000000000..0f9cc8f5e8
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/FrameTransport.java
@@ -0,0 +1,37 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.framing.AMQFrame;
+
+public interface FrameTransport<T extends AMQFrame>
+{
+ boolean isOpenForInput();
+ void closeForInput();
+ void processIncomingFrame(T frame);
+
+ T getNextFrame();
+ void closeForOutput();
+ boolean isOpenForOutput();
+
+ void setInputStateChangeListener(StateChangeListener listener);
+ void setOutputStateChangeListener(StateChangeListener listener);
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java
new file mode 100644
index 0000000000..60c1427e10
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEndpoint.java
@@ -0,0 +1,542 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class LinkEndpoint<T extends LinkEventListener>
+{
+
+ private T _linkEventListener;
+ private DeliveryStateHandler _deliveryStateHandler;
+ private Object _flowTransactionId;
+ private SenderSettleMode _sendingSettlementMode;
+ private ReceiverSettleMode _receivingSettlementMode;
+ private Map _initialUnsettledMap;
+ private Map _localUnsettled;
+ private UnsignedInteger _lastSentCreditLimit;
+
+
+ private enum State
+ {
+ DETACHED,
+ ATTACH_SENT,
+ ATTACH_RECVD,
+ ATTACHED,
+ DETACH_SENT,
+ DETACH_RECVD
+ };
+
+ private final String _name;
+
+ private SessionEndpoint _session;
+
+
+ private volatile State _state = State.DETACHED;
+
+ private Source _source;
+ private Target _target;
+ private UnsignedInteger _deliveryCount;
+ private UnsignedInteger _linkCredit;
+ private UnsignedInteger _available;
+ private Boolean _drain;
+ private UnsignedInteger _localHandle;
+ private UnsignedLong _maxMessageSize;
+
+ private Map<Binary,Delivery> _unsettledTransfers = new HashMap<Binary,Delivery>();
+
+ LinkEndpoint(final SessionEndpoint sessionEndpoint, String name, Map<Binary, Outcome> unsettled)
+ {
+ _name = name;
+ _session = sessionEndpoint;
+ _linkCredit = UnsignedInteger.valueOf(0);
+ _drain = Boolean.FALSE;
+ _localUnsettled = unsettled;
+
+ }
+
+ LinkEndpoint(final SessionEndpoint sessionEndpoint,final Attach attach)
+ {
+ _session = sessionEndpoint;
+
+ _name = attach.getName();
+ _initialUnsettledMap = attach.getUnsettled();
+
+ _state = State.ATTACH_RECVD;
+ }
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public abstract Role getRole();
+
+ public Source getSource()
+ {
+ return _source;
+ }
+
+ public void setSource(final Source source)
+ {
+ _source = source;
+ }
+
+ public Target getTarget()
+ {
+ return _target;
+ }
+
+ public void setTarget(final Target target)
+ {
+ _target = target;
+ }
+
+ public void setDeliveryCount(final UnsignedInteger deliveryCount)
+ {
+ _deliveryCount = deliveryCount;
+ }
+
+ public void setLinkCredit(final UnsignedInteger linkCredit)
+ {
+ _linkCredit = linkCredit;
+ }
+
+ public void setAvailable(final UnsignedInteger available)
+ {
+ _available = available;
+ }
+
+ public void setDrain(final Boolean drain)
+ {
+ _drain = drain;
+ }
+
+ public UnsignedInteger getDeliveryCount()
+ {
+ return _deliveryCount;
+ }
+
+ public UnsignedInteger getAvailable()
+ {
+ return _available;
+ }
+
+ public Boolean getDrain()
+ {
+ return _drain;
+ }
+
+ public UnsignedInteger getLinkCredit()
+ {
+ return _linkCredit;
+ }
+
+ public void remoteDetached(Detach detach)
+ {
+ synchronized (getLock())
+ {
+ switch(_state)
+ {
+ case DETACH_SENT:
+ _state = State.DETACHED;
+ break;
+ case ATTACHED:
+ _state = State.DETACH_RECVD;
+ _linkEventListener.remoteDetached(this, detach);
+ break;
+ }
+ getLock().notifyAll();
+ }
+ }
+
+ public void receiveTransfer(final Transfer transfer, final Delivery delivery)
+ {
+ // TODO
+ }
+
+ public void settledByPeer(final Binary deliveryTag)
+ {
+ // TODO
+ }
+
+ public void receiveFlow(final Flow flow)
+ {
+ }
+
+ public void addUnsettled(final Delivery unsettled)
+ {
+ synchronized(getLock())
+ {
+ _unsettledTransfers.put(unsettled.getDeliveryTag(), unsettled);
+ getLock().notifyAll();
+ }
+ }
+
+ public void receiveDeliveryState(final Delivery unsettled,
+ final DeliveryState state,
+ final Boolean settled)
+ {
+ // TODO
+ synchronized(getLock())
+ {
+ if(_deliveryStateHandler != null)
+ {
+ _deliveryStateHandler.handle(unsettled.getDeliveryTag(), state, settled);
+ }
+
+ if(settled)
+ {
+ settle(unsettled.getDeliveryTag());
+ }
+
+ getLock().notifyAll();
+ }
+
+ }
+
+ public void settle(final Binary deliveryTag)
+ {
+ Delivery delivery = _unsettledTransfers.remove(deliveryTag);
+ if(delivery != null)
+ {
+ getSession().settle(getRole(),delivery.getDeliveryId());
+ }
+
+ }
+
+ public int getUnsettledCount()
+ {
+ synchronized(getLock())
+ {
+ return _unsettledTransfers.size();
+ }
+ }
+
+ public void setLocalHandle(final UnsignedInteger localHandle)
+ {
+ _localHandle = localHandle;
+ }
+
+ public void receiveAttach(final Attach attach)
+ {
+ synchronized(getLock())
+ {
+ switch(_state)
+ {
+ case ATTACH_SENT:
+ {
+
+ _state = State.ATTACHED;
+ getLock().notifyAll();
+
+ _initialUnsettledMap = attach.getUnsettled();
+ /* TODO - don't yet handle:
+
+ attach.getUnsettled();
+ attach.getProperties();
+ attach.getDurable();
+ attach.getExpiryPolicy();
+ attach.getTimeout();
+ */
+
+ break;
+ }
+
+ case DETACHED:
+ {
+ _state = State.ATTACHED;
+ getLock().notifyAll();
+ }
+
+
+ }
+
+ if(attach.getRole() == Role.SENDER)
+ {
+ _source = attach.getSource();
+ }
+ else
+ {
+ _target = attach.getTarget();
+ }
+
+ if(getRole() == Role.SENDER)
+ {
+ _maxMessageSize = attach.getMaxMessageSize();
+ }
+
+ }
+ }
+
+ public synchronized boolean isAttached()
+ {
+ return _state == State.ATTACHED;
+ }
+
+ public synchronized boolean isDetached()
+ {
+ return _state == State.DETACHED;
+ }
+
+ public SessionEndpoint getSession()
+ {
+ return _session;
+ }
+
+ public UnsignedInteger getLocalHandle()
+ {
+ return _localHandle;
+ }
+
+ public Object getLock()
+ {
+ return _session.getLock();
+ }
+
+ public void attach()
+ {
+ synchronized(getLock())
+ {
+ Attach attachToSend = new Attach();
+ attachToSend.setName(getName());
+ attachToSend.setRole(getRole());
+ attachToSend.setHandle(getLocalHandle());
+ attachToSend.setSource(getSource());
+ attachToSend.setTarget(getTarget());
+ attachToSend.setSndSettleMode(getSendingSettlementMode());
+ attachToSend.setRcvSettleMode(getReceivingSettlementMode());
+ attachToSend.setUnsettled(_localUnsettled);
+
+ if(getRole() == Role.SENDER)
+ {
+ attachToSend.setInitialDeliveryCount(_deliveryCount);
+ }
+
+ switch(_state)
+ {
+ case DETACHED:
+ _state = State.ATTACH_SENT;
+ break;
+ case ATTACH_RECVD:
+ _state = State.ATTACHED;
+ break;
+ default:
+ // TODO ERROR
+ }
+
+ getSession().sendAttach(attachToSend);
+
+ getLock().notifyAll();
+
+ }
+
+ }
+
+
+ public void detach()
+ {
+ detach(null, false);
+ }
+
+ public void close()
+ {
+ detach(null, true);
+ }
+
+ public void close(Error error)
+ {
+ detach(error, true);
+ }
+
+ public void detach(Error error)
+ {
+ detach(error, false);
+ }
+
+ private void detach(Error error, boolean close)
+ {
+ synchronized(getLock())
+ {
+ //TODO
+ switch(_state)
+ {
+ case ATTACHED:
+ _state = State.DETACH_SENT;
+ break;
+ case DETACH_RECVD:
+ _state = State.DETACHED;
+ break;
+ default:
+ return;
+ }
+
+ Detach detach = new Detach();
+ detach.setHandle(getLocalHandle());
+ if(close)
+ detach.setClosed(close);
+ detach.setError(error);
+
+ getSession().sendDetach(detach);
+
+ getLock().notifyAll();
+ }
+
+ }
+
+
+
+
+ public void setTransactionId(final Object txnId)
+ {
+ _flowTransactionId = txnId;
+ }
+
+ public void sendFlowConditional()
+ {
+ if(_lastSentCreditLimit != null)
+ {
+ UnsignedInteger clientsCredit = _lastSentCreditLimit.subtract(_deliveryCount);
+ int i = _linkCredit.subtract(clientsCredit).compareTo(clientsCredit);
+ if(i >=0)
+ {
+ sendFlow(_flowTransactionId != null);
+ }
+ else
+ {
+ getSession().sendFlowConditional();
+ }
+ }
+ else
+ {
+ sendFlow(_flowTransactionId != null);
+ }
+ }
+
+
+ public void sendFlow()
+ {
+ sendFlow(_flowTransactionId != null);
+ }
+
+ public void sendFlow(boolean setTransactionId)
+ {
+ if(_state == State.ATTACHED || _state == State.ATTACH_SENT)
+ {
+ Flow flow = new Flow();
+ flow.setLinkCredit(_linkCredit);
+ flow.setDeliveryCount(_deliveryCount);
+ _lastSentCreditLimit = _linkCredit.add(_deliveryCount);
+ flow.setAvailable(_available);
+ flow.setDrain(_drain);
+ if(setTransactionId)
+ {
+ flow.setProperties(Collections.singletonMap(Symbol.valueOf("txn-id"), _flowTransactionId));
+ }
+ flow.setHandle(getLocalHandle());
+ getSession().sendFlow(flow);
+ }
+ }
+
+ public T getLinkEventListener()
+ {
+ return _linkEventListener;
+ }
+
+ public void setLinkEventListener(final T linkEventListener)
+ {
+ synchronized(getLock())
+ {
+ _linkEventListener = linkEventListener;
+ }
+ }
+
+ public DeliveryStateHandler getDeliveryStateHandler()
+ {
+ return _deliveryStateHandler;
+ }
+
+ public void setDeliveryStateHandler(final DeliveryStateHandler deliveryStateHandler)
+ {
+ synchronized(getLock())
+ {
+ _deliveryStateHandler = deliveryStateHandler;
+ }
+ }
+
+ public void setSendingSettlementMode(SenderSettleMode sendingSettlementMode)
+ {
+ _sendingSettlementMode = sendingSettlementMode;
+ }
+
+ public SenderSettleMode getSendingSettlementMode()
+ {
+ return _sendingSettlementMode;
+ }
+
+ public ReceiverSettleMode getReceivingSettlementMode()
+ {
+ return _receivingSettlementMode;
+ }
+
+ public void setReceivingSettlementMode(ReceiverSettleMode receivingSettlementMode)
+ {
+ _receivingSettlementMode = receivingSettlementMode;
+ }
+
+ public Map getInitialUnsettledMap()
+ {
+ return _initialUnsettledMap;
+ }
+
+
+ public abstract void flowStateChanged();
+
+ public void setLocalUnsettled(Map unsettled)
+ {
+ _localUnsettled = unsettled;
+ }
+
+ @Override public String toString()
+ {
+ return "LinkEndpoint{" +
+ "_name='" + _name + '\'' +
+ ", _session=" + _session +
+ ", _state=" + _state +
+ ", _role=" + getRole() +
+ ", _source=" + _source +
+ ", _target=" + _target +
+ ", _transferCount=" + _deliveryCount +
+ ", _linkCredit=" + _linkCredit +
+ ", _available=" + _available +
+ ", _drain=" + _drain +
+ ", _localHandle=" + _localHandle +
+ ", _maxMessageSize=" + _maxMessageSize +
+ '}';
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEventListener.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEventListener.java
new file mode 100644
index 0000000000..c56a227e31
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/LinkEventListener.java
@@ -0,0 +1,31 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.transport.Detach;
+
+public interface LinkEventListener
+{
+
+
+ void remoteDetached(final LinkEndpoint endpoint, Detach detach);
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Node.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Node.java
new file mode 100644
index 0000000000..fb2270b51b
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/Node.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+public class Node
+{
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ProtocolHeaderTransport.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ProtocolHeaderTransport.java
new file mode 100644
index 0000000000..f9abbeb832
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ProtocolHeaderTransport.java
@@ -0,0 +1,134 @@
+/*
+ * 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.amqp_1_0.transport;
+
+
+import org.apache.qpid.amqp_1_0.type.Binary;
+
+import java.nio.ByteBuffer;
+import java.util.Map;
+
+public class ProtocolHeaderTransport implements BytesTransport
+{
+ private final Object _inputLock = new Object();
+ private final Object _outputLock = new Object();
+
+ private volatile boolean _inputOpen;
+ private volatile boolean _outputOpen;
+
+ private final Map<Binary,BytesTransport> _headersMap;
+
+ private BytesTransport _delegate;
+ private ByteBuffer _bytesToSend;
+
+ private byte[] _header = new byte[8];
+ private int _received;
+ private ByteBuffer _outputBuffer;
+
+ public ProtocolHeaderTransport(Map<Binary, BytesTransport> validHeaders)
+ {
+ _headersMap = validHeaders;
+
+ // if only one valid header then we can send, else we have to wait
+ }
+
+ public boolean isOpenForInput()
+ {
+ return _inputOpen;
+ }
+
+ public void inputClosed()
+ {
+ synchronized(_inputLock)
+ {
+ _inputOpen = false;
+ _inputLock.notifyAll();
+ }
+ }
+
+ public void processBytes(final ByteBuffer buf)
+ {
+ if(_delegate != null)
+ {
+ _delegate.processBytes(buf);
+ }
+ else
+ {
+
+ while( _received < 8 && buf.hasRemaining())
+ {
+ _header[_received++] = buf.get();
+ }
+ if(_received == 8)
+ {
+ Binary header = new Binary(_header);
+ _delegate = _headersMap.get(header);
+ if(_delegate != null)
+ {
+ _delegate.processBytes(ByteBuffer.wrap(_header));
+ _delegate.processBytes(buf);
+ }
+ else
+ {
+ inputClosed();
+ _outputBuffer = _headersMap.keySet().iterator().next().asByteBuffer();
+ }
+ }
+ }
+ }
+
+ public void setInputStateChangeListener(final StateChangeListener listener)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+
+ public void getNextBytes(final BytesProcessor processor)
+ {
+ if(_bytesToSend != null && _bytesToSend.hasRemaining())
+ {
+ processor.processBytes(_bytesToSend);
+ }
+ else if(_delegate != null)
+ {
+ _delegate.getNextBytes(processor);
+ }
+
+ }
+
+ public void outputClosed()
+ {
+ synchronized (_outputLock)
+ {
+ _outputOpen = false;
+ _outputLock.notifyAll();
+ }
+ }
+
+ public boolean isOpenForOutput()
+ {
+ return _outputOpen;
+ }
+
+ public void setOutputStateChangeListener(final StateChangeListener listener)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkEndpoint.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkEndpoint.java
new file mode 100644
index 0000000000..bd9244c858
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkEndpoint.java
@@ -0,0 +1,438 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transaction.TransactionalState;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+
+
+import java.util.*;
+
+public class ReceivingLinkEndpoint extends LinkEndpoint<ReceivingLinkListener>
+{
+
+
+ private static class TransientState
+ {
+
+ UnsignedInteger _deliveryId;
+ int _credit = 1;
+ boolean _settled;
+
+ private TransientState(final UnsignedInteger transferId)
+ {
+ _deliveryId = transferId;
+ }
+
+ void incrementCredit()
+ {
+ _credit++;
+ }
+
+ public int getCredit()
+ {
+ return _credit;
+ }
+
+ public UnsignedInteger getDeliveryId()
+ {
+ return _deliveryId;
+ }
+
+ public boolean isSettled()
+ {
+ return _settled;
+ }
+
+ public void setSettled(boolean settled)
+ {
+ _settled = settled;
+ }
+ }
+
+ private Map<Binary, Object> _unsettledMap = new LinkedHashMap<Binary, Object>();
+ private Map<Binary, TransientState> _unsettledIds = new LinkedHashMap<Binary, TransientState>();
+ private boolean _creditWindow;
+ private boolean _remoteDrain;
+ private UnsignedInteger _remoteTransferCount;
+ private UnsignedInteger _drainLimit;
+
+
+ public ReceivingLinkEndpoint(final SessionEndpoint session, String name)
+ {
+ this(session,name,null);
+ }
+
+ public ReceivingLinkEndpoint(final SessionEndpoint session, String name, Map<Binary, Outcome> unsettledMap)
+ {
+ super(session, name, unsettledMap);
+ setDeliveryCount(UnsignedInteger.valueOf(0));
+ setLinkEventListener(ReceivingLinkListener.DEFAULT);
+ }
+
+ public ReceivingLinkEndpoint(final SessionEndpoint session, final Attach attach)
+ {
+ super(session, attach);
+ setDeliveryCount(attach.getInitialDeliveryCount());
+ setLinkEventListener(ReceivingLinkListener.DEFAULT);
+ setSendingSettlementMode(attach.getSndSettleMode());
+ setReceivingSettlementMode(attach.getRcvSettleMode());
+ }
+
+
+ @Override public Role getRole()
+ {
+ return Role.RECEIVER;
+ }
+
+ @Override
+ public void receiveTransfer(final Transfer transfer, final Delivery delivery)
+ {
+ synchronized (getLock())
+ {
+ TransientState transientState;
+ boolean existingState = _unsettledMap.containsKey(transfer.getDeliveryTag());
+ _unsettledMap.put(transfer.getDeliveryTag(), transfer.getState());
+ if(!existingState)
+ {
+ transientState = new TransientState(transfer.getDeliveryId());
+ if(Boolean.TRUE.equals(transfer.getSettled()))
+ {
+ transientState.setSettled(true);
+ }
+ _unsettledIds.put(transfer.getDeliveryTag(), transientState);
+ setLinkCredit(getLinkCredit().subtract(UnsignedInteger.ONE));
+ setDeliveryCount(getDeliveryCount().add(UnsignedInteger.ONE));
+
+ }
+ else
+ {
+ transientState = _unsettledIds.get(transfer.getDeliveryTag());
+ transientState.incrementCredit();
+ if(Boolean.TRUE.equals(transfer.getSettled()))
+ {
+ transientState.setSettled(true);
+ }
+ }
+
+ if(transientState.isSettled())
+ {
+ _unsettledMap.remove(transfer.getDeliveryTag());
+ }
+ getLinkEventListener().messageTransfer(transfer);
+
+
+ getLock().notifyAll();
+ }
+ }
+
+ @Override public void receiveFlow(final Flow flow)
+ {
+ synchronized (getLock())
+ {
+ super.receiveFlow(flow);
+ _remoteDrain = Boolean.TRUE.equals((Boolean)flow.getDrain());
+ setAvailable(flow.getAvailable());
+ _remoteTransferCount = flow.getDeliveryCount();
+ getLock().notifyAll();
+ }
+ }
+
+
+ public boolean isDrained()
+ {
+ return getDrain() && getDeliveryCount().equals(getDrainLimit());
+ }
+
+ @Override
+ public void settledByPeer(final Binary deliveryTag)
+ {
+ synchronized (getLock())
+ {
+ // TODO XXX : need to do anything about the window here?
+ if(settled(deliveryTag) && _creditWindow)
+ {
+ sendFlowConditional();
+ }
+ }
+ }
+
+ public boolean settled(final Binary deliveryTag)
+ {
+ synchronized(getLock())
+ {
+ boolean deleted;
+ if(deleted = (_unsettledIds.remove(deliveryTag) != null))
+ {
+ _unsettledMap.remove(deliveryTag);
+
+ getLock().notifyAll();
+ }
+
+ return deleted;
+ }
+ }
+
+ public void updateDisposition(final Binary deliveryTag, DeliveryState state, boolean settled)
+ {
+ synchronized(getLock())
+ {
+ if(_unsettledMap.containsKey(deliveryTag))
+ {
+ boolean outcomeUpdate = false;
+ Outcome outcome=null;
+ if(state instanceof Outcome)
+ {
+ outcome = (Outcome)state;
+ }
+ else if(state instanceof TransactionalState)
+ {
+ // TODO? Is this correct
+ outcome = ((TransactionalState)state).getOutcome();
+ }
+
+ if(outcome != null)
+ {
+ Object oldOutcome = _unsettledMap.put(deliveryTag, outcome);
+ outcomeUpdate = !outcome.equals(oldOutcome);
+ }
+
+
+
+
+ TransientState transientState = _unsettledIds.get(deliveryTag);
+ if(outcomeUpdate || settled)
+ {
+
+ final UnsignedInteger transferId = transientState.getDeliveryId();
+
+ getSession().updateDisposition(getRole(), transferId, transferId, state, settled);
+ }
+
+
+ if(settled)
+ {
+
+ if(settled(deliveryTag))
+ {
+ if(!isDetached() && _creditWindow)
+ {
+ setLinkCredit(getLinkCredit().add(UnsignedInteger.ONE));
+ sendFlowConditional();
+ }
+ else
+ {
+ getSession().sendFlowConditional();
+ }
+ }
+ }
+ getLock().notifyAll();
+ }
+ else
+ {
+ TransientState transientState = _unsettledIds.get(deliveryTag);
+ if(_creditWindow)
+ {
+ setLinkCredit(getLinkCredit().add(UnsignedInteger.ONE));
+ sendFlowConditional();
+ }
+
+ }
+ }
+
+ }
+
+
+ public void setCreditWindow()
+ {
+ setCreditWindow(true);
+ }
+ public void setCreditWindow(boolean window)
+ {
+
+ _creditWindow = window;
+ sendFlowConditional();
+
+ }
+
+ public void drain()
+ {
+ synchronized (getLock())
+ {
+ setDrain(true);
+ _creditWindow = false;
+ _drainLimit = getDeliveryCount().add(getLinkCredit());
+ sendFlow();
+ getLock().notifyAll();
+ }
+ }
+
+ @Override
+ public void receiveDeliveryState(final Delivery unsettled, final DeliveryState state, final Boolean settled)
+ {
+ super.receiveDeliveryState(unsettled, state, settled);
+ if(_creditWindow)
+ {
+ if(Boolean.TRUE.equals(settled))
+ {
+ setLinkCredit(getLinkCredit().add(UnsignedInteger.ONE));
+ sendFlowConditional();
+ }
+ }
+ }
+
+ public void requestTransactionalSend(Object txnId)
+ {
+ synchronized (getLock())
+ {
+ setDrain(true);
+ _creditWindow = false;
+ setTransactionId(txnId);
+ sendFlow();
+ getLock().notifyAll();
+ }
+ }
+
+ private void sendFlow(final Object transactionId)
+ {
+ sendFlow();
+ }
+
+
+ public void clearDrain()
+ {
+ synchronized (getLock())
+ {
+ setDrain(false);
+ sendFlow();
+ getLock().notifyAll();
+ }
+ }
+
+ public void updateAllDisposition(Binary deliveryTag, DeliveryState deliveryState, boolean settled)
+ {
+ synchronized(getLock())
+ {
+ if(!_unsettledIds.isEmpty())
+ {
+ Binary firstTag = _unsettledIds.keySet().iterator().next();
+ Binary lastTag = deliveryTag;
+ updateDispositions(firstTag, lastTag, deliveryState, settled);
+ }
+ }
+ }
+
+ private void updateDispositions(Binary firstTag, Binary lastTag, DeliveryState state, boolean settled)
+ {
+ SortedMap<UnsignedInteger, UnsignedInteger> ranges = new TreeMap<UnsignedInteger,UnsignedInteger>();
+
+ synchronized(getLock())
+ {
+
+ Iterator<Binary> iter = _unsettledIds.keySet().iterator();
+ List<Binary> tagsToUpdate = new ArrayList<Binary>();
+ Binary tag = null;
+
+ while(iter.hasNext() && !(tag = iter.next()).equals(firstTag));
+
+ if(firstTag.equals(tag))
+ {
+ tagsToUpdate.add(tag);
+
+ UnsignedInteger deliveryId = _unsettledIds.get(firstTag).getDeliveryId();
+
+ UnsignedInteger first = deliveryId;
+ UnsignedInteger last = first;
+
+ while(iter.hasNext())
+ {
+ tag = iter.next();
+ tagsToUpdate.add(tag);
+
+ deliveryId = _unsettledIds.get(firstTag).getDeliveryId();
+
+ if(deliveryId.equals(last.add(UnsignedInteger.ONE)))
+ {
+ last = deliveryId;
+ }
+ else
+ {
+ ranges.put(first,last);
+ first = last = deliveryId;
+ }
+
+ if(tag.equals(lastTag))
+ {
+ break;
+ }
+ }
+
+ ranges.put(first,last);
+ }
+
+ if(settled)
+ {
+
+ for(Binary deliveryTag : tagsToUpdate)
+ {
+ if(settled(deliveryTag) && _creditWindow)
+ {
+ setLinkCredit(getLinkCredit().add(UnsignedInteger.valueOf(1)));
+ }
+ }
+ sendFlowConditional();
+ }
+
+
+
+ for(Map.Entry<UnsignedInteger,UnsignedInteger> range : ranges.entrySet())
+ {
+ getSession().updateDisposition(getRole(), range.getKey(), range.getValue(), state, settled);
+ }
+
+
+ getLock().notifyAll();
+ }
+
+ }
+
+ @Override
+ public void settle(Binary deliveryTag)
+ {
+ super.settle(deliveryTag);
+ if(_creditWindow)
+ {
+ sendFlowConditional();
+ }
+
+ }
+
+ public void flowStateChanged()
+ {
+ }
+
+ public UnsignedInteger getDrainLimit()
+ {
+ return _drainLimit;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkListener.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkListener.java
new file mode 100644
index 0000000000..c0464fbff6
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingLinkListener.java
@@ -0,0 +1,43 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.transport.*;
+
+public interface ReceivingLinkListener extends LinkEventListener
+{
+ void messageTransfer(Transfer xfr);
+
+ class DefaultLinkEventListener implements org.apache.qpid.amqp_1_0.transport.ReceivingLinkListener
+ {
+ public void messageTransfer(final Transfer xfr)
+ {
+
+ }
+
+ public void remoteDetached(final LinkEndpoint endpoint, final Detach detach)
+ {
+ endpoint.detach();
+ }
+ }
+
+ public static final org.apache.qpid.amqp_1_0.transport.ReceivingLinkListener DEFAULT = new DefaultLinkEventListener();
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingSessionHalfEndpoint.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingSessionHalfEndpoint.java
new file mode 100644
index 0000000000..d4b8e500d9
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/ReceivingSessionHalfEndpoint.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+public class ReceivingSessionHalfEndpoint extends SessionHalfEndpoint
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpoint.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpoint.java
new file mode 100644
index 0000000000..21c33d848d
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpoint.java
@@ -0,0 +1,39 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.security.SaslChallenge;
+import org.apache.qpid.amqp_1_0.type.security.SaslInit;
+import org.apache.qpid.amqp_1_0.type.security.SaslMechanisms;
+import org.apache.qpid.amqp_1_0.type.security.SaslOutcome;
+import org.apache.qpid.amqp_1_0.type.security.SaslResponse;
+
+public interface SASLEndpoint
+{
+ void receiveSaslInit(SaslInit saslInit);
+
+ void receiveSaslMechanisms(SaslMechanisms saslMechanisms);
+
+ void receiveSaslChallenge(SaslChallenge saslChallenge);
+
+ void receiveSaslResponse(SaslResponse saslResponse);
+
+ void receiveSaslOutcome(SaslOutcome saslOutcome);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpointImpl.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpointImpl.java
new file mode 100644
index 0000000000..b371b1217c
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLEndpointImpl.java
@@ -0,0 +1,291 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+import org.apache.qpid.amqp_1_0.type.Binary;
+import org.apache.qpid.amqp_1_0.type.SaslFrameBody;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.UnsignedInteger;
+import org.apache.qpid.amqp_1_0.type.codec.AMQPDescribedTypeRegistry;
+import org.apache.qpid.amqp_1_0.type.security.SaslChallenge;
+import org.apache.qpid.amqp_1_0.type.security.SaslInit;
+import org.apache.qpid.amqp_1_0.type.security.SaslMechanisms;
+import org.apache.qpid.amqp_1_0.type.security.SaslOutcome;
+import org.apache.qpid.amqp_1_0.type.security.SaslResponse;
+
+
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+import java.io.PrintWriter;
+import java.util.Arrays;
+
+
+public class SASLEndpointImpl
+ implements DescribedTypeConstructorRegistry.Source, ValueWriter.Registry.Source, SASLEndpoint
+{
+ private static final short SASL_CONTROL_CHANNEL = (short) 0;
+
+ private static final byte[] EMPTY_CHALLENGE = new byte[0];
+
+ private FrameTransport _transport;
+
+
+ private static enum State
+ {
+ BEGIN_SERVER,
+ BEGIN_CLIENT,
+ SENT_MECHANISMS,
+ SENT_INIT,
+ SENT_REPSONSE,
+ SENT_CHALLENGE,
+ SENT_OUTCOME
+ };
+
+
+ public PrintWriter _out;
+
+
+ private State _state;
+
+ private SaslClient _saslClient;
+ private SaslServer _saslServer;
+
+ private boolean _isReadable;
+ private boolean _isWritable;
+ private boolean _closedForInput;
+ private boolean _closedForOutput;
+
+ private AMQPDescribedTypeRegistry _describedTypeRegistry = AMQPDescribedTypeRegistry.newInstance().registerSecurityLayer();
+
+ private FrameOutputHandler _frameOutputHandler;
+
+ private byte _majorVersion;
+ private byte _minorVersion;
+ private byte _revision;
+ private UnsignedInteger _handleMax = UnsignedInteger.MAX_VALUE;
+ private ConnectionEventListener _connectionEventListener = ConnectionEventListener.DEFAULT;
+ private Symbol[] _mechanisms;
+ private Symbol _mechanism;
+
+
+ private SASLEndpointImpl(FrameTransport transport, State initialState, Symbol... mechanisms)
+ {
+ _transport = transport;
+ _state = initialState;
+ _mechanisms = mechanisms;
+ }
+
+
+ public void setFrameOutputHandler(final FrameOutputHandler frameOutputHandler)
+ {
+ _frameOutputHandler = frameOutputHandler;
+ if(_state == State.BEGIN_SERVER)
+ {
+ sendMechanisms();
+ }
+ }
+
+ private synchronized void sendMechanisms()
+ {
+ SaslMechanisms saslMechanisms = new SaslMechanisms();
+
+ saslMechanisms.setSaslServerMechanisms(_mechanisms);
+
+ _state = State.SENT_MECHANISMS;
+
+ send(saslMechanisms);
+ }
+
+ public boolean isReadable()
+ {
+ return _isReadable;
+ }
+
+ public boolean isWritable()
+ {
+ return _isWritable;
+ }
+
+
+ public synchronized void send(SaslFrameBody body)
+ {
+ if(!_closedForOutput)
+ {
+ if(_out != null)
+ {
+ _out.println("SEND : " + body);
+ _out.flush();
+ }
+ //_frameOutputHandler.send(new SASLFrame(body));
+ }
+ }
+
+
+
+ public void invalidHeaderReceived()
+ {
+ // TODO
+ _closedForInput = true;
+ }
+
+ public synchronized boolean closedForInput()
+ {
+ return _closedForInput;
+ }
+
+ public synchronized void protocolHeaderReceived(final byte major, final byte minorVersion, final byte revision)
+ {
+ _majorVersion = major;
+ _minorVersion = minorVersion;
+ _revision = revision;
+ }
+
+
+ public synchronized void receive(final short channel, final Object frame)
+ {
+ if(_out != null)
+ {
+ _out.println( "RECV["+channel+"] : " + frame);
+ _out.flush();
+ }
+ if(frame instanceof SaslFrameBody)
+ {
+ ((SaslFrameBody)frame).invoke(this);
+ }
+ else
+ {
+ // TODO
+ }
+ }
+
+ public AMQPDescribedTypeRegistry getDescribedTypeRegistry()
+ {
+ return _describedTypeRegistry;
+ }
+
+ public synchronized void setClosedForOutput(boolean b)
+ {
+ _closedForOutput = true;
+ notifyAll();
+ }
+
+ public synchronized boolean closedForOutput()
+ {
+ return _closedForOutput;
+ }
+
+
+ public Object getLock()
+ {
+ return this;
+ }
+
+
+ public byte getMajorVersion()
+ {
+ return _majorVersion;
+ }
+
+
+ public byte getMinorVersion()
+ {
+ return _minorVersion;
+ }
+
+ public byte getRevision()
+ {
+ return _revision;
+ }
+
+
+ public void receiveSaslInit(final SaslInit saslInit)
+ {
+ _mechanism = saslInit.getMechanism();
+ try
+ {
+ _saslServer = Sasl.createSaslServer(_mechanism.toString(), "AMQP", "localhost", null, createServerCallbackHandler(_mechanism));
+ }
+ catch (SaslException e)
+ {
+ e.printStackTrace(); //TODO
+ }
+ }
+
+ private CallbackHandler createServerCallbackHandler(final Symbol mechanism)
+ {
+ return null; //TODO
+ }
+
+ public synchronized void receiveSaslMechanisms(final SaslMechanisms saslMechanisms)
+ {
+ Symbol[] serverMechanisms = saslMechanisms.getSaslServerMechanisms();
+ for(Symbol mechanism : _mechanisms)
+ {
+ if(Arrays.asList(serverMechanisms).contains(mechanism))
+ {
+ _mechanism = mechanism;
+ break;
+ }
+ }
+ // TODO - no matching mechanism
+ try
+ {
+ _saslClient = Sasl.createSaslClient(new String[] { _mechanism.toString() }, null, "AMQP", "localhost", null,
+ createClientCallbackHandler(_mechanism));
+ SaslInit init = new SaslInit();
+ init.setMechanism(_mechanism);
+ init.setInitialResponse(_saslClient.hasInitialResponse() ? new Binary(_saslClient.evaluateChallenge(EMPTY_CHALLENGE)) : null);
+ send(init);
+ }
+ catch (SaslException e)
+ {
+ e.printStackTrace(); //TODO
+ }
+ }
+
+ private CallbackHandler createClientCallbackHandler(final Symbol mechanism)
+ {
+ return null; //TODO
+ }
+
+ public void receiveSaslChallenge(final SaslChallenge saslChallenge)
+ {
+ //TODO
+ }
+
+ public void receiveSaslResponse(final SaslResponse saslResponse)
+ {
+ //TODO
+ }
+
+
+ public void receiveSaslOutcome(final SaslOutcome saslOutcome)
+ {
+ //TODO
+ }
+
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLFrameTransport.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLFrameTransport.java
new file mode 100644
index 0000000000..8299cddfbe
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLFrameTransport.java
@@ -0,0 +1,78 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.framing.SASLFrame;
+
+public class SASLFrameTransport implements FrameTransport<SASLFrame>
+{
+ private final Object _inputLock = new Object();
+ private final Object _outputLock = new Object();
+
+ private volatile boolean _inputOpen;
+ private volatile boolean _outputOpen;
+
+ public boolean isOpenForInput()
+ {
+ return _inputOpen;
+ }
+
+ public void closeForInput()
+ {
+ synchronized(_inputLock)
+ {
+ _inputOpen = false;
+ _inputLock.notifyAll();
+ }
+ }
+ public void processIncomingFrame(final SASLFrame frame)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public SASLFrame getNextFrame()
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void closeForOutput()
+ {
+ synchronized (_outputLock)
+ {
+ _outputOpen = false;
+ _outputLock.notifyAll();
+ }
+ }
+
+ public boolean isOpenForOutput()
+ {
+ return _outputOpen;
+ }
+
+ public void setInputStateChangeListener(final StateChangeListener listener)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setOutputStateChangeListener(final StateChangeListener listener)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLTransport.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLTransport.java
new file mode 100644
index 0000000000..e140e3acd7
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SASLTransport.java
@@ -0,0 +1,85 @@
+/*
+ * 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.amqp_1_0.transport;
+
+
+import org.apache.qpid.amqp_1_0.type.codec.AMQPDescribedTypeRegistry;
+
+import java.nio.ByteBuffer;
+
+public class SASLTransport implements BytesTransport
+{
+ private final Object _inputLock = new Object();
+ private final Object _outputLock = new Object();
+
+ private volatile boolean _inputOpen;
+ private volatile boolean _outputOpen;
+
+ private AMQPDescribedTypeRegistry _describedTypeRegistry = AMQPDescribedTypeRegistry.newInstance()
+ .registerSecurityLayer();
+
+ public boolean isOpenForInput()
+ {
+ return _inputOpen;
+ }
+
+ public void inputClosed()
+ {
+ synchronized(_inputLock)
+ {
+ _inputOpen = false;
+ _inputLock.notifyAll();
+ }
+ }
+
+ public void processBytes(final ByteBuffer buf)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setInputStateChangeListener(final StateChangeListener listener)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void getNextBytes(final BytesProcessor processor)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void outputClosed()
+ {
+ synchronized (_outputLock)
+ {
+ _outputOpen = false;
+ _outputLock.notifyAll();
+ }
+ }
+
+ public boolean isOpenForOutput()
+ {
+ return _outputOpen;
+ }
+
+ public void setOutputStateChangeListener(final StateChangeListener listener)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkEndpoint.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkEndpoint.java
new file mode 100644
index 0000000000..a53b3661be
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkEndpoint.java
@@ -0,0 +1,214 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.Attach;
+import org.apache.qpid.amqp_1_0.type.transport.Flow;
+import org.apache.qpid.amqp_1_0.type.transport.Role;
+import org.apache.qpid.amqp_1_0.type.transport.Transfer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class SendingLinkEndpoint extends LinkEndpoint<SendingLinkListener>
+{
+
+ private UnsignedInteger _lastDeliveryId;
+ private Binary _lastDeliveryTag;
+ private Map<Binary, UnsignedInteger> _unsettledMap = new HashMap<Binary, UnsignedInteger>();
+ private Binary _transactionId;
+
+ public SendingLinkEndpoint(final SessionEndpoint sessionEndpoint, String name)
+ {
+ this(sessionEndpoint, name, null);
+ }
+
+ public SendingLinkEndpoint(final SessionEndpoint sessionEndpoint, String name, Map<Binary, Outcome> unsettled)
+ {
+ super(sessionEndpoint, name, unsettled);
+ init();
+ }
+
+ public SendingLinkEndpoint(final SessionEndpoint sessionEndpoint, final Attach attach)
+ {
+ super(sessionEndpoint, attach);
+ setSendingSettlementMode(attach.getSndSettleMode());
+ setReceivingSettlementMode(attach.getRcvSettleMode());
+ init();
+ }
+
+ private void init()
+ {
+ setDeliveryCount(UnsignedInteger.valueOf(0));
+ setAvailable(UnsignedInteger.valueOf(0));
+ setLinkEventListener(SendingLinkListener.DEFAULT);
+ }
+
+ @Override public Role getRole()
+ {
+ return Role.SENDER;
+ }
+
+ public boolean transfer(final Transfer xfr)
+ {
+ SessionEndpoint s = getSession();
+ int transferCount;
+ transferCount = _lastDeliveryTag == null ? 1 : 1;
+ xfr.setMessageFormat(UnsignedInteger.ZERO);
+ synchronized(getLock())
+ {
+
+ final int currentCredit = getLinkCredit().intValue() - transferCount;
+
+ if(currentCredit < 0)
+ {
+ return false;
+ }
+ else
+ {
+ setLinkCredit(UnsignedInteger.valueOf((int)currentCredit));
+ }
+
+ setDeliveryCount(UnsignedInteger.valueOf((getDeliveryCount().intValue() + transferCount)));
+
+ xfr.setHandle(getLocalHandle());
+
+ s.sendTransfer(xfr, this, !xfr.getDeliveryTag().equals(_lastDeliveryTag));
+
+ if(!Boolean.TRUE.equals(xfr.getSettled()))
+ {
+ _unsettledMap.put(xfr.getDeliveryTag(), xfr.getDeliveryId());
+ }
+ }
+
+ if(Boolean.TRUE.equals(xfr.getMore()))
+ {
+ _lastDeliveryTag = xfr.getDeliveryTag();
+ }
+ else
+ {
+ _lastDeliveryTag = null;
+ }
+
+ return true;
+ }
+
+
+ public void drained()
+ {
+ synchronized (getLock())
+ {
+ setDeliveryCount(getDeliveryCount().add(getLinkCredit()));
+ setLinkCredit(UnsignedInteger.ZERO);
+ sendFlow();
+ }
+ }
+
+ @Override
+ public void receiveFlow(final Flow flow)
+ {
+ super.receiveFlow(flow);
+ UnsignedInteger t = flow.getDeliveryCount();
+ UnsignedInteger c = flow.getLinkCredit();
+ setDrain(flow.getDrain());
+
+ Map options;
+ if((options = flow.getProperties()) != null)
+ {
+ _transactionId = (Binary) options.get(Symbol.valueOf("txn-id"));
+ }
+
+ if(t == null)
+ {
+ setLinkCredit(c);
+ }
+ else
+ {
+ UnsignedInteger limit = t.add(c);
+ if(limit.compareTo(getDeliveryCount())<=0)
+ {
+ setLinkCredit(UnsignedInteger.valueOf(0));
+ }
+ else
+ {
+ setLinkCredit(limit.subtract(getDeliveryCount()));
+ }
+ }
+ getLinkEventListener().flowStateChanged();
+
+ }
+
+ @Override
+ public void flowStateChanged()
+ {
+ getLinkEventListener().flowStateChanged();
+ }
+
+ public boolean hasCreditToSend()
+ {
+ UnsignedInteger linkCredit = getLinkCredit();
+ return linkCredit != null && (linkCredit.compareTo(UnsignedInteger.valueOf(0)) > 0)
+ && getSession().hasCreditToSend();
+ }
+
+ public void receiveDeliveryState(final Delivery unsettled,
+ final DeliveryState state,
+ final Boolean settled)
+ {
+ super.receiveDeliveryState(unsettled, state, settled);
+ if(settled)
+ {
+ _unsettledMap.remove(unsettled.getDeliveryTag());
+ }
+ }
+
+ public UnsignedInteger getLastDeliveryId()
+ {
+ return _lastDeliveryId;
+ }
+
+ public void setLastDeliveryId(final UnsignedInteger deliveryId)
+ {
+ _lastDeliveryId = deliveryId;
+ }
+
+ public void updateDisposition(final Binary deliveryTag, DeliveryState state, boolean settled)
+ {
+ synchronized(getLock())
+ {
+ UnsignedInteger deliveryId;
+ if(settled && (deliveryId = _unsettledMap.remove(deliveryTag))!=null)
+ {
+ settle(deliveryTag);
+ getSession().updateDisposition(getRole(), deliveryId, deliveryId, state, settled);
+ }
+
+ }
+ }
+
+ public Binary getTransactionId()
+ {
+ return _transactionId;
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkListener.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkListener.java
new file mode 100644
index 0000000000..09a99f1ba1
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingLinkListener.java
@@ -0,0 +1,43 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.transport.*;
+
+public interface SendingLinkListener extends LinkEventListener
+{
+ void flowStateChanged();
+
+ class DefaultLinkEventListener implements org.apache.qpid.amqp_1_0.transport.SendingLinkListener
+ {
+
+ public void remoteDetached(final LinkEndpoint endpoint, final org.apache.qpid.amqp_1_0.type.transport.Detach detach)
+ {
+ endpoint.detach();
+ }
+
+ public void flowStateChanged()
+ {
+
+ }
+ }
+
+ public static final org.apache.qpid.amqp_1_0.transport.SendingLinkListener DEFAULT = new DefaultLinkEventListener();
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingSessionHalfEndpoint.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingSessionHalfEndpoint.java
new file mode 100644
index 0000000000..2bc9a42dc5
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SendingSessionHalfEndpoint.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+public class SendingSessionHalfEndpoint extends SessionHalfEndpoint
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SequenceNumber.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SequenceNumber.java
new file mode 100644
index 0000000000..3f6490c2aa
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SequenceNumber.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.amqp_1_0.transport;
+
+public class SequenceNumber implements Comparable<SequenceNumber>, Cloneable
+{
+ private int _seqNo;
+
+ public SequenceNumber(int seqNo)
+ {
+ _seqNo = seqNo;
+ }
+
+ public SequenceNumber incr()
+ {
+ _seqNo++;
+ return this;
+ }
+
+ public SequenceNumber decr()
+ {
+ _seqNo--;
+ return this;
+ }
+
+ public static SequenceNumber add(SequenceNumber a, int i)
+ {
+ return a.clone().add(i);
+ }
+
+ public static SequenceNumber subtract(SequenceNumber a, int i)
+ {
+ return a.clone().add(-i);
+ }
+
+ private SequenceNumber add(int i)
+ {
+ _seqNo+=i;
+ return this;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ SequenceNumber that = (SequenceNumber) o;
+
+ if (_seqNo != that._seqNo)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return _seqNo;
+ }
+
+ public int compareTo(SequenceNumber o)
+ {
+ return _seqNo - o._seqNo;
+ }
+
+ @Override
+ public SequenceNumber clone()
+ {
+ return new SequenceNumber(_seqNo);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "SN{" + _seqNo + '}';
+ }
+
+ public int intValue()
+ {
+ return _seqNo;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionAttachment.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionAttachment.java
new file mode 100644
index 0000000000..6bb1e922e5
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionAttachment.java
@@ -0,0 +1,92 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+public class SessionAttachment
+{
+ private final SessionEndpoint _sessionEndpoint;
+ private final ConnectionEndpoint _connectionEndpoint;
+ private final short _channel;
+
+ public SessionAttachment(SessionEndpoint sessionEndpoint, ConnectionEndpoint connectionEndpoint, short channel)
+ {
+ _sessionEndpoint = sessionEndpoint;
+ _connectionEndpoint = connectionEndpoint;
+ _channel = channel;
+ }
+
+ public SessionEndpoint getSessionEndpoint()
+ {
+ return _sessionEndpoint;
+ }
+
+ public ConnectionEndpoint getConnectionEndpoint()
+ {
+ return _connectionEndpoint;
+ }
+
+ public short getChannel()
+ {
+ return _channel;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ SessionAttachment that = (SessionAttachment) o;
+
+ if (_channel != that._channel)
+ {
+ return false;
+ }
+ if (_connectionEndpoint != null
+ ? !_connectionEndpoint.equals(that._connectionEndpoint)
+ : that._connectionEndpoint != null)
+ {
+ return false;
+ }
+ if (_sessionEndpoint != null ? !_sessionEndpoint.equals(that._sessionEndpoint) : that._sessionEndpoint != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = _sessionEndpoint != null ? _sessionEndpoint.hashCode() : 0;
+ result = 31 * result + (_connectionEndpoint != null ? _connectionEndpoint.hashCode() : 0);
+ result = 31 * result + (int) _channel;
+ return result;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEndpoint.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEndpoint.java
new file mode 100644
index 0000000000..4b8bf82a4a
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEndpoint.java
@@ -0,0 +1,781 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.framing.OversizeFrameException;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Source;
+import org.apache.qpid.amqp_1_0.type.messaging.Target;
+import org.apache.qpid.amqp_1_0.type.messaging.TerminusDurability;
+import org.apache.qpid.amqp_1_0.type.messaging.TerminusExpiryPolicy;
+import org.apache.qpid.amqp_1_0.type.transaction.*;
+import org.apache.qpid.amqp_1_0.type.transaction.TxnCapability;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+
+import java.nio.ByteBuffer;
+import java.util.*;
+
+public class SessionEndpoint
+{
+ private SessionState _state = SessionState.INACTIVE;
+
+ private final Map<String, LinkEndpoint> _linkMap = new HashMap<String, LinkEndpoint>();
+ private final Map<LinkEndpoint, UnsignedInteger> _localLinkEndpoints = new HashMap<LinkEndpoint, UnsignedInteger>();
+ private final Map<UnsignedInteger, LinkEndpoint> _remoteLinkEndpoints = new HashMap<UnsignedInteger, LinkEndpoint>();
+
+ private long _timeout;
+
+
+ private ConnectionEndpoint _connection;
+ private long _lastAttachedTime;
+
+ private short _receivingChannel;
+ private short _sendingChannel;
+
+ private LinkedHashMap<UnsignedInteger,Delivery> _outgoingUnsettled;
+ private LinkedHashMap<UnsignedInteger,Delivery> _incomingUnsettled;
+
+ // has to be a power of two
+ private static final int DEFAULT_SESSION_BUFFER_SIZE = 1 << 11;
+ private static final int BUFFER_SIZE_MASK = DEFAULT_SESSION_BUFFER_SIZE - 1;
+
+ private SequenceNumber _nextIncomingTransferId;
+ private SequenceNumber _nextOutgoingTransferId;
+
+ private int _nextOutgoingDeliveryId;
+
+ //private SequenceNumber _incomingLWM;
+ //private SequenceNumber _outgoingLWM;
+
+ private UnsignedInteger _outgoingSessionCredit;
+
+
+
+ private UnsignedInteger _initialOutgoingId;
+
+ private SessionEventListener _sessionEventListener = SessionEventListener.DEFAULT;
+
+ private int _availableIncomingCredit;
+ private int _availableOutgoingCredit;
+ private UnsignedInteger _lastSentIncomingLimit;
+
+ public SessionEndpoint(final ConnectionEndpoint connectionEndpoint)
+ {
+ this(connectionEndpoint, UnsignedInteger.valueOf(0));
+ }
+
+ public SessionEndpoint(final ConnectionEndpoint connectionEndpoint, Begin begin)
+ {
+ this(connectionEndpoint, UnsignedInteger.valueOf(0));
+ _state = SessionState.BEGIN_RECVD;
+ _nextIncomingTransferId = new SequenceNumber(begin.getNextOutgoingId().intValue());
+ }
+
+
+ public SessionEndpoint(final ConnectionEndpoint connectionEndpoint, UnsignedInteger nextOutgoingId)
+ {
+ _connection = connectionEndpoint;
+
+ _initialOutgoingId = nextOutgoingId;
+ _nextOutgoingTransferId = new SequenceNumber(nextOutgoingId.intValue());
+
+ _outgoingUnsettled = new LinkedHashMap<UnsignedInteger,Delivery>(DEFAULT_SESSION_BUFFER_SIZE);
+ _incomingUnsettled = new LinkedHashMap<UnsignedInteger, Delivery>(DEFAULT_SESSION_BUFFER_SIZE);
+ _availableIncomingCredit = DEFAULT_SESSION_BUFFER_SIZE;
+ _availableOutgoingCredit = DEFAULT_SESSION_BUFFER_SIZE;
+ }
+
+
+ public void setReceivingChannel(final short receivingChannel)
+ {
+ _receivingChannel = receivingChannel;
+ switch(_state)
+ {
+ case INACTIVE:
+ _state = SessionState.BEGIN_RECVD;
+ break;
+ case BEGIN_SENT:
+ _state = SessionState.ACTIVE;
+ break;
+ default:
+ // TODO error
+
+ }
+ }
+
+
+ public void setSendingChannel(final short sendingChannel)
+ {
+ _sendingChannel = sendingChannel;
+ switch(_state)
+ {
+ case INACTIVE:
+ _state = SessionState.BEGIN_SENT;
+ break;
+ case BEGIN_RECVD:
+ _state = SessionState.ACTIVE;
+ break;
+ default:
+ // TODO error
+
+ }
+ }
+
+ public SessionState getState()
+ {
+ return _state;
+ }
+
+ public void end()
+ {
+ end(null);
+ }
+
+ public void end(final End end)
+ {
+ synchronized(getLock())
+ {
+ switch(_state)
+ {
+ case END_SENT:
+ _state = SessionState.ENDED;
+ break;
+ case ACTIVE:
+ detachLinks();
+ _sessionEventListener.remoteEnd(end);
+ short sendChannel = getSendingChannel();
+ _connection.sendEnd(sendChannel, new End());
+ _state = end == null ? SessionState.END_SENT : SessionState.ENDED;
+ break;
+ default:
+ sendChannel = getSendingChannel();
+ End reply = new End();
+ Error error = new Error();
+ error.setCondition(AmqpError.ILLEGAL_STATE);
+ error.setDescription("END called on Session which has not been opened");
+ reply.setError(error);
+ _connection.sendEnd(sendChannel, reply);
+ break;
+
+
+ }
+ getLock().notifyAll();
+ }
+ }
+
+ private void detachLinks()
+ {
+ Collection<UnsignedInteger> handles = new ArrayList<UnsignedInteger>(_remoteLinkEndpoints.keySet());
+ for(UnsignedInteger handle : handles)
+ {
+ detach(handle, null);
+ }
+ }
+
+ public short getSendingChannel()
+ {
+ return _sendingChannel;
+ }
+
+
+ public void receiveAttach(final Attach attach)
+ {
+ if(_state == SessionState.ACTIVE)
+ {
+ UnsignedInteger handle = attach.getHandle();
+ if(_remoteLinkEndpoints.containsKey(handle))
+ {
+ // TODO - Error - handle busy?
+ }
+ else
+ {
+ LinkEndpoint endpoint = getLinkMap().get(attach.getName());
+ if(endpoint == null)
+ {
+ endpoint = attach.getRole() == Role.RECEIVER
+ ? new SendingLinkEndpoint(this, attach)
+ : new ReceivingLinkEndpoint(this, attach);
+
+ // TODO : fix below - distinguish between local and remote owned
+ endpoint.setSource(attach.getSource());
+ endpoint.setTarget(attach.getTarget());
+
+
+ }
+
+ if(attach.getRole() == Role.SENDER)
+ {
+ endpoint.setDeliveryCount(attach.getInitialDeliveryCount());
+ }
+
+ _remoteLinkEndpoints.put(handle, endpoint);
+
+ if(!_localLinkEndpoints.containsKey(endpoint))
+ {
+ UnsignedInteger localHandle = findNextAvailableHandle();
+ endpoint.setLocalHandle(localHandle);
+ _localLinkEndpoints.put(endpoint, localHandle);
+
+ _sessionEventListener.remoteLinkCreation(endpoint);
+
+
+ }
+ else
+ {
+ endpoint.receiveAttach(attach);
+ }
+ }
+ }
+ }
+
+ private void send(final FrameBody frameBody)
+ {
+ _connection.send(this.getSendingChannel(), frameBody);
+ }
+
+
+ private int send(final FrameBody frameBody, ByteBuffer payload)
+ {
+ return _connection.send(this.getSendingChannel(), frameBody, payload);
+ }
+
+ private UnsignedInteger findNextAvailableHandle()
+ {
+ int i = 0;
+ do
+ {
+ if(!_localLinkEndpoints.containsValue(UnsignedInteger.valueOf(i)))
+ {
+ return UnsignedInteger.valueOf(i);
+ }
+ } while(++i != 0);
+
+ // TODO
+ throw new RuntimeException();
+ }
+
+ public void receiveDetach(final Detach detach)
+ {
+ UnsignedInteger handle = detach.getHandle();
+ detach(handle, detach);
+ }
+
+ private void detach(UnsignedInteger handle, Detach detach)
+ {
+ if(_remoteLinkEndpoints.containsKey(handle))
+ {
+ LinkEndpoint endpoint = _remoteLinkEndpoints.remove(handle);
+
+ endpoint.remoteDetached(detach);
+
+ _localLinkEndpoints.remove(endpoint);
+
+
+ }
+ else
+ {
+ // TODO
+ }
+ }
+
+ public void receiveTransfer(final Transfer transfer)
+ {
+ synchronized(getLock())
+ {
+ _nextIncomingTransferId.incr();
+/*
+ _availableIncomingCredit--;
+*/
+
+ UnsignedInteger handle = transfer.getHandle();
+
+
+
+ LinkEndpoint endpoint = _remoteLinkEndpoints.get(handle);
+
+ if(endpoint == null)
+ {
+ //TODO - error unknown link
+ System.err.println("Unknown endpoint " + transfer);
+
+ }
+
+ Delivery delivery = _incomingUnsettled.get(transfer.getDeliveryId());
+ if(delivery == null)
+ {
+ delivery = new Delivery(transfer, endpoint);
+ _incomingUnsettled.put(transfer.getDeliveryId(),delivery);
+ if(delivery.isSettled() || Boolean.TRUE.equals(transfer.getAborted()))
+ {
+/*
+ _availableIncomingCredit++;
+*/
+ }
+ }
+ else
+ {
+ if(delivery.getDeliveryId().equals(transfer.getDeliveryId()))
+ {
+ delivery.addTransfer(transfer);
+ if(delivery.isSettled())
+ {
+/*
+ _availableIncomingCredit++;
+*/
+ }
+ else if(Boolean.TRUE.equals(transfer.getAborted()))
+ {
+/*
+ _availableIncomingCredit += delivery.getTransfers().size();
+*/
+ }
+ }
+ else
+ {
+ // TODO - error
+ System.err.println("Incorrect transfer id " + transfer);
+ }
+ }
+
+ if(endpoint != null)
+ {
+ endpoint.receiveTransfer(transfer, delivery);
+ }
+
+ if((delivery.isComplete() && delivery.isSettled() || Boolean.TRUE.equals(transfer.getAborted())))
+ {
+ _incomingUnsettled.remove(transfer.getDeliveryId());
+ }
+ }
+ }
+
+ public void receiveFlow(final Flow flow)
+ {
+
+ synchronized(getLock())
+ {
+ UnsignedInteger handle = flow.getHandle();
+ LinkEndpoint endpoint = handle == null ? null : _remoteLinkEndpoints.get(handle);
+
+ final UnsignedInteger nextOutgoingId = flow.getNextIncomingId() == null ? _initialOutgoingId : flow.getNextIncomingId();
+ int limit = (nextOutgoingId.intValue() + flow.getIncomingWindow().intValue());
+ _outgoingSessionCredit = UnsignedInteger.valueOf(limit - _nextOutgoingTransferId.intValue());
+
+ if(endpoint != null)
+ {
+ endpoint.receiveFlow( flow );
+ }
+ else
+ {
+ for(LinkEndpoint le : _remoteLinkEndpoints.values())
+ {
+ le.flowStateChanged();
+ }
+ }
+
+ getLock().notifyAll();
+ }
+
+
+ }
+
+ public void receiveDisposition(final Disposition disposition)
+ {
+ Role dispositionRole = disposition.getRole();
+
+ LinkedHashMap<UnsignedInteger, Delivery> unsettledTransfers;
+
+ if(dispositionRole == Role.RECEIVER)
+ {
+ unsettledTransfers = _outgoingUnsettled;
+ }
+ else
+ {
+ unsettledTransfers = _incomingUnsettled;
+
+ }
+
+ UnsignedInteger deliveryId = disposition.getFirst();
+ UnsignedInteger last = disposition.getLast();
+ if(last == null)
+ {
+ last = deliveryId;
+ }
+
+
+ while(deliveryId.compareTo(last)<=0)
+ {
+
+ Delivery delivery = unsettledTransfers.get(deliveryId);
+ if(delivery != null)
+ {
+ delivery.getLinkEndpoint().receiveDeliveryState(delivery,
+ disposition.getState(),
+ disposition.getSettled());
+ }
+ deliveryId = deliveryId.add(UnsignedInteger.ONE);
+ }
+ if(disposition.getSettled())
+ {
+ checkSendFlow();
+ }
+
+ }
+
+ private void checkSendFlow()
+ {
+ //TODO
+ }
+
+ public SendingLinkEndpoint createSendingLinkEndpoint(final String name, final String targetAddr, final String sourceAddr)
+ {
+ return createSendingLinkEndpoint(name, targetAddr, sourceAddr, null);
+ }
+
+ public SendingLinkEndpoint createSendingLinkEndpoint(final String name, final String targetAddr, final String sourceAddr, Map<Binary, Outcome> unsettled)
+ {
+ return createSendingLinkEndpoint(name, targetAddr, sourceAddr, false, unsettled);
+ }
+
+ public SendingLinkEndpoint createSendingLinkEndpoint(final String name, final String targetAddr,
+ final String sourceAddr, boolean durable,
+ Map<Binary, Outcome> unsettled)
+ {
+
+ Source source = new Source();
+ source.setAddress(sourceAddr);
+ Target target = new Target();
+ target.setAddress(targetAddr);
+ if(durable)
+ {
+ target.setDurable(TerminusDurability.UNSETTLED_STATE);
+ target.setExpiryPolicy(TerminusExpiryPolicy.NEVER);
+ }
+
+ return createSendingLinkEndpoint(name, source, target, unsettled);
+
+ }
+
+ public SendingLinkEndpoint createSendingLinkEndpoint(final String name, final Source source, final org.apache.qpid.amqp_1_0.type.Target target)
+ {
+ return createSendingLinkEndpoint(name, source, target, null);
+ }
+
+ public SendingLinkEndpoint createSendingLinkEndpoint(final String name, final Source source, final org.apache.qpid.amqp_1_0.type.Target target, Map<Binary, Outcome> unsettled)
+ {
+ SendingLinkEndpoint endpoint = new SendingLinkEndpoint(this, name, unsettled);
+ endpoint.setSource(source);
+ endpoint.setTarget(target);
+ UnsignedInteger handle = findNextAvailableHandle();
+ _localLinkEndpoints.put(endpoint, handle);
+ endpoint.setLocalHandle(handle);
+ getLinkMap().put(name, endpoint);
+
+ return endpoint;
+ }
+
+ public void sendAttach(Attach attach)
+ {
+ send(attach);
+ }
+
+ public void sendTransfer(final Transfer xfr, SendingLinkEndpoint endpoint, boolean newDelivery)
+ {
+ _nextOutgoingTransferId.incr();
+ UnsignedInteger deliveryId;
+ if(newDelivery)
+ {
+ deliveryId = UnsignedInteger.valueOf(_nextOutgoingDeliveryId++);
+ endpoint.setLastDeliveryId(deliveryId);
+ }
+ else
+ {
+ deliveryId = endpoint.getLastDeliveryId();
+ }
+ xfr.setDeliveryId(deliveryId);
+
+ if(!Boolean.TRUE.equals(xfr.getSettled()))
+ {
+ Delivery delivery;
+ if((delivery = _outgoingUnsettled.get(deliveryId))== null)
+ {
+ delivery = new Delivery(xfr, endpoint);
+ _outgoingUnsettled.put(deliveryId, delivery);
+
+ }
+ else
+ {
+ delivery.addTransfer(xfr);
+ }
+ _outgoingSessionCredit = _outgoingSessionCredit.subtract(UnsignedInteger.ONE);
+ endpoint.addUnsettled(delivery);
+
+ }
+
+ try
+ {
+ ByteBuffer payload = xfr.getPayload();
+ int payloadSent = send(xfr, payload);
+
+ if(payload != null && payloadSent < payload.remaining())
+ {
+ payload = payload.duplicate();
+try
+{
+ payload.position(payload.position()+payloadSent);
+}
+catch(IllegalArgumentException e)
+{
+ System.err.println("UNEXPECTED");
+ System.err.println("Payload Position: " + payload.position());
+ System.err.println("Payload Sent: " + payloadSent);
+ System.err.println("Payload Remaining: " + payload.remaining());
+ throw e;
+
+}
+
+ Transfer secondTransfer = new Transfer();
+
+ secondTransfer.setDeliveryTag(xfr.getDeliveryTag());
+ secondTransfer.setHandle(xfr.getHandle());
+ secondTransfer.setSettled(xfr.getSettled());
+ secondTransfer.setState(xfr.getState());
+ secondTransfer.setMessageFormat(xfr.getMessageFormat());
+ secondTransfer.setPayload(payload);
+
+ sendTransfer(secondTransfer, endpoint, false);
+
+ }
+ }
+ catch(OversizeFrameException e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+ public Object getLock()
+ {
+ return _connection.getLock();
+ }
+
+ public ReceivingLinkEndpoint createReceivingLinkEndpoint(final String name,
+ String targetAddr,
+ String sourceAddr,
+ UnsignedInteger initialCredit,
+ final DistributionMode distributionMode)
+ {
+ Source source = new Source();
+ source.setAddress(sourceAddr);
+ source.setDistributionMode(distributionMode);
+ Target target = new Target();
+ target.setAddress(targetAddr);
+
+ return createReceivingLinkEndpoint(name, target, source, initialCredit);
+ }
+
+ public ReceivingLinkEndpoint createReceivingLinkEndpoint(final String name,
+ Target target,
+ Source source,
+ UnsignedInteger initialCredit)
+ {
+ ReceivingLinkEndpoint endpoint = new ReceivingLinkEndpoint(this, name);
+ endpoint.setLinkCredit(initialCredit);
+ endpoint.setSource(source);
+ endpoint.setTarget(target);
+ UnsignedInteger handle = findNextAvailableHandle();
+ _localLinkEndpoints.put(endpoint, handle);
+ endpoint.setLocalHandle(handle);
+ getLinkMap().put(name, endpoint);
+
+ return endpoint;
+
+ }
+
+ public void updateDisposition(final Role role,
+ final UnsignedInteger first,
+ final UnsignedInteger last,
+ final DeliveryState state,
+ final boolean settled)
+ {
+
+
+ Disposition disposition = new Disposition();
+ disposition.setRole(role);
+ disposition.setFirst(first);
+ disposition.setLast(last);
+ disposition.setSettled(settled);
+
+ disposition.setState(state);
+
+
+ if(settled)
+ {
+ if(role == Role.RECEIVER)
+ {
+ SequenceNumber pos = new SequenceNumber(first.intValue());
+ SequenceNumber end = new SequenceNumber(last.intValue());
+ while(pos.compareTo(end)<=0)
+ {
+ Delivery d = _incomingUnsettled.remove(new UnsignedInteger(pos.intValue()));
+
+/*
+ _availableIncomingCredit += d.getTransfers().size();
+*/
+
+ pos.incr();
+ }
+ }
+ }
+
+ send(disposition);
+ checkSendFlow();
+ }
+
+ public void settle(Role role, final UnsignedInteger deliveryId)
+ {
+ if(role == Role.RECEIVER)
+ {
+ Delivery d = _incomingUnsettled.remove(deliveryId);
+ if(d != null)
+ {
+/*
+ _availableIncomingCredit += d.getTransfers().size();
+*/
+ }
+ }
+ else
+ {
+ Delivery d = _outgoingUnsettled.remove(deliveryId);
+/* if(d != null)
+ {
+ _availableOutgoingCredit += d.getTransfers().size();
+
+ }*/
+ }
+
+ }
+
+ public void sendFlow()
+ {
+ sendFlow(new Flow());
+ }
+ public void sendFlow(final Flow flow)
+ {
+ final int nextIncomingId = _nextIncomingTransferId.intValue();
+ flow.setNextIncomingId(UnsignedInteger.valueOf(nextIncomingId));
+ flow.setIncomingWindow(UnsignedInteger.valueOf(_availableIncomingCredit));
+ _lastSentIncomingLimit = UnsignedInteger.valueOf(nextIncomingId + _availableIncomingCredit);
+
+ flow.setNextOutgoingId(UnsignedInteger.valueOf(_nextOutgoingTransferId.intValue()));
+ flow.setOutgoingWindow(UnsignedInteger.valueOf(_availableOutgoingCredit));
+ send(flow);
+ }
+
+ public void sendFlowConditional()
+ {
+ UnsignedInteger clientsCredit = _lastSentIncomingLimit.subtract(UnsignedInteger.valueOf(_nextIncomingTransferId.intValue()));
+ int i = UnsignedInteger.valueOf(_availableIncomingCredit).subtract(clientsCredit).compareTo(clientsCredit);
+ if(i >=0)
+ {
+ sendFlow();
+ }
+
+ }
+
+ public void sendDetach(Detach detach)
+ {
+ send(detach);
+
+ }
+
+ void doEnd(End end)
+ {
+ }
+
+ public void setNextIncomingId(final UnsignedInteger nextIncomingId)
+ {
+ _nextIncomingTransferId = new SequenceNumber(nextIncomingId.intValue());
+
+ }
+
+ public void setOutgoingSessionCredit(final UnsignedInteger outgoingSessionCredit)
+ {
+ _outgoingSessionCredit = outgoingSessionCredit;
+ }
+
+ public UnsignedInteger getNextOutgoingId()
+ {
+ return UnsignedInteger.valueOf(_nextOutgoingTransferId.intValue());
+ }
+
+ public UnsignedInteger getOutgoingWindowSize()
+ {
+ return UnsignedInteger.valueOf(_availableOutgoingCredit);
+ }
+
+ public boolean hasCreditToSend()
+ {
+ boolean b = _outgoingSessionCredit != null && _outgoingSessionCredit.intValue() > 0;
+ boolean b1 = getOutgoingWindowSize() != null && getOutgoingWindowSize().compareTo(UnsignedInteger.ZERO) > 0;
+ return b && b1;
+ }
+
+ public UnsignedInteger getIncomingWindowSize()
+ {
+ return UnsignedInteger.valueOf(_availableIncomingCredit);
+ }
+
+ public SessionEventListener getSessionEventListener()
+ {
+ return _sessionEventListener;
+ }
+
+ public void setSessionEventListener(final SessionEventListener sessionEventListener)
+ {
+ _sessionEventListener = sessionEventListener;
+ }
+
+ public ConnectionEndpoint getConnection()
+ {
+ return _connection;
+ }
+
+ public SendingLinkEndpoint createTransactionController(String name, TxnCapability... capabilities)
+ {
+ Coordinator coordinator = new Coordinator();
+ coordinator.setCapabilities(capabilities);
+
+ Source src = new Source();
+
+ return createSendingLinkEndpoint(name, src, coordinator);
+ }
+
+ Map<String, LinkEndpoint> getLinkMap()
+ {
+ return _linkMap;
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEventListener.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEventListener.java
new file mode 100644
index 0000000000..81d51b5908
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionEventListener.java
@@ -0,0 +1,47 @@
+/*
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.transport.End;
+
+public interface SessionEventListener
+{
+ class DefaultSessionEventListener implements SessionEventListener
+ {
+ public void remoteLinkCreation(final LinkEndpoint endpoint)
+ {
+ endpoint.attach();
+ endpoint.detach();
+ }
+
+ public void remoteEnd(End end)
+ {
+
+ }
+
+ }
+
+ public static final SessionEventListener DEFAULT = new DefaultSessionEventListener();
+
+ void remoteLinkCreation(LinkEndpoint endpoint);
+
+ void remoteEnd(End end);
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionHalfEndpoint.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionHalfEndpoint.java
new file mode 100644
index 0000000000..fce1ce021f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionHalfEndpoint.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+public class SessionHalfEndpoint
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionState.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionState.java
new file mode 100644
index 0000000000..b09e27d980
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/SessionState.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+public enum SessionState
+{
+ ACTIVE,
+ INACTIVE,
+ BEGIN_SENT,
+ BEGIN_RECVD,
+ END_SENT,
+ END_RECVD,
+ ENDED;
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/StateChangeListener.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/StateChangeListener.java
new file mode 100644
index 0000000000..a02e110d8b
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/StateChangeListener.java
@@ -0,0 +1,25 @@
+/*
+ * 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.amqp_1_0.transport;
+
+public interface StateChangeListener
+{
+ void onStateChange(boolean active);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/UnsettledTransfer.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/UnsettledTransfer.java
new file mode 100644
index 0000000000..7a39fd9a54
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/UnsettledTransfer.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.amqp_1_0.transport;
+
+import org.apache.qpid.amqp_1_0.type.transport.Transfer;
+
+public class UnsettledTransfer
+{
+ private final Transfer _transfer;
+ private final LinkEndpoint _linkEndpoint;
+
+ public UnsettledTransfer(final Transfer transfer, final LinkEndpoint linkEndpoint)
+ {
+ _transfer = transfer;
+ _linkEndpoint = linkEndpoint;
+ }
+
+ public Transfer getTransfer()
+ {
+ return _transfer;
+ }
+
+ public LinkEndpoint getLinkEndpoint()
+ {
+ return _linkEndpoint;
+ }
+
+ @Override public String toString()
+ {
+ return "UnsettledTransfer{" +
+ "_transfer=" + _transfer +
+ ", _linkEndpoint=" + _linkEndpoint +
+ '}';
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/AmqpErrorException.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/AmqpErrorException.java
new file mode 100644
index 0000000000..74ae7de470
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/AmqpErrorException.java
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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.amqp_1_0.type;
+
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+import java.util.Formatter;
+
+public class AmqpErrorException extends Exception
+{
+ private final Error _error;
+
+
+ public AmqpErrorException(final Error error)
+ {
+ _error = error;
+ }
+
+ public AmqpErrorException(ErrorCondition condition)
+ {
+ _error = new Error();
+ _error.setCondition(condition);
+ }
+
+ public AmqpErrorException(ErrorCondition condition, String format, Object... args)
+ {
+ _error = new Error();
+ _error.setCondition(condition);
+ _error.setDescription((new Formatter()).format(format, args).toString());
+ }
+
+ public Error getError()
+ {
+ return _error;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Binary.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Binary.java
new file mode 100644
index 0000000000..0c8dc3444a
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Binary.java
@@ -0,0 +1,161 @@
+/*
+ *
+ * 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.amqp_1_0.type;
+
+import java.nio.ByteBuffer;
+import java.util.Collection;
+
+import static java.lang.Math.min;
+
+public class Binary
+{
+
+ private final byte[] _data;
+ private final int _offset;
+ private final int _length;
+ private final int _hashCode;
+
+ public Binary(final byte[] data)
+ {
+ this(data, 0, data.length);
+ }
+
+ public Binary(final byte[] data, final int offset, final int length)
+ {
+
+ _data = data;
+ _offset = offset;
+ _length = length;
+ int hc = 0;
+ for (int i = 0; i < length; i++)
+ {
+ hc = 31*hc + (0xFF & data[offset + i]);
+ }
+ _hashCode = hc;
+ }
+
+ public ByteBuffer asByteBuffer()
+ {
+ return ByteBuffer.wrap(_data, _offset, _length);
+ }
+
+ public final int hashCode()
+ {
+ return _hashCode;
+ }
+
+ public final boolean equals(Object o)
+ {
+ Binary buf = (Binary) o;
+ if(o == null)
+ {
+ return false;
+ }
+ final int size = _length;
+ if (size != buf._length)
+ {
+ return false;
+ }
+
+ final byte[] myData = _data;
+ final byte[] theirData = buf._data;
+ int myOffset = _offset;
+ int theirOffset = buf._offset;
+ final int myLimit = myOffset + size;
+
+ while(myOffset < myLimit)
+ {
+ if (myData[myOffset++] != theirData[theirOffset++])
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+ public int getArrayOffset()
+ {
+ return _offset;
+ }
+
+ public byte[] getArray()
+ {
+ return _data;
+ }
+
+ public int getLength()
+ {
+ return _length;
+ }
+
+ public String toString()
+ {
+ StringBuilder str = new StringBuilder();
+
+
+ for (int i = _offset; i < _length; i++)
+ {
+ byte c = _data[i];
+
+ if (c > 31 && c < 127 && c != '\\')
+ {
+ str.append((char)c);
+ }
+ else
+ {
+ str.append(String.format("\\x%02x", c));
+ }
+ }
+
+ return str.toString();
+
+ }
+
+ public static Binary combine(final Collection<Binary> binaries)
+ {
+
+ if(binaries.size() == 1)
+ {
+ return binaries.iterator().next();
+ }
+
+ int size = 0;
+ for(Binary binary : binaries)
+ {
+ size += binary.getLength();
+ }
+ byte[] data = new byte[size];
+ int offset = 0;
+ for(Binary binary : binaries)
+ {
+ System.arraycopy(binary._data, binary._offset, data, offset, binary._length);
+ offset += binary._length;
+ }
+ return new Binary(data);
+ }
+
+ public Binary subBinary(final int offset, final int length)
+ {
+ return new Binary(_data, _offset+offset, length);
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/DeliveryState.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/DeliveryState.java
new file mode 100644
index 0000000000..a16cc46729
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/DeliveryState.java
@@ -0,0 +1,26 @@
+/*
+*
+* 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.amqp_1_0.type;
+
+public interface DeliveryState
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/DistributionMode.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/DistributionMode.java
new file mode 100644
index 0000000000..751bdd1406
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/DistributionMode.java
@@ -0,0 +1,26 @@
+/*
+*
+* 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.amqp_1_0.type;
+
+public interface DistributionMode
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/ErrorCondition.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/ErrorCondition.java
new file mode 100644
index 0000000000..a9f8115784
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/ErrorCondition.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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.amqp_1_0.type;
+
+public interface ErrorCondition
+{
+ public Symbol getValue();
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/FrameBody.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/FrameBody.java
new file mode 100644
index 0000000000..0312378019
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/FrameBody.java
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.amqp_1_0.type;
+
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+public interface FrameBody
+{
+ public void invoke(short channel, ConnectionEndpoint conn);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/GlobalTxId.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/GlobalTxId.java
new file mode 100644
index 0000000000..f17a8648c6
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/GlobalTxId.java
@@ -0,0 +1,26 @@
+/*
+*
+* 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.amqp_1_0.type;
+
+public class GlobalTxId
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/LifetimePolicy.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/LifetimePolicy.java
new file mode 100644
index 0000000000..af13cdaffe
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/LifetimePolicy.java
@@ -0,0 +1,26 @@
+/*
+*
+* 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.amqp_1_0.type;
+
+public interface LifetimePolicy
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Outcome.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Outcome.java
new file mode 100644
index 0000000000..0741ebdf70
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Outcome.java
@@ -0,0 +1,26 @@
+/*
+*
+* 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.amqp_1_0.type;
+
+public interface Outcome
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/RestrictedType.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/RestrictedType.java
new file mode 100644
index 0000000000..9bcfc752a1
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/RestrictedType.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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.amqp_1_0.type;
+
+public interface RestrictedType<V>
+{
+ V getValue();
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/SaslFrameBody.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/SaslFrameBody.java
new file mode 100644
index 0000000000..cb4332f020
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/SaslFrameBody.java
@@ -0,0 +1,27 @@
+/*
+ * 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.amqp_1_0.type;
+
+import org.apache.qpid.amqp_1_0.transport.SASLEndpoint;
+
+public interface SaslFrameBody
+{
+ public void invoke(SASLEndpoint conn);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Section.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Section.java
new file mode 100644
index 0000000000..1e2872b66a
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Section.java
@@ -0,0 +1,27 @@
+/*
+ * 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.amqp_1_0.type;
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+
+public interface Section
+{
+
+ Binary encode(SectionEncoder encoder);
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Source.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Source.java
new file mode 100644
index 0000000000..c033ed4d55
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Source.java
@@ -0,0 +1,26 @@
+/*
+*
+* 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.amqp_1_0.type;
+
+public interface Source
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Symbol.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Symbol.java
new file mode 100644
index 0000000000..6efcdcf952
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Symbol.java
@@ -0,0 +1,90 @@
+/*
+ *
+ * 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.amqp_1_0.type;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+public final class Symbol implements Comparable<Symbol>, CharSequence
+{
+ private final String _underlying;
+ private static final ConcurrentHashMap<String, Symbol> _symbols = new ConcurrentHashMap<String, Symbol>(2048);
+
+ private Symbol(String underlying)
+ {
+ _underlying = underlying;
+ }
+
+ public int length()
+ {
+ return _underlying.length();
+ }
+
+ public int compareTo(Symbol o)
+ {
+ return _underlying.compareTo(o._underlying);
+ }
+
+ public char charAt(int index)
+ {
+ return _underlying.charAt(index);
+ }
+
+ public CharSequence subSequence(int beginIndex, int endIndex)
+ {
+ return _underlying.subSequence(beginIndex, endIndex);
+ }
+
+ @Override
+ public String toString()
+ {
+ return _underlying;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return _underlying.hashCode();
+ }
+
+ public static Symbol valueOf(String symbolVal)
+ {
+ return getSymbol(symbolVal);
+ }
+
+ public static Symbol getSymbol(String symbolVal)
+ {
+ Symbol symbol = _symbols.get(symbolVal);
+ if(symbol == null)
+ {
+ symbolVal = symbolVal.intern();
+ symbol = new Symbol(symbolVal);
+ Symbol existing;
+ if((existing = _symbols.putIfAbsent(symbolVal, symbol)) != null)
+ {
+ symbol = existing;
+ }
+ }
+ return symbol;
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Target.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Target.java
new file mode 100644
index 0000000000..345f6c418f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Target.java
@@ -0,0 +1,26 @@
+/*
+*
+* 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.amqp_1_0.type;
+
+public interface Target
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/TxnCapability.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/TxnCapability.java
new file mode 100644
index 0000000000..3d7d2137a6
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/TxnCapability.java
@@ -0,0 +1,26 @@
+/*
+*
+* 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.amqp_1_0.type;
+
+public interface TxnCapability
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/TxnId.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/TxnId.java
new file mode 100644
index 0000000000..eef6b3a32f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/TxnId.java
@@ -0,0 +1,23 @@
+/*
+ * 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.amqp_1_0.type;
+
+public interface TxnId
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedByte.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedByte.java
new file mode 100644
index 0000000000..07739e068e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedByte.java
@@ -0,0 +1,134 @@
+/*
+ *
+ * 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.amqp_1_0.type;
+
+public final class UnsignedByte extends Number implements Comparable<UnsignedByte>
+{
+ private final byte _underlying;
+ private static final UnsignedByte[] cachedValues = new UnsignedByte[256];
+
+ static
+ {
+ for(int i = 0; i<256; i++)
+ {
+ cachedValues[i] = new UnsignedByte((byte)i);
+ }
+ }
+
+ public UnsignedByte(byte underlying)
+ {
+ _underlying = underlying;
+ }
+
+ @Override
+ public byte byteValue()
+ {
+ return _underlying;
+ }
+
+ @Override
+ public short shortValue()
+ {
+ return (short) intValue();
+ }
+
+ @Override
+ public int intValue()
+ {
+ return ((int)_underlying) & 0xFF;
+ }
+
+ @Override
+ public long longValue()
+ {
+ return ((long) _underlying) & 0xFFl;
+ }
+
+ @Override
+ public float floatValue()
+ {
+ return (float) longValue();
+ }
+
+ @Override
+ public double doubleValue()
+ {
+ return (double) longValue();
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ UnsignedByte that = (UnsignedByte) o;
+
+ if (_underlying != that._underlying)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int compareTo(UnsignedByte o)
+ {
+ return Integer.signum(intValue() - o.intValue());
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return _underlying;
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.valueOf(intValue());
+ }
+
+ public static UnsignedByte valueOf(byte underlying)
+ {
+ final int index = ((int) underlying) & 0xFF;
+ return cachedValues[index];
+ }
+
+ public static UnsignedByte valueOf(final String value)
+ throws NumberFormatException
+ {
+ int intVal = Integer.parseInt(value);
+ if(intVal < 0 || intVal >= (1<<8))
+ {
+ throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0 + "-" + (1<<8) +").");
+ }
+ return valueOf((byte)intVal);
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedInteger.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedInteger.java
new file mode 100644
index 0000000000..f9a8f96868
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedInteger.java
@@ -0,0 +1,149 @@
+/*
+ *
+ * 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.amqp_1_0.type;
+
+public final class UnsignedInteger extends Number implements Comparable<UnsignedInteger>
+{
+ private final int _underlying;
+ private static final UnsignedInteger[] cachedValues = new UnsignedInteger[256];
+
+ static
+ {
+ for(int i = 0; i < 256; i++)
+ {
+ cachedValues[i] = new UnsignedInteger(i);
+ }
+ }
+
+ public static final UnsignedInteger ZERO = cachedValues[0];
+ public static final UnsignedInteger ONE = cachedValues[1];
+ public static final UnsignedInteger MAX_VALUE = new UnsignedInteger(0xffffffff);
+
+
+ public UnsignedInteger(int underlying)
+ {
+ _underlying = underlying;
+ }
+
+ @Override
+ public int intValue()
+ {
+ return _underlying;
+ }
+
+ @Override
+ public long longValue()
+ {
+ return ((long) _underlying) & 0xFFFFFFFFl;
+ }
+
+ @Override
+ public float floatValue()
+ {
+ return (float) longValue();
+ }
+
+ @Override
+ public double doubleValue()
+ {
+ return (double) longValue();
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ UnsignedInteger that = (UnsignedInteger) o;
+
+ if (_underlying != that._underlying)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int compareTo(UnsignedInteger o)
+ {
+ return Long.signum(longValue() - o.longValue());
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return _underlying;
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.valueOf(longValue());
+ }
+
+ public static UnsignedInteger valueOf(int underlying)
+ {
+ if((underlying & 0xFFFFFF00) == 0)
+ {
+ return cachedValues[underlying];
+ }
+ else
+ {
+ return new UnsignedInteger(underlying);
+ }
+ }
+
+ public UnsignedInteger add(final UnsignedInteger i)
+ {
+ int val = _underlying + i._underlying;
+ return UnsignedInteger.valueOf(val);
+ }
+
+ public UnsignedInteger subtract(final UnsignedInteger i)
+ {
+ int val = _underlying - i._underlying;
+ return UnsignedInteger.valueOf(val);
+ }
+
+ public static UnsignedInteger valueOf(final String value)
+ {
+ long longVal = Long.parseLong(value);
+ return valueOf(longVal);
+ }
+
+ public static UnsignedInteger valueOf(final long longVal)
+ {
+ if(longVal < 0L || longVal >= (1L<<32))
+ {
+ throw new NumberFormatException("Value \""+longVal+"\" lies outside the range [" + 0L + "-" + (1L<<32) +").");
+ }
+ return valueOf((int)longVal);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedLong.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedLong.java
new file mode 100644
index 0000000000..0586423fe0
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedLong.java
@@ -0,0 +1,162 @@
+/*
+ *
+ * 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.amqp_1_0.type;
+
+import java.math.BigInteger;
+
+public final class UnsignedLong extends Number implements Comparable<UnsignedLong>
+{
+ private static final BigInteger TWO_TO_THE_SIXTY_FOUR = new BigInteger( new byte[] { (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 });
+ private static final BigInteger LONG_MAX_VALUE = BigInteger.valueOf(Long.MAX_VALUE);
+
+ private static final UnsignedLong[] cachedValues = new UnsignedLong[256];
+
+ static
+ {
+ for(int i = 0; i<256; i++)
+ {
+ cachedValues[i] = new UnsignedLong(i);
+ }
+ }
+
+ public static final UnsignedLong ZERO = cachedValues[0];
+ public static final UnsignedLong ONE = cachedValues[1];
+
+ private final long _underlying;
+
+
+
+ public UnsignedLong(long underlying)
+ {
+ _underlying = underlying;
+ }
+
+ @Override
+ public int intValue()
+ {
+ return (int) _underlying;
+ }
+
+ @Override
+ public long longValue()
+ {
+ return _underlying;
+ }
+
+ public BigInteger bigIntegerValue()
+ {
+ if(_underlying >= 0L)
+ {
+ return BigInteger.valueOf(_underlying);
+ }
+ else
+ {
+ return TWO_TO_THE_SIXTY_FOUR.add(BigInteger.valueOf(_underlying));
+ }
+ }
+
+ @Override
+ public float floatValue()
+ {
+ return (float) longValue();
+ }
+
+ @Override
+ public double doubleValue()
+ {
+ return (double) longValue();
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ UnsignedLong that = (UnsignedLong) o;
+
+ if (_underlying != that._underlying)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int compareTo(UnsignedLong o)
+ {
+ return bigIntegerValue().compareTo(o.bigIntegerValue());
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return (int)(_underlying ^ (_underlying >>> 32));
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.valueOf(bigIntegerValue());
+ }
+
+ public static UnsignedLong valueOf(long underlying)
+ {
+ if((underlying & 0xFFL) == underlying)
+ {
+ return cachedValues[(int)underlying];
+ }
+ else
+ {
+ return new UnsignedLong(underlying);
+ }
+ }
+
+ public static UnsignedLong valueOf(final String value)
+ {
+ BigInteger bigInt = new BigInteger(value);
+ if(bigInt.signum() == -1 || bigInt.bitCount()>64)
+ {
+ throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0L + "- 2^64).");
+ }
+ else if(bigInt.compareTo(LONG_MAX_VALUE)>=0)
+ {
+ return UnsignedLong.valueOf(bigInt.longValue());
+ }
+ else
+ {
+ return UnsignedLong.valueOf(TWO_TO_THE_SIXTY_FOUR.subtract(bigInt).negate().longValue());
+ }
+
+ }
+
+ public UnsignedLong add(UnsignedLong unsignedLong)
+ {
+ return UnsignedLong.valueOf(_underlying + unsignedLong._underlying);
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedShort.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedShort.java
new file mode 100644
index 0000000000..01c72ac159
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/UnsignedShort.java
@@ -0,0 +1,132 @@
+/*
+ *
+ * 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.amqp_1_0.type;
+
+public final class UnsignedShort extends Number implements Comparable<UnsignedShort>
+{
+ private final short _underlying;
+ private static final UnsignedShort[] cachedValues = new UnsignedShort[256];
+
+ static
+ {
+ for(short i = 0; i < 256; i++)
+ {
+ cachedValues[i] = new UnsignedShort(i);
+ }
+ }
+
+ public UnsignedShort(short underlying)
+ {
+ _underlying = underlying;
+ }
+
+ public short shortValue()
+ {
+ return _underlying;
+ }
+
+ @Override
+ public int intValue()
+ {
+ return _underlying & 0xFFFF;
+ }
+
+ @Override
+ public long longValue()
+ {
+ return ((long) _underlying) & 0xFFFFl;
+ }
+
+ @Override
+ public float floatValue()
+ {
+ return (float) intValue();
+ }
+
+ @Override
+ public double doubleValue()
+ {
+ return (double) intValue();
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ UnsignedShort that = (UnsignedShort) o;
+
+ if (_underlying != that._underlying)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int compareTo(UnsignedShort o)
+ {
+ return Integer.signum(intValue() - o.intValue());
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return _underlying;
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.valueOf(longValue());
+ }
+
+ public static UnsignedShort valueOf(short underlying)
+ {
+ if((underlying & 0xFF00) == 0)
+ {
+ return cachedValues[underlying];
+ }
+ else
+ {
+ return new UnsignedShort(underlying);
+ }
+ }
+
+ public static UnsignedShort valueOf(final String value)
+ {
+ int intVal = Integer.parseInt(value);
+ if(intVal < 0 || intVal >= (1<<16))
+ {
+ throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0 + "-" + (1<<16) +").");
+ }
+ return valueOf((short)intVal);
+
+ }
+} \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/WrapperType.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/WrapperType.java
new file mode 100644
index 0000000000..359926d9d4
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/WrapperType.java
@@ -0,0 +1,27 @@
+/*
+*
+* 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.amqp_1_0.type;
+
+public interface WrapperType
+{
+ Object getValue();
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/codec/AMQPDescribedTypeRegistry.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/codec/AMQPDescribedTypeRegistry.java
new file mode 100644
index 0000000000..5ffa96e094
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/codec/AMQPDescribedTypeRegistry.java
@@ -0,0 +1,389 @@
+
+
+package org.apache.qpid.amqp_1_0.type.codec;
+
+import org.apache.qpid.amqp_1_0.codec.BinaryWriter;
+import org.apache.qpid.amqp_1_0.codec.BooleanWriter;
+import org.apache.qpid.amqp_1_0.codec.ByteWriter;
+import org.apache.qpid.amqp_1_0.codec.CharWriter;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.codec.DoubleWriter;
+import org.apache.qpid.amqp_1_0.codec.FloatWriter;
+import org.apache.qpid.amqp_1_0.codec.IntegerWriter;
+import org.apache.qpid.amqp_1_0.codec.ListWriter;
+import org.apache.qpid.amqp_1_0.codec.LongWriter;
+import org.apache.qpid.amqp_1_0.codec.MapWriter;
+import org.apache.qpid.amqp_1_0.codec.NullWriter;
+import org.apache.qpid.amqp_1_0.codec.RestrictedTypeValueWriter;
+import org.apache.qpid.amqp_1_0.codec.ShortWriter;
+import org.apache.qpid.amqp_1_0.codec.StringWriter;
+import org.apache.qpid.amqp_1_0.codec.SymbolWriter;
+import org.apache.qpid.amqp_1_0.codec.SymbolArrayWriter;
+import org.apache.qpid.amqp_1_0.codec.TimestampWriter;
+import org.apache.qpid.amqp_1_0.codec.TypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.UUIDWriter;
+import org.apache.qpid.amqp_1_0.codec.UnsignedByteWriter;
+import org.apache.qpid.amqp_1_0.codec.UnsignedIntegerWriter;
+import org.apache.qpid.amqp_1_0.codec.UnsignedLongWriter;
+import org.apache.qpid.amqp_1_0.codec.UnsignedShortWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+
+import org.apache.qpid.amqp_1_0.type.RestrictedType;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.codec.*;
+
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.codec.*;
+
+import org.apache.qpid.amqp_1_0.type.transaction.*;
+import org.apache.qpid.amqp_1_0.type.transaction.codec.*;
+
+import org.apache.qpid.amqp_1_0.type.security.*;
+import org.apache.qpid.amqp_1_0.type.security.codec.*;
+
+import java.lang.reflect.Array;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class AMQPDescribedTypeRegistry implements DescribedTypeConstructorRegistry, ValueWriter.Registry
+{
+
+ private final Map<Object, DescribedTypeConstructor> _constructorRegistry = new HashMap<Object, DescribedTypeConstructor>();
+
+ public void register(Object descriptor, DescribedTypeConstructor constructor)
+ {
+ _constructorRegistry.put(descriptor, constructor);
+ }
+
+ public void register(Object descriptor, DescribedTypeConstructor constructor, TypeConstructor describedConstructor)
+ {
+ _constructorRegistry.put(descriptor, constructor);
+ }
+
+ public DescribedTypeConstructor getConstructor(Object descriptor)
+ {
+ return _constructorRegistry.get(descriptor);
+ }
+
+ private AMQPDescribedTypeRegistry()
+ {
+ }
+
+ public AMQPDescribedTypeRegistry registerTransportLayer()
+ {
+ registerTransportConstructors(this);
+ registerTransportWriters(this);
+ return this;
+ }
+
+ public AMQPDescribedTypeRegistry registerMessagingLayer()
+ {
+ registerMessagingConstructors(this);
+ registerMessagingWriters(this);
+ return this;
+ }
+
+ public AMQPDescribedTypeRegistry registerTransactionLayer()
+ {
+ registerTransactionsConstructors(this);
+ registerTransactionsWriters(this);
+ return this;
+ }
+
+ public AMQPDescribedTypeRegistry registerSecurityLayer()
+ {
+ registerSecurityConstructors(this);
+ registerSecurityWriters(this);
+ return this;
+ }
+
+ public static AMQPDescribedTypeRegistry newInstance()
+ {
+ AMQPDescribedTypeRegistry registry = new AMQPDescribedTypeRegistry();
+
+ NullWriter.register(registry);
+ BooleanWriter.register(registry);
+ ByteWriter.register(registry);
+ UnsignedByteWriter.register(registry);
+ ShortWriter.register(registry);
+ UnsignedShortWriter.register(registry);
+ IntegerWriter.register(registry);
+ UnsignedIntegerWriter.register(registry);
+ CharWriter.register(registry);
+ FloatWriter.register(registry);
+ LongWriter.register(registry);
+ UnsignedLongWriter.register(registry);
+ DoubleWriter.register(registry);
+ TimestampWriter.register(registry);
+ UUIDWriter.register(registry);
+ StringWriter.register(registry);
+ SymbolWriter.register(registry);
+ BinaryWriter.register(registry);
+ ListWriter.register(registry);
+ MapWriter.register(registry);
+
+ SymbolArrayWriter.register(registry);
+
+ return registry;
+ }
+
+
+
+ private static void registerTransportWriters(final AMQPDescribedTypeRegistry registry)
+ {
+
+ OpenWriter.register(registry);
+ BeginWriter.register(registry);
+ AttachWriter.register(registry);
+ FlowWriter.register(registry);
+ TransferWriter.register(registry);
+ DispositionWriter.register(registry);
+ DetachWriter.register(registry);
+ EndWriter.register(registry);
+ CloseWriter.register(registry);
+ RestrictedTypeValueWriter.register(registry,Role.class);
+ RestrictedTypeValueWriter.register(registry,SenderSettleMode.class);
+ RestrictedTypeValueWriter.register(registry,ReceiverSettleMode.class);
+ ErrorWriter.register(registry);
+ RestrictedTypeValueWriter.register(registry,AmqpError.class);
+ RestrictedTypeValueWriter.register(registry,ConnectionError.class);
+ RestrictedTypeValueWriter.register(registry,SessionError.class);
+ RestrictedTypeValueWriter.register(registry,LinkError.class);
+ }
+
+ private static void registerMessagingWriters(final AMQPDescribedTypeRegistry registry)
+ {
+
+ HeaderWriter.register(registry);
+ DeliveryAnnotationsWriter.register(registry);
+ MessageAnnotationsWriter.register(registry);
+ PropertiesWriter.register(registry);
+ ApplicationPropertiesWriter.register(registry);
+ DataWriter.register(registry);
+ AmqpSequenceWriter.register(registry);
+ AmqpValueWriter.register(registry);
+ FooterWriter.register(registry);
+ ReceivedWriter.register(registry);
+ AcceptedWriter.register(registry);
+ RejectedWriter.register(registry);
+ ReleasedWriter.register(registry);
+ ModifiedWriter.register(registry);
+ SourceWriter.register(registry);
+ TargetWriter.register(registry);
+ RestrictedTypeValueWriter.register(registry,TerminusDurability.class);
+ RestrictedTypeValueWriter.register(registry,TerminusExpiryPolicy.class);
+ RestrictedTypeValueWriter.register(registry,StdDistMode.class);
+ DeleteOnCloseWriter.register(registry);
+ DeleteOnNoLinksWriter.register(registry);
+ DeleteOnNoMessagesWriter.register(registry);
+ DeleteOnNoLinksOrMessagesWriter.register(registry);
+
+
+ ExactSubjectFilterWriter.register(registry);
+ MatchingSubjectFilterWriter.register(registry);
+ JMSSelectorFilterWriter.register(registry);
+ NoLocalFilterWriter.register(registry);
+ }
+
+ private static void registerTransactionsWriters(final AMQPDescribedTypeRegistry registry)
+ {
+
+ CoordinatorWriter.register(registry);
+ DeclareWriter.register(registry);
+ DischargeWriter.register(registry);
+ DeclaredWriter.register(registry);
+ TransactionalStateWriter.register(registry);
+ RestrictedTypeValueWriter.register(registry,TxnCapability.class);
+ RestrictedTypeValueWriter.register(registry,TransactionErrors.class);
+ }
+
+ private static void registerSecurityWriters(final AMQPDescribedTypeRegistry registry)
+ {
+
+ SaslMechanismsWriter.register(registry);
+ SaslInitWriter.register(registry);
+ SaslChallengeWriter.register(registry);
+ SaslResponseWriter.register(registry);
+ SaslOutcomeWriter.register(registry);
+ RestrictedTypeValueWriter.register(registry,SaslCode.class);
+ }
+
+ private static void registerTransportConstructors(final AMQPDescribedTypeRegistry registry)
+ {
+
+ OpenConstructor.register(registry);
+ BeginConstructor.register(registry);
+ AttachConstructor.register(registry);
+ FlowConstructor.register(registry);
+ TransferConstructor.register(registry);
+ DispositionConstructor.register(registry);
+ DetachConstructor.register(registry);
+ EndConstructor.register(registry);
+ CloseConstructor.register(registry);
+ ErrorConstructor.register(registry);
+ }
+
+ private static void registerMessagingConstructors(final AMQPDescribedTypeRegistry registry)
+ {
+
+ HeaderConstructor.register(registry);
+ DeliveryAnnotationsConstructor.register(registry);
+ MessageAnnotationsConstructor.register(registry);
+ PropertiesConstructor.register(registry);
+ ApplicationPropertiesConstructor.register(registry);
+ DataConstructor.register(registry);
+ AmqpSequenceConstructor.register(registry);
+ AmqpValueConstructor.register(registry);
+ FooterConstructor.register(registry);
+ ReceivedConstructor.register(registry);
+ AcceptedConstructor.register(registry);
+ RejectedConstructor.register(registry);
+ ReleasedConstructor.register(registry);
+ ModifiedConstructor.register(registry);
+ SourceConstructor.register(registry);
+ TargetConstructor.register(registry);
+ DeleteOnCloseConstructor.register(registry);
+ DeleteOnNoLinksConstructor.register(registry);
+ DeleteOnNoMessagesConstructor.register(registry);
+ DeleteOnNoLinksOrMessagesConstructor.register(registry);
+
+ ExactSubjectFilterConstructor.register(registry);
+ MatchingSubjectFilterConstructor.register(registry);
+ JMSSelectorFilterConstructor.register(registry);
+ NoLocalFilterConstructor.register(registry);
+ }
+
+ private static void registerTransactionsConstructors(final AMQPDescribedTypeRegistry registry)
+ {
+
+ CoordinatorConstructor.register(registry);
+ DeclareConstructor.register(registry);
+ DischargeConstructor.register(registry);
+ DeclaredConstructor.register(registry);
+ TransactionalStateConstructor.register(registry);
+ }
+
+ private static void registerSecurityConstructors(final AMQPDescribedTypeRegistry registry)
+ {
+
+ SaslMechanismsConstructor.register(registry);
+ SaslInitConstructor.register(registry);
+ SaslChallengeConstructor.register(registry);
+ SaslResponseConstructor.register(registry);
+ SaslOutcomeConstructor.register(registry);
+ }
+
+
+ private final Map<Class, ValueWriter.Factory> _writerMap = new HashMap<Class, ValueWriter.Factory>();
+ private final Map<Class, ValueWriter> _cachedWriters = new HashMap<Class,ValueWriter>();
+
+ public <V extends Object> ValueWriter<V> getValueWriter(V value, Map<Class, ValueWriter> localCache)
+ {
+ Class<? extends Object> clazz = value == null ? Void.TYPE : value.getClass();
+ ValueWriter writer = null; // TODO localCache.get(clazz);
+ if(writer == null || !writer.isComplete())
+ {
+ writer = getValueWriter(value);
+ localCache.put(clazz, writer);
+ }
+ else
+ {
+ writer.setValue(value);
+ }
+
+
+ return writer;
+ }
+
+
+ public <V extends Object> ValueWriter<V> getValueWriter(V value)
+ {
+
+ Class<? extends Object> clazz = value == null ? Void.TYPE : value.getClass();
+
+ ValueWriter writer = null; // TODO _cachedWriters.get(clazz);
+ if(writer == null || !writer.isComplete())
+ {
+ ValueWriter.Factory<V> factory = (ValueWriter.Factory<V>) (_writerMap.get(clazz));
+
+ if(factory == null)
+ {
+ if(value instanceof List)
+ {
+ factory = _writerMap.get(List.class);
+ _writerMap.put(value.getClass(), factory);
+ writer = factory.newInstance(this);
+ if(writer.isCacheable())
+ {
+ _cachedWriters.put(clazz, writer);
+ }
+ writer.setValue(value);
+
+ }
+ else if(value instanceof Map)
+ {
+ factory = _writerMap.get(Map.class);
+ _writerMap.put(value.getClass(), factory);
+ writer = factory.newInstance(this);
+ if(writer.isCacheable())
+ {
+ _cachedWriters.put(clazz, writer);
+ }
+ writer.setValue(value);
+
+ }
+ else if(value.getClass().isArray())
+ {
+ if(RestrictedType.class.isAssignableFrom(value.getClass().getComponentType()))
+ {
+ RestrictedType[] restrictedTypes = (RestrictedType[]) value;
+ Object[] newVals = (Object[]) Array.newInstance(restrictedTypes[0].getValue().getClass(),
+ restrictedTypes.length);
+ for(int i = 0; i < restrictedTypes.length; i++)
+ {
+ newVals[i] = restrictedTypes[i].getValue();
+ }
+ return (ValueWriter<V>) getValueWriter(newVals);
+ }
+ // TODO primitive array types
+ factory = _writerMap.get(List.class);
+ writer = factory.newInstance(this);
+ writer.setValue(Arrays.asList((Object[])value));
+
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ writer = factory.newInstance(this);
+ if(writer.isCacheable())
+ {
+ _cachedWriters.put(clazz, writer);
+ }
+ writer.setValue(value);
+ }
+ }
+ else
+ {
+ writer.setValue(value);
+ }
+
+ return writer;
+
+ }
+
+ public <V extends Object> ValueWriter<V> register(Class<V> clazz, ValueWriter.Factory<V> writer)
+ {
+ return (ValueWriter<V>) _writerMap.put(clazz, writer);
+ }
+
+}
+
+ \ No newline at end of file
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Accepted.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Accepted.java
new file mode 100644
index 0000000000..aede9df82e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Accepted.java
@@ -0,0 +1,46 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Accepted
+ implements org.apache.qpid.amqp_1_0.type.DeliveryState, Outcome
+ {
+
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Accepted{");
+ final int origLength = builder.length();
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/AmqpSequence.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/AmqpSequence.java
new file mode 100644
index 0000000000..72531f3acc
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/AmqpSequence.java
@@ -0,0 +1,70 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+
+
+import java.util.List;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class AmqpSequence
+ implements Section
+ {
+
+
+
+ private final List _value;
+
+ public AmqpSequence(List value)
+ {
+ _value = value;
+ }
+
+ public List getValue()
+ {
+ return _value;
+ }
+
+
+
+
+ public Binary encode(final SectionEncoder encoder)
+ {
+ encoder.reset();
+ encoder.encodeObject(this);
+ return encoder.getEncoding();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "AmqpSequence{" +
+ _value +
+ '}';
+ }
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/AmqpValue.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/AmqpValue.java
new file mode 100644
index 0000000000..22723decca
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/AmqpValue.java
@@ -0,0 +1,66 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class AmqpValue
+ implements Section
+ {
+
+
+
+ private final Object _value;
+
+ public AmqpValue(Object value)
+ {
+ _value = value;
+ }
+
+ public Object getValue()
+ {
+ return _value;
+ }
+
+
+
+
+ public Binary encode(final SectionEncoder encoder)
+ {
+ encoder.reset();
+ encoder.encodeObject(this);
+ return encoder.getEncoding();
+ }
+
+
+ @Override
+ public String toString()
+ {
+ return "AmqpValue{(" + _value.getClass().getName() + ')' + _value + '}';
+ }
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/ApplicationProperties.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/ApplicationProperties.java
new file mode 100644
index 0000000000..fb9200ecb6
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/ApplicationProperties.java
@@ -0,0 +1,64 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+
+
+import java.util.Map;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class ApplicationProperties
+ implements Section
+ {
+
+
+
+ private final Map _value;
+
+ public ApplicationProperties(Map value)
+ {
+ _value = value;
+ }
+
+ public Map getValue()
+ {
+ return _value;
+ }
+
+
+
+
+ public Binary encode(final SectionEncoder encoder)
+ {
+ encoder.reset();
+ encoder.encodeObject(this);
+ return encoder.getEncoding();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Data.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Data.java
new file mode 100644
index 0000000000..f4b8b78264
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Data.java
@@ -0,0 +1,68 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Data
+ implements Section
+ {
+
+
+
+ private final Binary _value;
+
+ public Data(Binary value)
+ {
+ _value = value;
+ }
+
+ public Binary getValue()
+ {
+ return _value;
+ }
+
+
+
+
+ public Binary encode(final SectionEncoder encoder)
+ {
+ encoder.reset();
+ encoder.encodeObject(this);
+ return encoder.getEncoding();
+ }
+
+
+ @Override
+ public String toString()
+ {
+ return "Data{" +
+ _value +
+ '}';
+ }
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnClose.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnClose.java
new file mode 100644
index 0000000000..aab5cf8a27
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnClose.java
@@ -0,0 +1,46 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class DeleteOnClose
+ implements LifetimePolicy
+ {
+
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("DeleteOnClose{");
+ final int origLength = builder.length();
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoLinks.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoLinks.java
new file mode 100644
index 0000000000..ab0043ea5b
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoLinks.java
@@ -0,0 +1,46 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class DeleteOnNoLinks
+ implements LifetimePolicy
+ {
+
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("DeleteOnNoLinks{");
+ final int origLength = builder.length();
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoLinksOrMessages.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoLinksOrMessages.java
new file mode 100644
index 0000000000..591597c655
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoLinksOrMessages.java
@@ -0,0 +1,46 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class DeleteOnNoLinksOrMessages
+ implements LifetimePolicy
+ {
+
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("DeleteOnNoLinksOrMessages{");
+ final int origLength = builder.length();
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoMessages.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoMessages.java
new file mode 100644
index 0000000000..9e44061928
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeleteOnNoMessages.java
@@ -0,0 +1,46 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class DeleteOnNoMessages
+ implements LifetimePolicy
+ {
+
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("DeleteOnNoMessages{");
+ final int origLength = builder.length();
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeliveryAnnotations.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeliveryAnnotations.java
new file mode 100644
index 0000000000..bde1da090e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/DeliveryAnnotations.java
@@ -0,0 +1,64 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+
+
+import java.util.Map;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class DeliveryAnnotations
+ implements Section
+ {
+
+
+
+ private final Map _value;
+
+ public DeliveryAnnotations(Map value)
+ {
+ _value = value;
+ }
+
+ public Map getValue()
+ {
+ return _value;
+ }
+
+
+
+
+ public Binary encode(final SectionEncoder encoder)
+ {
+ encoder.reset();
+ encoder.encodeObject(this);
+ return encoder.getEncoding();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/ExactSubjectFilter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/ExactSubjectFilter.java
new file mode 100644
index 0000000000..3d01a26485
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/ExactSubjectFilter.java
@@ -0,0 +1,82 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+import org.apache.qpid.amqp_1_0.type.Binary;
+import org.apache.qpid.amqp_1_0.type.Section;
+
+public class ExactSubjectFilter implements Filter
+{
+
+
+
+ private final String _value;
+
+ public ExactSubjectFilter(String value)
+ {
+ _value = value;
+ }
+
+ public String getValue()
+ {
+ return _value;
+ }
+
+
+ @Override
+ public String toString()
+ {
+ return "ExactSubjectFilter{" + _value + '}';
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ ExactSubjectFilter that = (ExactSubjectFilter) o;
+
+ if(_value != null ? !_value.equals(that._value) : that._value != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return _value != null ? _value.hashCode() : 0;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Filter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Filter.java
new file mode 100644
index 0000000000..46f391bf4d
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Filter.java
@@ -0,0 +1,28 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+public interface Filter
+{
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Footer.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Footer.java
new file mode 100644
index 0000000000..25cf04763e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Footer.java
@@ -0,0 +1,70 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+
+
+import java.util.Map;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Footer
+ implements Section
+ {
+
+
+
+ private final Map _value;
+
+ public Footer(Map value)
+ {
+ _value = value;
+ }
+
+ public Map getValue()
+ {
+ return _value;
+ }
+
+
+
+
+ public Binary encode(final SectionEncoder encoder)
+ {
+ encoder.reset();
+ encoder.encodeObject(this);
+ return encoder.getEncoding();
+ }
+
+
+ @Override
+ public String toString()
+ {
+ return "Footer{" + _value +
+ '}';
+ }
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Header.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Header.java
new file mode 100644
index 0000000000..02b4810196
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Header.java
@@ -0,0 +1,161 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Header
+ implements Section
+ {
+
+
+ private Boolean _durable;
+
+ private UnsignedByte _priority;
+
+ private UnsignedInteger _ttl;
+
+ private Boolean _firstAcquirer;
+
+ private UnsignedInteger _deliveryCount;
+
+ public Boolean getDurable()
+ {
+ return _durable;
+ }
+
+ public void setDurable(Boolean durable)
+ {
+ _durable = durable;
+ }
+
+ public UnsignedByte getPriority()
+ {
+ return _priority;
+ }
+
+ public void setPriority(UnsignedByte priority)
+ {
+ _priority = priority;
+ }
+
+ public UnsignedInteger getTtl()
+ {
+ return _ttl;
+ }
+
+ public void setTtl(UnsignedInteger ttl)
+ {
+ _ttl = ttl;
+ }
+
+ public Boolean getFirstAcquirer()
+ {
+ return _firstAcquirer;
+ }
+
+ public void setFirstAcquirer(Boolean firstAcquirer)
+ {
+ _firstAcquirer = firstAcquirer;
+ }
+
+ public UnsignedInteger getDeliveryCount()
+ {
+ return _deliveryCount;
+ }
+
+ public void setDeliveryCount(UnsignedInteger deliveryCount)
+ {
+ _deliveryCount = deliveryCount;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Header{");
+ final int origLength = builder.length();
+
+ if(_durable != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("durable=").append(_durable);
+ }
+
+ if(_priority != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("priority=").append(_priority);
+ }
+
+ if(_ttl != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("ttl=").append(_ttl);
+ }
+
+ if(_firstAcquirer != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("firstAcquirer=").append(_firstAcquirer);
+ }
+
+ if(_deliveryCount != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("deliveryCount=").append(_deliveryCount);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ public Binary encode(final SectionEncoder encoder)
+ {
+ encoder.reset();
+ encoder.encodeObject(this);
+ return encoder.getEncoding();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/JMSSelectorFilter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/JMSSelectorFilter.java
new file mode 100644
index 0000000000..a6317c42bf
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/JMSSelectorFilter.java
@@ -0,0 +1,77 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+public class JMSSelectorFilter implements Filter
+{
+
+
+
+ private final String _value;
+
+ public JMSSelectorFilter(String value)
+ {
+ _value = value;
+ }
+
+ public String getValue()
+ {
+ return _value;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "JMSSelector{" + _value + '}';
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ JMSSelectorFilter that = (JMSSelectorFilter) o;
+
+ if(_value != null ? !_value.equals(that._value) : that._value != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return _value != null ? _value.hashCode() : 0;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/MatchingSubjectFilter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/MatchingSubjectFilter.java
new file mode 100644
index 0000000000..9504a658a9
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/MatchingSubjectFilter.java
@@ -0,0 +1,81 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+import org.apache.qpid.amqp_1_0.type.Binary;
+import org.apache.qpid.amqp_1_0.type.Section;
+
+public class MatchingSubjectFilter implements Filter
+{
+
+
+
+ private final String _value;
+
+ public MatchingSubjectFilter(String value)
+ {
+ _value = value;
+ }
+
+ public String getValue()
+ {
+ return _value;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "MatchingSubjectFilter{" + _value + '}';
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ MatchingSubjectFilter that = (MatchingSubjectFilter) o;
+
+ if(_value != null ? !_value.equals(that._value) : that._value != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return _value != null ? _value.hashCode() : 0;
+ }
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/MessageAnnotations.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/MessageAnnotations.java
new file mode 100644
index 0000000000..265beb7213
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/MessageAnnotations.java
@@ -0,0 +1,64 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+
+
+import java.util.Map;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class MessageAnnotations
+ implements Section
+ {
+
+
+
+ private final Map _value;
+
+ public MessageAnnotations(Map value)
+ {
+ _value = value;
+ }
+
+ public Map getValue()
+ {
+ return _value;
+ }
+
+
+
+
+ public Binary encode(final SectionEncoder encoder)
+ {
+ encoder.reset();
+ encoder.encodeObject(this);
+ return encoder.getEncoding();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Modified.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Modified.java
new file mode 100644
index 0000000000..d466cbf2b1
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Modified.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.amqp_1_0.type.messaging;
+
+
+
+import java.util.Map;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Modified
+ implements org.apache.qpid.amqp_1_0.type.DeliveryState, Outcome
+ {
+
+
+ private Boolean _deliveryFailed;
+
+ private Boolean _undeliverableHere;
+
+ private Map _messageAnnotations;
+
+ public Boolean getDeliveryFailed()
+ {
+ return _deliveryFailed;
+ }
+
+ public void setDeliveryFailed(Boolean deliveryFailed)
+ {
+ _deliveryFailed = deliveryFailed;
+ }
+
+ public Boolean getUndeliverableHere()
+ {
+ return _undeliverableHere;
+ }
+
+ public void setUndeliverableHere(Boolean undeliverableHere)
+ {
+ _undeliverableHere = undeliverableHere;
+ }
+
+ public Map getMessageAnnotations()
+ {
+ return _messageAnnotations;
+ }
+
+ public void setMessageAnnotations(Map messageAnnotations)
+ {
+ _messageAnnotations = messageAnnotations;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Modified{");
+ final int origLength = builder.length();
+
+ if(_deliveryFailed != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("deliveryFailed=").append(_deliveryFailed);
+ }
+
+ if(_undeliverableHere != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("undeliverableHere=").append(_undeliverableHere);
+ }
+
+ if(_messageAnnotations != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("messageAnnotations=").append(_messageAnnotations);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/NoLocalFilter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/NoLocalFilter.java
new file mode 100644
index 0000000000..73f175e6fa
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/NoLocalFilter.java
@@ -0,0 +1,45 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+public final class NoLocalFilter implements Filter
+{
+
+
+ public static final NoLocalFilter INSTANCE = new NoLocalFilter();
+
+ private NoLocalFilter()
+ {
+ }
+
+
+ @Override
+ public String toString()
+ {
+ return "NoLocalFilter{}";
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Properties.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Properties.java
new file mode 100644
index 0000000000..bcab361a8e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Properties.java
@@ -0,0 +1,333 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
+
+
+import java.util.Date;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Properties
+ implements Section
+ {
+
+
+ private Object _messageId;
+
+ private Binary _userId;
+
+ private String _to;
+
+ private String _subject;
+
+ private String _replyTo;
+
+ private Object _correlationId;
+
+ private Symbol _contentType;
+
+ private Symbol _contentEncoding;
+
+ private Date _absoluteExpiryTime;
+
+ private Date _creationTime;
+
+ private String _groupId;
+
+ private UnsignedInteger _groupSequence;
+
+ private String _replyToGroupId;
+
+ public Object getMessageId()
+ {
+ return _messageId;
+ }
+
+ public void setMessageId(Object messageId)
+ {
+ _messageId = messageId;
+ }
+
+ public Binary getUserId()
+ {
+ return _userId;
+ }
+
+ public void setUserId(Binary userId)
+ {
+ _userId = userId;
+ }
+
+ public String getTo()
+ {
+ return _to;
+ }
+
+ public void setTo(String to)
+ {
+ _to = to;
+ }
+
+ public String getSubject()
+ {
+ return _subject;
+ }
+
+ public void setSubject(String subject)
+ {
+ _subject = subject;
+ }
+
+ public String getReplyTo()
+ {
+ return _replyTo;
+ }
+
+ public void setReplyTo(String replyTo)
+ {
+ _replyTo = replyTo;
+ }
+
+ public Object getCorrelationId()
+ {
+ return _correlationId;
+ }
+
+ public void setCorrelationId(Object correlationId)
+ {
+ _correlationId = correlationId;
+ }
+
+ public Symbol getContentType()
+ {
+ return _contentType;
+ }
+
+ public void setContentType(Symbol contentType)
+ {
+ _contentType = contentType;
+ }
+
+ public Symbol getContentEncoding()
+ {
+ return _contentEncoding;
+ }
+
+ public void setContentEncoding(Symbol contentEncoding)
+ {
+ _contentEncoding = contentEncoding;
+ }
+
+ public Date getAbsoluteExpiryTime()
+ {
+ return _absoluteExpiryTime;
+ }
+
+ public void setAbsoluteExpiryTime(Date absoluteExpiryTime)
+ {
+ _absoluteExpiryTime = absoluteExpiryTime;
+ }
+
+ public Date getCreationTime()
+ {
+ return _creationTime;
+ }
+
+ public void setCreationTime(Date creationTime)
+ {
+ _creationTime = creationTime;
+ }
+
+ public String getGroupId()
+ {
+ return _groupId;
+ }
+
+ public void setGroupId(String groupId)
+ {
+ _groupId = groupId;
+ }
+
+ public UnsignedInteger getGroupSequence()
+ {
+ return _groupSequence;
+ }
+
+ public void setGroupSequence(UnsignedInteger groupSequence)
+ {
+ _groupSequence = groupSequence;
+ }
+
+ public String getReplyToGroupId()
+ {
+ return _replyToGroupId;
+ }
+
+ public void setReplyToGroupId(String replyToGroupId)
+ {
+ _replyToGroupId = replyToGroupId;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Properties{");
+ final int origLength = builder.length();
+
+ if(_messageId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("messageId=").append(_messageId);
+ }
+
+ if(_userId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("userId=").append(_userId);
+ }
+
+ if(_to != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("to=").append(_to);
+ }
+
+ if(_subject != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("subject=").append(_subject);
+ }
+
+ if(_replyTo != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("replyTo=").append(_replyTo);
+ }
+
+ if(_correlationId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("correlationId=").append(_correlationId);
+ }
+
+ if(_contentType != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("contentType=").append(_contentType);
+ }
+
+ if(_contentEncoding != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("contentEncoding=").append(_contentEncoding);
+ }
+
+ if(_absoluteExpiryTime != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("absoluteExpiryTime=").append(_absoluteExpiryTime);
+ }
+
+ if(_creationTime != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("creationTime=").append(_creationTime);
+ }
+
+ if(_groupId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("groupId=").append(_groupId);
+ }
+
+ if(_groupSequence != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("groupSequence=").append(_groupSequence);
+ }
+
+ if(_replyToGroupId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("replyToGroupId=").append(_replyToGroupId);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ public Binary encode(final SectionEncoder encoder)
+ {
+ encoder.reset();
+ encoder.encodeObject(this);
+ return encoder.getEncoding();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Received.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Received.java
new file mode 100644
index 0000000000..2e398063b8
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Received.java
@@ -0,0 +1,88 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Received
+ implements org.apache.qpid.amqp_1_0.type.DeliveryState
+ {
+
+
+ private UnsignedInteger _sectionNumber;
+
+ private UnsignedLong _sectionOffset;
+
+ public UnsignedInteger getSectionNumber()
+ {
+ return _sectionNumber;
+ }
+
+ public void setSectionNumber(UnsignedInteger sectionNumber)
+ {
+ _sectionNumber = sectionNumber;
+ }
+
+ public UnsignedLong getSectionOffset()
+ {
+ return _sectionOffset;
+ }
+
+ public void setSectionOffset(UnsignedLong sectionOffset)
+ {
+ _sectionOffset = sectionOffset;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Received{");
+ final int origLength = builder.length();
+
+ if(_sectionNumber != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("sectionNumber=").append(_sectionNumber);
+ }
+
+ if(_sectionOffset != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("sectionOffset=").append(_sectionOffset);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Rejected.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Rejected.java
new file mode 100644
index 0000000000..c895074131
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Rejected.java
@@ -0,0 +1,70 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Rejected
+ implements org.apache.qpid.amqp_1_0.type.DeliveryState, Outcome
+ {
+
+
+ private Error _error;
+
+ public Error getError()
+ {
+ return _error;
+ }
+
+ public void setError(Error error)
+ {
+ _error = error;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Rejected{");
+ final int origLength = builder.length();
+
+ if(_error != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("error=").append(_error);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Released.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Released.java
new file mode 100644
index 0000000000..ad54b6ff04
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Released.java
@@ -0,0 +1,46 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Released
+ implements org.apache.qpid.amqp_1_0.type.DeliveryState, Outcome
+ {
+
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Released{");
+ final int origLength = builder.length();
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Source.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Source.java
new file mode 100644
index 0000000000..b634542fd6
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Source.java
@@ -0,0 +1,280 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import java.util.Map;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Source
+ implements org.apache.qpid.amqp_1_0.type.Source
+ {
+
+
+ private String _address;
+
+ private TerminusDurability _durable;
+
+ private TerminusExpiryPolicy _expiryPolicy;
+
+ private UnsignedInteger _timeout;
+
+ private Boolean _dynamic;
+
+ private Map _dynamicNodeProperties;
+
+ private DistributionMode _distributionMode;
+
+ private Map _filter;
+
+ private Outcome _defaultOutcome;
+
+ private Symbol[] _outcomes;
+
+ private Symbol[] _capabilities;
+
+ public String getAddress()
+ {
+ return _address;
+ }
+
+ public void setAddress(String address)
+ {
+ _address = address;
+ }
+
+ public TerminusDurability getDurable()
+ {
+ return _durable;
+ }
+
+ public void setDurable(TerminusDurability durable)
+ {
+ _durable = durable;
+ }
+
+ public TerminusExpiryPolicy getExpiryPolicy()
+ {
+ return _expiryPolicy;
+ }
+
+ public void setExpiryPolicy(TerminusExpiryPolicy expiryPolicy)
+ {
+ _expiryPolicy = expiryPolicy;
+ }
+
+ public UnsignedInteger getTimeout()
+ {
+ return _timeout;
+ }
+
+ public void setTimeout(UnsignedInteger timeout)
+ {
+ _timeout = timeout;
+ }
+
+ public Boolean getDynamic()
+ {
+ return _dynamic;
+ }
+
+ public void setDynamic(Boolean dynamic)
+ {
+ _dynamic = dynamic;
+ }
+
+ public Map getDynamicNodeProperties()
+ {
+ return _dynamicNodeProperties;
+ }
+
+ public void setDynamicNodeProperties(Map dynamicNodeProperties)
+ {
+ _dynamicNodeProperties = dynamicNodeProperties;
+ }
+
+ public DistributionMode getDistributionMode()
+ {
+ return _distributionMode;
+ }
+
+ public void setDistributionMode(DistributionMode distributionMode)
+ {
+ _distributionMode = distributionMode;
+ }
+
+ public Map getFilter()
+ {
+ return _filter;
+ }
+
+ public void setFilter(Map filter)
+ {
+ _filter = filter;
+ }
+
+ public Outcome getDefaultOutcome()
+ {
+ return _defaultOutcome;
+ }
+
+ public void setDefaultOutcome(Outcome defaultOutcome)
+ {
+ _defaultOutcome = defaultOutcome;
+ }
+
+ public Symbol[] getOutcomes()
+ {
+ return _outcomes;
+ }
+
+ public void setOutcomes(Symbol[] outcomes)
+ {
+ _outcomes = outcomes;
+ }
+
+ public Symbol[] getCapabilities()
+ {
+ return _capabilities;
+ }
+
+ public void setCapabilities(Symbol[] capabilities)
+ {
+ _capabilities = capabilities;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Source{");
+ final int origLength = builder.length();
+
+ if(_address != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("address=").append(_address);
+ }
+
+ if(_durable != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("durable=").append(_durable);
+ }
+
+ if(_expiryPolicy != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("expiryPolicy=").append(_expiryPolicy);
+ }
+
+ if(_timeout != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("timeout=").append(_timeout);
+ }
+
+ if(_dynamic != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("dynamic=").append(_dynamic);
+ }
+
+ if(_dynamicNodeProperties != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("dynamicNodeProperties=").append(_dynamicNodeProperties);
+ }
+
+ if(_distributionMode != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("distributionMode=").append(_distributionMode);
+ }
+
+ if(_filter != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("filter=").append(_filter);
+ }
+
+ if(_defaultOutcome != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("defaultOutcome=").append(_defaultOutcome);
+ }
+
+ if(_outcomes != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("outcomes=").append(_outcomes);
+ }
+
+ if(_capabilities != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("capabilities=").append(_capabilities);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/StdDistMode.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/StdDistMode.java
new file mode 100644
index 0000000000..a3fba6fe46
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/StdDistMode.java
@@ -0,0 +1,95 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class StdDistMode
+ implements DistributionMode, RestrictedType<Symbol>
+
+ {
+
+
+
+ private final Symbol _val;
+
+
+ public static final StdDistMode MOVE = new StdDistMode(Symbol.valueOf("move"));
+
+ public static final StdDistMode COPY = new StdDistMode(Symbol.valueOf("copy"));
+
+
+
+ private StdDistMode(Symbol val)
+ {
+ _val = val;
+ }
+
+ public Symbol getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == MOVE)
+ {
+ return "move";
+ }
+
+ if(this == COPY)
+ {
+ return "copy";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static StdDistMode valueOf(Object obj)
+ {
+ Symbol val = (Symbol) obj;
+
+ if(MOVE._val.equals(val))
+ {
+ return MOVE;
+ }
+
+ if(COPY._val.equals(val))
+ {
+ return COPY;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Target.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Target.java
new file mode 100644
index 0000000000..ea9319d31d
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/Target.java
@@ -0,0 +1,196 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import java.util.Map;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Target
+ implements org.apache.qpid.amqp_1_0.type.Target
+ {
+
+
+ private String _address;
+
+ private TerminusDurability _durable;
+
+ private TerminusExpiryPolicy _expiryPolicy;
+
+ private UnsignedInteger _timeout;
+
+ private Boolean _dynamic;
+
+ private Map _dynamicNodeProperties;
+
+ private Symbol[] _capabilities;
+
+ public String getAddress()
+ {
+ return _address;
+ }
+
+ public void setAddress(String address)
+ {
+ _address = address;
+ }
+
+ public TerminusDurability getDurable()
+ {
+ return _durable;
+ }
+
+ public void setDurable(TerminusDurability durable)
+ {
+ _durable = durable;
+ }
+
+ public TerminusExpiryPolicy getExpiryPolicy()
+ {
+ return _expiryPolicy;
+ }
+
+ public void setExpiryPolicy(TerminusExpiryPolicy expiryPolicy)
+ {
+ _expiryPolicy = expiryPolicy;
+ }
+
+ public UnsignedInteger getTimeout()
+ {
+ return _timeout;
+ }
+
+ public void setTimeout(UnsignedInteger timeout)
+ {
+ _timeout = timeout;
+ }
+
+ public Boolean getDynamic()
+ {
+ return _dynamic;
+ }
+
+ public void setDynamic(Boolean dynamic)
+ {
+ _dynamic = dynamic;
+ }
+
+ public Map getDynamicNodeProperties()
+ {
+ return _dynamicNodeProperties;
+ }
+
+ public void setDynamicNodeProperties(Map dynamicNodeProperties)
+ {
+ _dynamicNodeProperties = dynamicNodeProperties;
+ }
+
+ public Symbol[] getCapabilities()
+ {
+ return _capabilities;
+ }
+
+ public void setCapabilities(Symbol[] capabilities)
+ {
+ _capabilities = capabilities;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Target{");
+ final int origLength = builder.length();
+
+ if(_address != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("address=").append(_address);
+ }
+
+ if(_durable != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("durable=").append(_durable);
+ }
+
+ if(_expiryPolicy != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("expiryPolicy=").append(_expiryPolicy);
+ }
+
+ if(_timeout != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("timeout=").append(_timeout);
+ }
+
+ if(_dynamic != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("dynamic=").append(_dynamic);
+ }
+
+ if(_dynamicNodeProperties != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("dynamicNodeProperties=").append(_dynamicNodeProperties);
+ }
+
+ if(_capabilities != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("capabilities=").append(_capabilities);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/TerminusDurability.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/TerminusDurability.java
new file mode 100644
index 0000000000..b08c416b4a
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/TerminusDurability.java
@@ -0,0 +1,107 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class TerminusDurability
+ implements RestrictedType<UnsignedInteger>
+
+ {
+
+
+
+ private final UnsignedInteger _val;
+
+
+ public static final TerminusDurability NONE = new TerminusDurability(UnsignedInteger.valueOf(0));
+
+ public static final TerminusDurability CONFIGURATION = new TerminusDurability(UnsignedInteger.valueOf(1));
+
+ public static final TerminusDurability UNSETTLED_STATE = new TerminusDurability(UnsignedInteger.valueOf(2));
+
+
+
+ private TerminusDurability(UnsignedInteger val)
+ {
+ _val = val;
+ }
+
+ public UnsignedInteger getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == NONE)
+ {
+ return "none";
+ }
+
+ if(this == CONFIGURATION)
+ {
+ return "configuration";
+ }
+
+ if(this == UNSETTLED_STATE)
+ {
+ return "unsettled-state";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static TerminusDurability valueOf(Object obj)
+ {
+ UnsignedInteger val = (UnsignedInteger) obj;
+
+ if(NONE._val.equals(val))
+ {
+ return NONE;
+ }
+
+ if(CONFIGURATION._val.equals(val))
+ {
+ return CONFIGURATION;
+ }
+
+ if(UNSETTLED_STATE._val.equals(val))
+ {
+ return UNSETTLED_STATE;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/TerminusExpiryPolicy.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/TerminusExpiryPolicy.java
new file mode 100644
index 0000000000..7ed2f84532
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/TerminusExpiryPolicy.java
@@ -0,0 +1,119 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class TerminusExpiryPolicy
+ implements RestrictedType<Symbol>
+
+ {
+
+
+
+ private final Symbol _val;
+
+
+ public static final TerminusExpiryPolicy LINK_DETACH = new TerminusExpiryPolicy(Symbol.valueOf("link-detach"));
+
+ public static final TerminusExpiryPolicy SESSION_END = new TerminusExpiryPolicy(Symbol.valueOf("session-end"));
+
+ public static final TerminusExpiryPolicy CONNECTION_CLOSE = new TerminusExpiryPolicy(Symbol.valueOf("connection-close"));
+
+ public static final TerminusExpiryPolicy NEVER = new TerminusExpiryPolicy(Symbol.valueOf("never"));
+
+
+
+ private TerminusExpiryPolicy(Symbol val)
+ {
+ _val = val;
+ }
+
+ public Symbol getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == LINK_DETACH)
+ {
+ return "link-detach";
+ }
+
+ if(this == SESSION_END)
+ {
+ return "session-end";
+ }
+
+ if(this == CONNECTION_CLOSE)
+ {
+ return "connection-close";
+ }
+
+ if(this == NEVER)
+ {
+ return "never";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static TerminusExpiryPolicy valueOf(Object obj)
+ {
+ Symbol val = (Symbol) obj;
+
+ if(LINK_DETACH._val.equals(val))
+ {
+ return LINK_DETACH;
+ }
+
+ if(SESSION_END._val.equals(val))
+ {
+ return SESSION_END;
+ }
+
+ if(CONNECTION_CLOSE._val.equals(val))
+ {
+ return CONNECTION_CLOSE;
+ }
+
+ if(NEVER._val.equals(val))
+ {
+ return NEVER;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AcceptedConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AcceptedConstructor.java
new file mode 100644
index 0000000000..8000853a4d
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AcceptedConstructor.java
@@ -0,0 +1,72 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Accepted;
+
+
+import java.util.List;
+
+public class AcceptedConstructor extends DescribedTypeConstructor<Accepted>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:accepted:list"),UnsignedLong.valueOf(0x0000000000000024L),
+ };
+
+ private static final AcceptedConstructor INSTANCE = new AcceptedConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Accepted construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Accepted obj = new Accepted();
+ int position = 0;
+ final int size = list.size();
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AcceptedWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AcceptedWriter.java
new file mode 100644
index 0000000000..862b678b59
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AcceptedWriter.java
@@ -0,0 +1,151 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.Accepted;
+
+public class AcceptedWriter extends AbstractDescribedTypeWriter<Accepted>
+{
+ private Accepted _value;
+ private int _count = -1;
+
+ public AcceptedWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Accepted value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000024L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ if(_count != 0)
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+ else
+ {
+ return new ListWriter.EmptyListValueWriter();
+ }
+
+ }
+
+ private class Writer extends AbstractListWriter<Accepted>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Accepted value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Accepted> FACTORY = new Factory<Accepted>()
+ {
+
+ public ValueWriter<Accepted> newInstance(Registry registry)
+ {
+ return new AcceptedWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Accepted.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpSequenceConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpSequenceConstructor.java
new file mode 100644
index 0000000000..7304a50b18
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpSequenceConstructor.java
@@ -0,0 +1,68 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.AmqpSequence;
+
+
+import java.util.List;
+
+public class AmqpSequenceConstructor extends DescribedTypeConstructor<AmqpSequence>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:amqp-sequence:list"),UnsignedLong.valueOf(0x0000000000000076L),
+ };
+
+ private static final AmqpSequenceConstructor INSTANCE = new AmqpSequenceConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+
+ public AmqpSequence construct(Object underlying)
+ {
+
+ if(underlying instanceof List)
+ {
+ return new AmqpSequence((List)underlying);
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpSequenceWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpSequenceWriter.java
new file mode 100644
index 0000000000..14c10ca5e6
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpSequenceWriter.java
@@ -0,0 +1,80 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.AmqpSequence;
+
+public class AmqpSequenceWriter extends AbstractDescribedTypeWriter<AmqpSequence>
+{
+ private AmqpSequence _value;
+
+
+
+ public AmqpSequenceWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final AmqpSequence value)
+ {
+ _value = value;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ }
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000076L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ return getRegistry().getValueWriter(_value);
+ }
+
+ private static Factory<AmqpSequence> FACTORY = new Factory<AmqpSequence>()
+ {
+
+ public ValueWriter<AmqpSequence> newInstance(Registry registry)
+ {
+ return new AmqpSequenceWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(AmqpSequence.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java
new file mode 100644
index 0000000000..2000880361
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java
@@ -0,0 +1,65 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.AmqpValue;
+
+public class AmqpValueConstructor extends DescribedTypeConstructor<AmqpValue>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:amqp-value:*"),UnsignedLong.valueOf(0x0000000000000077L),
+ };
+
+ private static final AmqpValueConstructor INSTANCE = new AmqpValueConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+
+ public AmqpValue construct(Object underlying)
+ {
+
+ if(underlying instanceof Object)
+ {
+ return new AmqpValue((Object)underlying);
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueWriter.java
new file mode 100644
index 0000000000..f38d2edb00
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueWriter.java
@@ -0,0 +1,80 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.AmqpValue;
+
+public class AmqpValueWriter extends AbstractDescribedTypeWriter<AmqpValue>
+{
+ private AmqpValue _value;
+
+
+
+ public AmqpValueWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final AmqpValue value)
+ {
+ _value = value;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ }
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000077L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ return getRegistry().getValueWriter(_value.getValue());
+ }
+
+ private static Factory<AmqpValue> FACTORY = new Factory<AmqpValue>()
+ {
+
+ public ValueWriter<AmqpValue> newInstance(Registry registry)
+ {
+ return new AmqpValueWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(AmqpValue.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ApplicationPropertiesConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ApplicationPropertiesConstructor.java
new file mode 100644
index 0000000000..f2bf26b7b4
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ApplicationPropertiesConstructor.java
@@ -0,0 +1,68 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties;
+
+
+import java.util.Map;
+
+public class ApplicationPropertiesConstructor extends DescribedTypeConstructor<ApplicationProperties>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:application-properties:map"),UnsignedLong.valueOf(0x0000000000000074L),
+ };
+
+ private static final ApplicationPropertiesConstructor INSTANCE = new ApplicationPropertiesConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+
+ public ApplicationProperties construct(Object underlying)
+ {
+
+ if(underlying instanceof Map)
+ {
+ return new ApplicationProperties((Map)underlying);
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ApplicationPropertiesWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ApplicationPropertiesWriter.java
new file mode 100644
index 0000000000..6fff917058
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ApplicationPropertiesWriter.java
@@ -0,0 +1,80 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties;
+
+public class ApplicationPropertiesWriter extends AbstractDescribedTypeWriter<ApplicationProperties>
+{
+ private ApplicationProperties _value;
+
+
+
+ public ApplicationPropertiesWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final ApplicationProperties value)
+ {
+ _value = value;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ }
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000074L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ return getRegistry().getValueWriter(_value.getValue());
+ }
+
+ private static Factory<ApplicationProperties> FACTORY = new Factory<ApplicationProperties>()
+ {
+
+ public ValueWriter<ApplicationProperties> newInstance(Registry registry)
+ {
+ return new ApplicationPropertiesWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(ApplicationProperties.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DataConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DataConstructor.java
new file mode 100644
index 0000000000..75e921c1b8
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DataConstructor.java
@@ -0,0 +1,65 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Data;
+
+public class DataConstructor extends DescribedTypeConstructor<Data>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:data:binary"),UnsignedLong.valueOf(0x0000000000000075L),
+ };
+
+ private static final DataConstructor INSTANCE = new DataConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+
+ public Data construct(Object underlying)
+ {
+
+ if(underlying instanceof Binary)
+ {
+ return new Data((Binary)underlying);
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DataWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DataWriter.java
new file mode 100644
index 0000000000..5ae6eecb43
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DataWriter.java
@@ -0,0 +1,80 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.Data;
+
+public class DataWriter extends AbstractDescribedTypeWriter<Data>
+{
+ private Data _value;
+
+
+
+ public DataWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Data value)
+ {
+ _value = value;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ }
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000075L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ return getRegistry().getValueWriter(_value.getValue());
+ }
+
+ private static Factory<Data> FACTORY = new Factory<Data>()
+ {
+
+ public ValueWriter<Data> newInstance(Registry registry)
+ {
+ return new DataWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Data.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnCloseConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnCloseConstructor.java
new file mode 100644
index 0000000000..31236a00cc
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnCloseConstructor.java
@@ -0,0 +1,72 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.DeleteOnClose;
+
+
+import java.util.List;
+
+public class DeleteOnCloseConstructor extends DescribedTypeConstructor<DeleteOnClose>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:delete-on-close:list"),UnsignedLong.valueOf(0x000000000000002bL),
+ };
+
+ private static final DeleteOnCloseConstructor INSTANCE = new DeleteOnCloseConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public DeleteOnClose construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ DeleteOnClose obj = new DeleteOnClose();
+ int position = 0;
+ final int size = list.size();
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnCloseWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnCloseWriter.java
new file mode 100644
index 0000000000..3ea43f2565
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnCloseWriter.java
@@ -0,0 +1,142 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.DeleteOnClose;
+
+public class DeleteOnCloseWriter extends AbstractDescribedTypeWriter<DeleteOnClose>
+{
+ private DeleteOnClose _value;
+ private int _count = -1;
+
+ public DeleteOnCloseWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final DeleteOnClose value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x000000000000002bL);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<DeleteOnClose>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final DeleteOnClose value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<DeleteOnClose> FACTORY = new Factory<DeleteOnClose>()
+ {
+
+ public ValueWriter<DeleteOnClose> newInstance(Registry registry)
+ {
+ return new DeleteOnCloseWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(DeleteOnClose.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksConstructor.java
new file mode 100644
index 0000000000..e5ea6e923e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksConstructor.java
@@ -0,0 +1,72 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.DeleteOnNoLinks;
+
+
+import java.util.List;
+
+public class DeleteOnNoLinksConstructor extends DescribedTypeConstructor<DeleteOnNoLinks>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:delete-on-no-links:list"),UnsignedLong.valueOf(0x000000000000002cL),
+ };
+
+ private static final DeleteOnNoLinksConstructor INSTANCE = new DeleteOnNoLinksConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public DeleteOnNoLinks construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ DeleteOnNoLinks obj = new DeleteOnNoLinks();
+ int position = 0;
+ final int size = list.size();
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksOrMessagesConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksOrMessagesConstructor.java
new file mode 100644
index 0000000000..c9bafe9550
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksOrMessagesConstructor.java
@@ -0,0 +1,72 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.DeleteOnNoLinksOrMessages;
+
+
+import java.util.List;
+
+public class DeleteOnNoLinksOrMessagesConstructor extends DescribedTypeConstructor<DeleteOnNoLinksOrMessages>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:delete-on-no-links-or-messages:list"),UnsignedLong.valueOf(0x000000000000002eL),
+ };
+
+ private static final DeleteOnNoLinksOrMessagesConstructor INSTANCE = new DeleteOnNoLinksOrMessagesConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public DeleteOnNoLinksOrMessages construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ DeleteOnNoLinksOrMessages obj = new DeleteOnNoLinksOrMessages();
+ int position = 0;
+ final int size = list.size();
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksOrMessagesWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksOrMessagesWriter.java
new file mode 100644
index 0000000000..e77c6a3be4
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksOrMessagesWriter.java
@@ -0,0 +1,142 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.DeleteOnNoLinksOrMessages;
+
+public class DeleteOnNoLinksOrMessagesWriter extends AbstractDescribedTypeWriter<DeleteOnNoLinksOrMessages>
+{
+ private DeleteOnNoLinksOrMessages _value;
+ private int _count = -1;
+
+ public DeleteOnNoLinksOrMessagesWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final DeleteOnNoLinksOrMessages value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x000000000000002eL);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<DeleteOnNoLinksOrMessages>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final DeleteOnNoLinksOrMessages value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<DeleteOnNoLinksOrMessages> FACTORY = new Factory<DeleteOnNoLinksOrMessages>()
+ {
+
+ public ValueWriter<DeleteOnNoLinksOrMessages> newInstance(Registry registry)
+ {
+ return new DeleteOnNoLinksOrMessagesWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(DeleteOnNoLinksOrMessages.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksWriter.java
new file mode 100644
index 0000000000..cbd5048ba1
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoLinksWriter.java
@@ -0,0 +1,142 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.DeleteOnNoLinks;
+
+public class DeleteOnNoLinksWriter extends AbstractDescribedTypeWriter<DeleteOnNoLinks>
+{
+ private DeleteOnNoLinks _value;
+ private int _count = -1;
+
+ public DeleteOnNoLinksWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final DeleteOnNoLinks value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x000000000000002cL);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<DeleteOnNoLinks>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final DeleteOnNoLinks value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<DeleteOnNoLinks> FACTORY = new Factory<DeleteOnNoLinks>()
+ {
+
+ public ValueWriter<DeleteOnNoLinks> newInstance(Registry registry)
+ {
+ return new DeleteOnNoLinksWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(DeleteOnNoLinks.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoMessagesConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoMessagesConstructor.java
new file mode 100644
index 0000000000..de8ce5b9a5
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoMessagesConstructor.java
@@ -0,0 +1,72 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.DeleteOnNoMessages;
+
+
+import java.util.List;
+
+public class DeleteOnNoMessagesConstructor extends DescribedTypeConstructor<DeleteOnNoMessages>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:delete-on-no-messages:list"),UnsignedLong.valueOf(0x000000000000002dL),
+ };
+
+ private static final DeleteOnNoMessagesConstructor INSTANCE = new DeleteOnNoMessagesConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public DeleteOnNoMessages construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ DeleteOnNoMessages obj = new DeleteOnNoMessages();
+ int position = 0;
+ final int size = list.size();
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoMessagesWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoMessagesWriter.java
new file mode 100644
index 0000000000..bd75ec9fa1
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeleteOnNoMessagesWriter.java
@@ -0,0 +1,142 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.DeleteOnNoMessages;
+
+public class DeleteOnNoMessagesWriter extends AbstractDescribedTypeWriter<DeleteOnNoMessages>
+{
+ private DeleteOnNoMessages _value;
+ private int _count = -1;
+
+ public DeleteOnNoMessagesWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final DeleteOnNoMessages value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x000000000000002dL);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<DeleteOnNoMessages>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final DeleteOnNoMessages value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<DeleteOnNoMessages> FACTORY = new Factory<DeleteOnNoMessages>()
+ {
+
+ public ValueWriter<DeleteOnNoMessages> newInstance(Registry registry)
+ {
+ return new DeleteOnNoMessagesWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(DeleteOnNoMessages.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeliveryAnnotationsConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeliveryAnnotationsConstructor.java
new file mode 100644
index 0000000000..3596a1f722
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeliveryAnnotationsConstructor.java
@@ -0,0 +1,68 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.DeliveryAnnotations;
+
+
+import java.util.Map;
+
+public class DeliveryAnnotationsConstructor extends DescribedTypeConstructor<DeliveryAnnotations>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:delivery-annotations:map"),UnsignedLong.valueOf(0x0000000000000071L),
+ };
+
+ private static final DeliveryAnnotationsConstructor INSTANCE = new DeliveryAnnotationsConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+
+ public DeliveryAnnotations construct(Object underlying)
+ {
+
+ if(underlying instanceof Map)
+ {
+ return new DeliveryAnnotations((Map)underlying);
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeliveryAnnotationsWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeliveryAnnotationsWriter.java
new file mode 100644
index 0000000000..e22c26b290
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/DeliveryAnnotationsWriter.java
@@ -0,0 +1,80 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.DeliveryAnnotations;
+
+public class DeliveryAnnotationsWriter extends AbstractDescribedTypeWriter<DeliveryAnnotations>
+{
+ private DeliveryAnnotations _value;
+
+
+
+ public DeliveryAnnotationsWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final DeliveryAnnotations value)
+ {
+ _value = value;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ }
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000071L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ return getRegistry().getValueWriter(_value);
+ }
+
+ private static Factory<DeliveryAnnotations> FACTORY = new Factory<DeliveryAnnotations>()
+ {
+
+ public ValueWriter<DeliveryAnnotations> newInstance(Registry registry)
+ {
+ return new DeliveryAnnotationsWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(DeliveryAnnotations.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ExactSubjectFilterConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ExactSubjectFilterConstructor.java
new file mode 100644
index 0000000000..48bec31797
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ExactSubjectFilterConstructor.java
@@ -0,0 +1,64 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.messaging.ExactSubjectFilter;
+
+public class ExactSubjectFilterConstructor extends DescribedTypeConstructor<ExactSubjectFilter>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:exact-subject-filter:string"),
+ };
+
+ private static final ExactSubjectFilterConstructor INSTANCE = new ExactSubjectFilterConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+
+ public ExactSubjectFilter construct(Object underlying)
+ {
+
+ if(underlying instanceof String)
+ {
+ return new ExactSubjectFilter((String)underlying);
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ExactSubjectFilterWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ExactSubjectFilterWriter.java
new file mode 100644
index 0000000000..75e2df4b65
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ExactSubjectFilterWriter.java
@@ -0,0 +1,79 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.messaging.ExactSubjectFilter;
+
+public class ExactSubjectFilterWriter extends AbstractDescribedTypeWriter<ExactSubjectFilter>
+{
+ private ExactSubjectFilter _value;
+
+
+
+ public ExactSubjectFilterWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final ExactSubjectFilter value)
+ {
+ _value = value;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ }
+
+ protected Object getDescriptor()
+ {
+ return Symbol.valueOf("amqp:exact-subject-filter:string");
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ return getRegistry().getValueWriter(_value.getValue());
+ }
+
+ private static Factory<ExactSubjectFilter> FACTORY = new Factory<ExactSubjectFilter>()
+ {
+
+ public ValueWriter<ExactSubjectFilter> newInstance(Registry registry)
+ {
+ return new ExactSubjectFilterWriter(registry);
+ }
+ };
+
+ public static void register(Registry registry)
+ {
+ registry.register(ExactSubjectFilter.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/FooterConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/FooterConstructor.java
new file mode 100644
index 0000000000..ed92c9f8f8
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/FooterConstructor.java
@@ -0,0 +1,68 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Footer;
+
+
+import java.util.Map;
+
+public class FooterConstructor extends DescribedTypeConstructor<Footer>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:footer:map"),UnsignedLong.valueOf(0x0000000000000078L),
+ };
+
+ private static final FooterConstructor INSTANCE = new FooterConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+
+ public Footer construct(Object underlying)
+ {
+
+ if(underlying instanceof Map)
+ {
+ return new Footer((Map)underlying);
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/FooterWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/FooterWriter.java
new file mode 100644
index 0000000000..3ffde7c663
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/FooterWriter.java
@@ -0,0 +1,80 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.Footer;
+
+public class FooterWriter extends AbstractDescribedTypeWriter<Footer>
+{
+ private Footer _value;
+
+
+
+ public FooterWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Footer value)
+ {
+ _value = value;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ }
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000078L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ return getRegistry().getValueWriter(_value.getValue());
+ }
+
+ private static Factory<Footer> FACTORY = new Factory<Footer>()
+ {
+
+ public ValueWriter<Footer> newInstance(Registry registry)
+ {
+ return new FooterWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Footer.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/HeaderConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/HeaderConstructor.java
new file mode 100644
index 0000000000..5a1b4ceb1b
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/HeaderConstructor.java
@@ -0,0 +1,207 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Header;
+
+
+import java.util.List;
+
+public class HeaderConstructor extends DescribedTypeConstructor<Header>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:header:list"),UnsignedLong.valueOf(0x0000000000000070L),
+ };
+
+ private static final HeaderConstructor INSTANCE = new HeaderConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Header construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Header obj = new Header();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDurable( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setPriority( (UnsignedByte) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setTtl( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setFirstAcquirer( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDeliveryCount( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/HeaderWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/HeaderWriter.java
new file mode 100644
index 0000000000..20605293e1
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/HeaderWriter.java
@@ -0,0 +1,182 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.Header;
+
+public class HeaderWriter extends AbstractDescribedTypeWriter<Header>
+{
+ private Header _value;
+ private int _count = -1;
+
+ public HeaderWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Header value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getDeliveryCount() != null)
+ {
+ return 5;
+ }
+
+ if( _value.getFirstAcquirer() != null)
+ {
+ return 4;
+ }
+
+ if( _value.getTtl() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getPriority() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getDurable() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000070L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Header>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Header value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getDurable();
+
+ case 1:
+ return _value.getPriority();
+
+ case 2:
+ return _value.getTtl();
+
+ case 3:
+ return _value.getFirstAcquirer();
+
+ case 4:
+ return _value.getDeliveryCount();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Header> FACTORY = new Factory<Header>()
+ {
+
+ public ValueWriter<Header> newInstance(Registry registry)
+ {
+ return new HeaderWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Header.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/JMSSelectorFilterConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/JMSSelectorFilterConstructor.java
new file mode 100644
index 0000000000..e222c3371e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/JMSSelectorFilterConstructor.java
@@ -0,0 +1,64 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.messaging.JMSSelectorFilter;
+
+public class JMSSelectorFilterConstructor extends DescribedTypeConstructor<JMSSelectorFilter>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:jms-selector-filter:string"),
+ };
+
+ private static final JMSSelectorFilterConstructor INSTANCE = new JMSSelectorFilterConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+
+ public JMSSelectorFilter construct(Object underlying)
+ {
+
+ if(underlying instanceof String)
+ {
+ return new JMSSelectorFilter((String)underlying);
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/JMSSelectorFilterWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/JMSSelectorFilterWriter.java
new file mode 100644
index 0000000000..4e2b9f8d24
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/JMSSelectorFilterWriter.java
@@ -0,0 +1,80 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.messaging.JMSSelectorFilter;
+import org.apache.qpid.amqp_1_0.type.messaging.MatchingSubjectFilter;
+
+public class JMSSelectorFilterWriter extends AbstractDescribedTypeWriter<JMSSelectorFilter>
+{
+ private JMSSelectorFilter _value;
+
+
+
+ public JMSSelectorFilterWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final JMSSelectorFilter value)
+ {
+ _value = value;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ }
+
+ protected Object getDescriptor()
+ {
+ return Symbol.valueOf("amqp:jms-selector-filter:string");
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ return getRegistry().getValueWriter(_value.getValue());
+ }
+
+ private static Factory<JMSSelectorFilter> FACTORY = new Factory<JMSSelectorFilter>()
+ {
+
+ public ValueWriter<JMSSelectorFilter> newInstance(Registry registry)
+ {
+ return new JMSSelectorFilterWriter(registry);
+ }
+ };
+
+ public static void register(Registry registry)
+ {
+ registry.register(JMSSelectorFilter.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MatchingSubjectFilterConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MatchingSubjectFilterConstructor.java
new file mode 100644
index 0000000000..d9cdc7bbb9
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MatchingSubjectFilterConstructor.java
@@ -0,0 +1,64 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.messaging.MatchingSubjectFilter;
+
+public class MatchingSubjectFilterConstructor extends DescribedTypeConstructor<MatchingSubjectFilter>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:matching-subject-filter:string"),
+ };
+
+ private static final MatchingSubjectFilterConstructor INSTANCE = new MatchingSubjectFilterConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+
+ public MatchingSubjectFilter construct(Object underlying)
+ {
+
+ if(underlying instanceof String)
+ {
+ return new MatchingSubjectFilter((String)underlying);
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MatchingSubjectFilterWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MatchingSubjectFilterWriter.java
new file mode 100644
index 0000000000..29fd304831
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MatchingSubjectFilterWriter.java
@@ -0,0 +1,79 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.messaging.MatchingSubjectFilter;
+
+public class MatchingSubjectFilterWriter extends AbstractDescribedTypeWriter<MatchingSubjectFilter>
+{
+ private MatchingSubjectFilter _value;
+
+
+
+ public MatchingSubjectFilterWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final MatchingSubjectFilter value)
+ {
+ _value = value;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ }
+
+ protected Object getDescriptor()
+ {
+ return Symbol.valueOf("amqp:matching-subject-filter:string");
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ return getRegistry().getValueWriter(_value.getValue());
+ }
+
+ private static Factory<MatchingSubjectFilter> FACTORY = new Factory<MatchingSubjectFilter>()
+ {
+
+ public ValueWriter<MatchingSubjectFilter> newInstance(Registry registry)
+ {
+ return new MatchingSubjectFilterWriter(registry);
+ }
+ };
+
+ public static void register(Registry registry)
+ {
+ registry.register(MatchingSubjectFilter.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MessageAnnotationsConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MessageAnnotationsConstructor.java
new file mode 100644
index 0000000000..b2f2ec5739
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MessageAnnotationsConstructor.java
@@ -0,0 +1,68 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.MessageAnnotations;
+
+
+import java.util.Map;
+
+public class MessageAnnotationsConstructor extends DescribedTypeConstructor<MessageAnnotations>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:message-annotations:map"),UnsignedLong.valueOf(0x0000000000000072L),
+ };
+
+ private static final MessageAnnotationsConstructor INSTANCE = new MessageAnnotationsConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+
+ public MessageAnnotations construct(Object underlying)
+ {
+
+ if(underlying instanceof Map)
+ {
+ return new MessageAnnotations((Map)underlying);
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MessageAnnotationsWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MessageAnnotationsWriter.java
new file mode 100644
index 0000000000..400449c381
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/MessageAnnotationsWriter.java
@@ -0,0 +1,80 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.MessageAnnotations;
+
+public class MessageAnnotationsWriter extends AbstractDescribedTypeWriter<MessageAnnotations>
+{
+ private MessageAnnotations _value;
+
+
+
+ public MessageAnnotationsWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final MessageAnnotations value)
+ {
+ _value = value;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ }
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000072L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ return getRegistry().getValueWriter(_value.getValue());
+ }
+
+ private static Factory<MessageAnnotations> FACTORY = new Factory<MessageAnnotations>()
+ {
+
+ public ValueWriter<MessageAnnotations> newInstance(Registry registry)
+ {
+ return new MessageAnnotationsWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(MessageAnnotations.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ModifiedConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ModifiedConstructor.java
new file mode 100644
index 0000000000..fb78708d7d
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ModifiedConstructor.java
@@ -0,0 +1,154 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Modified;
+
+
+import java.util.List;
+import java.util.Map;
+
+public class ModifiedConstructor extends DescribedTypeConstructor<Modified>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:modified:list"),UnsignedLong.valueOf(0x0000000000000027L),
+ };
+
+ private static final ModifiedConstructor INSTANCE = new ModifiedConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Modified construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Modified obj = new Modified();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDeliveryFailed( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setUndeliverableHere( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setMessageAnnotations( (Map) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ModifiedWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ModifiedWriter.java
new file mode 100644
index 0000000000..df3063ee52
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ModifiedWriter.java
@@ -0,0 +1,166 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.Modified;
+
+public class ModifiedWriter extends AbstractDescribedTypeWriter<Modified>
+{
+ private Modified _value;
+ private int _count = -1;
+
+ public ModifiedWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Modified value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getMessageAnnotations() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getUndeliverableHere() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getDeliveryFailed() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000027L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Modified>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Modified value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getDeliveryFailed();
+
+ case 1:
+ return _value.getUndeliverableHere();
+
+ case 2:
+ return _value.getMessageAnnotations();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Modified> FACTORY = new Factory<Modified>()
+ {
+
+ public ValueWriter<Modified> newInstance(Registry registry)
+ {
+ return new ModifiedWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Modified.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/NoLocalFilterConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/NoLocalFilterConstructor.java
new file mode 100644
index 0000000000..2bcf44e6d5
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/NoLocalFilterConstructor.java
@@ -0,0 +1,56 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.messaging.JMSSelectorFilter;
+import org.apache.qpid.amqp_1_0.type.messaging.NoLocalFilter;
+
+public class NoLocalFilterConstructor extends DescribedTypeConstructor<NoLocalFilter>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:no-local-filter:list"),
+ };
+
+ private static final NoLocalFilterConstructor INSTANCE = new NoLocalFilterConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+
+ public NoLocalFilter construct(Object underlying)
+ {
+ return NoLocalFilter.INSTANCE;
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/NoLocalFilterWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/NoLocalFilterWriter.java
new file mode 100644
index 0000000000..1e7dce7600
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/NoLocalFilterWriter.java
@@ -0,0 +1,89 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.ListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+import org.apache.qpid.amqp_1_0.type.Symbol;
+import org.apache.qpid.amqp_1_0.type.messaging.NoLocalFilter;
+
+public class NoLocalFilterWriter extends AbstractDescribedTypeWriter<NoLocalFilter>
+{
+ private NoLocalFilter _value;
+ private int _count = -1;
+
+ public NoLocalFilterWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final NoLocalFilter value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return Symbol.valueOf("amqp:no-local-filter:list");
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ return new ListWriter.EmptyListValueWriter();
+ }
+
+ private static Factory<NoLocalFilter> FACTORY = new Factory<NoLocalFilter>()
+ {
+
+ public ValueWriter<NoLocalFilter> newInstance(Registry registry)
+ {
+ return new NoLocalFilterWriter(registry);
+ }
+ };
+
+ public static void register(Registry registry)
+ {
+ registry.register(NoLocalFilter.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/PropertiesConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/PropertiesConstructor.java
new file mode 100644
index 0000000000..98b911f341
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/PropertiesConstructor.java
@@ -0,0 +1,424 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Properties;
+
+
+import java.util.List;
+import java.util.Date;
+
+public class PropertiesConstructor extends DescribedTypeConstructor<Properties>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:properties:list"),UnsignedLong.valueOf(0x0000000000000073L),
+ };
+
+ private static final PropertiesConstructor INSTANCE = new PropertiesConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Properties construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Properties obj = new Properties();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setMessageId( val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setUserId( (Binary) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setTo( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setSubject( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setReplyTo( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setCorrelationId( val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setContentType( (Symbol) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setContentEncoding( (Symbol) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setAbsoluteExpiryTime( (Date) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setCreationTime( (Date) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setGroupId( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setGroupSequence( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setReplyToGroupId( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/PropertiesWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/PropertiesWriter.java
new file mode 100644
index 0000000000..021338bcfa
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/PropertiesWriter.java
@@ -0,0 +1,246 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.Properties;
+
+public class PropertiesWriter extends AbstractDescribedTypeWriter<Properties>
+{
+ private Properties _value;
+ private int _count = -1;
+
+ public PropertiesWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Properties value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getReplyToGroupId() != null)
+ {
+ return 13;
+ }
+
+ if( _value.getGroupSequence() != null)
+ {
+ return 12;
+ }
+
+ if( _value.getGroupId() != null)
+ {
+ return 11;
+ }
+
+ if( _value.getCreationTime() != null)
+ {
+ return 10;
+ }
+
+ if( _value.getAbsoluteExpiryTime() != null)
+ {
+ return 9;
+ }
+
+ if( _value.getContentEncoding() != null)
+ {
+ return 8;
+ }
+
+ if( _value.getContentType() != null)
+ {
+ return 7;
+ }
+
+ if( _value.getCorrelationId() != null)
+ {
+ return 6;
+ }
+
+ if( _value.getReplyTo() != null)
+ {
+ return 5;
+ }
+
+ if( _value.getSubject() != null)
+ {
+ return 4;
+ }
+
+ if( _value.getTo() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getUserId() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getMessageId() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000073L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Properties>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Properties value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getMessageId();
+
+ case 1:
+ return _value.getUserId();
+
+ case 2:
+ return _value.getTo();
+
+ case 3:
+ return _value.getSubject();
+
+ case 4:
+ return _value.getReplyTo();
+
+ case 5:
+ return _value.getCorrelationId();
+
+ case 6:
+ return _value.getContentType();
+
+ case 7:
+ return _value.getContentEncoding();
+
+ case 8:
+ return _value.getAbsoluteExpiryTime();
+
+ case 9:
+ return _value.getCreationTime();
+
+ case 10:
+ return _value.getGroupId();
+
+ case 11:
+ return _value.getGroupSequence();
+
+ case 12:
+ return _value.getReplyToGroupId();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Properties> FACTORY = new Factory<Properties>()
+ {
+
+ public ValueWriter<Properties> newInstance(Registry registry)
+ {
+ return new PropertiesWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Properties.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReceivedConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReceivedConstructor.java
new file mode 100644
index 0000000000..a515379d33
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReceivedConstructor.java
@@ -0,0 +1,126 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Received;
+
+
+import java.util.List;
+
+public class ReceivedConstructor extends DescribedTypeConstructor<Received>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:received:list"),UnsignedLong.valueOf(0x0000000000000023L),
+ };
+
+ private static final ReceivedConstructor INSTANCE = new ReceivedConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Received construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Received obj = new Received();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setSectionNumber( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setSectionOffset( (UnsignedLong) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReceivedWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReceivedWriter.java
new file mode 100644
index 0000000000..76af939db5
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReceivedWriter.java
@@ -0,0 +1,158 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.Received;
+
+public class ReceivedWriter extends AbstractDescribedTypeWriter<Received>
+{
+ private Received _value;
+ private int _count = -1;
+
+ public ReceivedWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Received value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getSectionOffset() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getSectionNumber() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000023L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Received>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Received value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getSectionNumber();
+
+ case 1:
+ return _value.getSectionOffset();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Received> FACTORY = new Factory<Received>()
+ {
+
+ public ValueWriter<Received> newInstance(Registry registry)
+ {
+ return new ReceivedWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Received.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/RejectedConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/RejectedConstructor.java
new file mode 100644
index 0000000000..eb923c535d
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/RejectedConstructor.java
@@ -0,0 +1,99 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Rejected;
+
+
+import java.util.List;
+
+public class RejectedConstructor extends DescribedTypeConstructor<Rejected>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:rejected:list"),UnsignedLong.valueOf(0x0000000000000025L),
+ };
+
+ private static final RejectedConstructor INSTANCE = new RejectedConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Rejected construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Rejected obj = new Rejected();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setError( (org.apache.qpid.amqp_1_0.type.transport.Error) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/RejectedWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/RejectedWriter.java
new file mode 100644
index 0000000000..6e24ac2972
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/RejectedWriter.java
@@ -0,0 +1,150 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.Rejected;
+
+public class RejectedWriter extends AbstractDescribedTypeWriter<Rejected>
+{
+ private Rejected _value;
+ private int _count = -1;
+
+ public RejectedWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Rejected value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getError() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000025L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Rejected>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Rejected value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getError();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Rejected> FACTORY = new Factory<Rejected>()
+ {
+
+ public ValueWriter<Rejected> newInstance(Registry registry)
+ {
+ return new RejectedWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Rejected.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReleasedConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReleasedConstructor.java
new file mode 100644
index 0000000000..534b81efd7
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReleasedConstructor.java
@@ -0,0 +1,72 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Released;
+
+
+import java.util.List;
+
+public class ReleasedConstructor extends DescribedTypeConstructor<Released>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:released:list"),UnsignedLong.valueOf(0x0000000000000026L),
+ };
+
+ private static final ReleasedConstructor INSTANCE = new ReleasedConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Released construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Released obj = new Released();
+ int position = 0;
+ final int size = list.size();
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReleasedWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReleasedWriter.java
new file mode 100644
index 0000000000..cad602e0a6
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/ReleasedWriter.java
@@ -0,0 +1,142 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.Released;
+
+public class ReleasedWriter extends AbstractDescribedTypeWriter<Released>
+{
+ private Released _value;
+ private int _count = -1;
+
+ public ReleasedWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Released value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000026L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Released>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Released value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Released> FACTORY = new Factory<Released>()
+ {
+
+ public ValueWriter<Released> newInstance(Registry registry)
+ {
+ return new ReleasedWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Released.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/SourceConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/SourceConstructor.java
new file mode 100644
index 0000000000..764fa222ee
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/SourceConstructor.java
@@ -0,0 +1,384 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Source;
+
+
+import java.util.List;
+import java.util.Map;
+
+public class SourceConstructor extends DescribedTypeConstructor<Source>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:source:list"),UnsignedLong.valueOf(0x0000000000000028L),
+ };
+
+ private static final SourceConstructor INSTANCE = new SourceConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Source construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Source obj = new Source();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setAddress( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDurable( TerminusDurability.valueOf( val ) );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setExpiryPolicy( TerminusExpiryPolicy.valueOf( val ) );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setTimeout( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDynamic( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDynamicNodeProperties( (Map) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDistributionMode( (DistributionMode) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setFilter( (Map) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDefaultOutcome( (Outcome) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setOutcomes( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setOutcomes( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setCapabilities( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setCapabilities( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/SourceWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/SourceWriter.java
new file mode 100644
index 0000000000..7fc8cfb35e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/SourceWriter.java
@@ -0,0 +1,230 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.Source;
+
+public class SourceWriter extends AbstractDescribedTypeWriter<Source>
+{
+ private Source _value;
+ private int _count = -1;
+
+ public SourceWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Source value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getCapabilities() != null)
+ {
+ return 11;
+ }
+
+ if( _value.getOutcomes() != null)
+ {
+ return 10;
+ }
+
+ if( _value.getDefaultOutcome() != null)
+ {
+ return 9;
+ }
+
+ if( _value.getFilter() != null)
+ {
+ return 8;
+ }
+
+ if( _value.getDistributionMode() != null)
+ {
+ return 7;
+ }
+
+ if( _value.getDynamicNodeProperties() != null)
+ {
+ return 6;
+ }
+
+ if( _value.getDynamic() != null)
+ {
+ return 5;
+ }
+
+ if( _value.getTimeout() != null)
+ {
+ return 4;
+ }
+
+ if( _value.getExpiryPolicy() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getDurable() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getAddress() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000028L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Source>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Source value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getAddress();
+
+ case 1:
+ return _value.getDurable();
+
+ case 2:
+ return _value.getExpiryPolicy();
+
+ case 3:
+ return _value.getTimeout();
+
+ case 4:
+ return _value.getDynamic();
+
+ case 5:
+ return _value.getDynamicNodeProperties();
+
+ case 6:
+ return _value.getDistributionMode();
+
+ case 7:
+ return _value.getFilter();
+
+ case 8:
+ return _value.getDefaultOutcome();
+
+ case 9:
+ return _value.getOutcomes();
+
+ case 10:
+ return _value.getCapabilities();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Source> FACTORY = new Factory<Source>()
+ {
+
+ public ValueWriter<Source> newInstance(Registry registry)
+ {
+ return new SourceWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Source.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/TargetConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/TargetConstructor.java
new file mode 100644
index 0000000000..1c89574273
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/TargetConstructor.java
@@ -0,0 +1,269 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.messaging.*;
+import org.apache.qpid.amqp_1_0.type.messaging.Target;
+
+
+import java.util.List;
+import java.util.Map;
+
+public class TargetConstructor extends DescribedTypeConstructor<Target>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:target:list"),UnsignedLong.valueOf(0x0000000000000029L),
+ };
+
+ private static final TargetConstructor INSTANCE = new TargetConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Target construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Target obj = new Target();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setAddress( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDurable( TerminusDurability.valueOf( val ) );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setExpiryPolicy( TerminusExpiryPolicy.valueOf( val ) );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setTimeout( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDynamic( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDynamicNodeProperties( (Map) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setCapabilities( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setCapabilities( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/TargetWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/TargetWriter.java
new file mode 100644
index 0000000000..970a9f4020
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/TargetWriter.java
@@ -0,0 +1,198 @@
+
+/*
+*
+* 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.amqp_1_0.type.messaging.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.messaging.Target;
+
+public class TargetWriter extends AbstractDescribedTypeWriter<Target>
+{
+ private Target _value;
+ private int _count = -1;
+
+ public TargetWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Target value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getCapabilities() != null)
+ {
+ return 7;
+ }
+
+ if( _value.getDynamicNodeProperties() != null)
+ {
+ return 6;
+ }
+
+ if( _value.getDynamic() != null)
+ {
+ return 5;
+ }
+
+ if( _value.getTimeout() != null)
+ {
+ return 4;
+ }
+
+ if( _value.getExpiryPolicy() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getDurable() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getAddress() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000029L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Target>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Target value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getAddress();
+
+ case 1:
+ return _value.getDurable();
+
+ case 2:
+ return _value.getExpiryPolicy();
+
+ case 3:
+ return _value.getTimeout();
+
+ case 4:
+ return _value.getDynamic();
+
+ case 5:
+ return _value.getDynamicNodeProperties();
+
+ case 6:
+ return _value.getCapabilities();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Target> FACTORY = new Factory<Target>()
+ {
+
+ public ValueWriter<Target> newInstance(Registry registry)
+ {
+ return new TargetWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Target.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslChallenge.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslChallenge.java
new file mode 100644
index 0000000000..081c00af29
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslChallenge.java
@@ -0,0 +1,74 @@
+
+/*
+*
+* 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.amqp_1_0.type.security;
+
+
+import org.apache.qpid.amqp_1_0.transport.SASLEndpoint;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class SaslChallenge
+ implements SaslFrameBody
+ {
+
+
+ private Binary _challenge;
+
+ public Binary getChallenge()
+ {
+ return _challenge;
+ }
+
+ public void setChallenge(Binary challenge)
+ {
+ _challenge = challenge;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("SaslChallenge{");
+ final int origLength = builder.length();
+
+ if(_challenge != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("challenge=").append(_challenge);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(SASLEndpoint conn)
+ {
+ conn.receiveSaslChallenge(this);
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslCode.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslCode.java
new file mode 100644
index 0000000000..59a24070ef
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslCode.java
@@ -0,0 +1,131 @@
+
+/*
+*
+* 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.amqp_1_0.type.security;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class SaslCode
+ implements RestrictedType<UnsignedByte>
+
+ {
+
+
+
+ private final UnsignedByte _val;
+
+
+ public static final SaslCode OK = new SaslCode(UnsignedByte.valueOf((byte) 0));
+
+ public static final SaslCode AUTH = new SaslCode(UnsignedByte.valueOf((byte) 1));
+
+ public static final SaslCode SYS = new SaslCode(UnsignedByte.valueOf((byte) 2));
+
+ public static final SaslCode SYS_PERM = new SaslCode(UnsignedByte.valueOf((byte) 3));
+
+ public static final SaslCode SYS_TEMP = new SaslCode(UnsignedByte.valueOf((byte) 4));
+
+
+
+ private SaslCode(UnsignedByte val)
+ {
+ _val = val;
+ }
+
+ public UnsignedByte getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == OK)
+ {
+ return "ok";
+ }
+
+ if(this == AUTH)
+ {
+ return "auth";
+ }
+
+ if(this == SYS)
+ {
+ return "sys";
+ }
+
+ if(this == SYS_PERM)
+ {
+ return "sys-perm";
+ }
+
+ if(this == SYS_TEMP)
+ {
+ return "sys-temp";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static SaslCode valueOf(Object obj)
+ {
+ UnsignedByte val = (UnsignedByte) obj;
+
+ if(OK._val.equals(val))
+ {
+ return OK;
+ }
+
+ if(AUTH._val.equals(val))
+ {
+ return AUTH;
+ }
+
+ if(SYS._val.equals(val))
+ {
+ return SYS;
+ }
+
+ if(SYS_PERM._val.equals(val))
+ {
+ return SYS_PERM;
+ }
+
+ if(SYS_TEMP._val.equals(val))
+ {
+ return SYS_TEMP;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslInit.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslInit.java
new file mode 100644
index 0000000000..9b789a4e17
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslInit.java
@@ -0,0 +1,116 @@
+
+/*
+*
+* 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.amqp_1_0.type.security;
+
+
+import org.apache.qpid.amqp_1_0.transport.SASLEndpoint;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class SaslInit
+ implements SaslFrameBody
+ {
+
+
+ private Symbol _mechanism;
+
+ private Binary _initialResponse;
+
+ private String _hostname;
+
+ public Symbol getMechanism()
+ {
+ return _mechanism;
+ }
+
+ public void setMechanism(Symbol mechanism)
+ {
+ _mechanism = mechanism;
+ }
+
+ public Binary getInitialResponse()
+ {
+ return _initialResponse;
+ }
+
+ public void setInitialResponse(Binary initialResponse)
+ {
+ _initialResponse = initialResponse;
+ }
+
+ public String getHostname()
+ {
+ return _hostname;
+ }
+
+ public void setHostname(String hostname)
+ {
+ _hostname = hostname;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("SaslInit{");
+ final int origLength = builder.length();
+
+ if(_mechanism != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("mechanism=").append(_mechanism);
+ }
+
+ if(_initialResponse != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("initialResponse=").append(_initialResponse);
+ }
+
+ if(_hostname != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("hostname=").append(_hostname);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(SASLEndpoint conn)
+ {
+ conn.receiveSaslInit(this);
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslMechanisms.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslMechanisms.java
new file mode 100644
index 0000000000..7f4775c3ae
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslMechanisms.java
@@ -0,0 +1,74 @@
+
+/*
+*
+* 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.amqp_1_0.type.security;
+
+
+import org.apache.qpid.amqp_1_0.transport.SASLEndpoint;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class SaslMechanisms
+ implements SaslFrameBody
+ {
+
+
+ private Symbol[] _saslServerMechanisms;
+
+ public Symbol[] getSaslServerMechanisms()
+ {
+ return _saslServerMechanisms;
+ }
+
+ public void setSaslServerMechanisms(Symbol[] saslServerMechanisms)
+ {
+ _saslServerMechanisms = saslServerMechanisms;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("SaslMechanisms{");
+ final int origLength = builder.length();
+
+ if(_saslServerMechanisms != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("saslServerMechanisms=").append(_saslServerMechanisms);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(SASLEndpoint conn)
+ {
+ conn.receiveSaslMechanisms(this);
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslOutcome.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslOutcome.java
new file mode 100644
index 0000000000..02d707d311
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslOutcome.java
@@ -0,0 +1,95 @@
+
+/*
+*
+* 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.amqp_1_0.type.security;
+
+
+import org.apache.qpid.amqp_1_0.transport.SASLEndpoint;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class SaslOutcome
+ implements SaslFrameBody
+ {
+
+
+ private SaslCode _code;
+
+ private Binary _additionalData;
+
+ public SaslCode getCode()
+ {
+ return _code;
+ }
+
+ public void setCode(SaslCode code)
+ {
+ _code = code;
+ }
+
+ public Binary getAdditionalData()
+ {
+ return _additionalData;
+ }
+
+ public void setAdditionalData(Binary additionalData)
+ {
+ _additionalData = additionalData;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("SaslOutcome{");
+ final int origLength = builder.length();
+
+ if(_code != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("code=").append(_code);
+ }
+
+ if(_additionalData != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("additionalData=").append(_additionalData);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(SASLEndpoint conn)
+ {
+ conn.receiveSaslOutcome(this);
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslResponse.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslResponse.java
new file mode 100644
index 0000000000..7ffcaba7e9
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/SaslResponse.java
@@ -0,0 +1,74 @@
+
+/*
+*
+* 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.amqp_1_0.type.security;
+
+
+import org.apache.qpid.amqp_1_0.transport.SASLEndpoint;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class SaslResponse
+ implements SaslFrameBody
+ {
+
+
+ private Binary _response;
+
+ public Binary getResponse()
+ {
+ return _response;
+ }
+
+ public void setResponse(Binary response)
+ {
+ _response = response;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("SaslResponse{");
+ final int origLength = builder.length();
+
+ if(_response != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("response=").append(_response);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(SASLEndpoint conn)
+ {
+ conn.receiveSaslResponse(this);
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslChallengeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslChallengeConstructor.java
new file mode 100644
index 0000000000..400e62db5a
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslChallengeConstructor.java
@@ -0,0 +1,99 @@
+
+/*
+*
+* 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.amqp_1_0.type.security.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.security.*;
+import org.apache.qpid.amqp_1_0.type.security.SaslChallenge;
+
+
+import java.util.List;
+
+public class SaslChallengeConstructor extends DescribedTypeConstructor<SaslChallenge>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:sasl-challenge:list"),UnsignedLong.valueOf(0x0000000000000042L),
+ };
+
+ private static final SaslChallengeConstructor INSTANCE = new SaslChallengeConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public SaslChallenge construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ SaslChallenge obj = new SaslChallenge();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setChallenge( (Binary) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslChallengeWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslChallengeWriter.java
new file mode 100644
index 0000000000..2dd0e572e4
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslChallengeWriter.java
@@ -0,0 +1,150 @@
+
+/*
+*
+* 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.amqp_1_0.type.security.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.security.SaslChallenge;
+
+public class SaslChallengeWriter extends AbstractDescribedTypeWriter<SaslChallenge>
+{
+ private SaslChallenge _value;
+ private int _count = -1;
+
+ public SaslChallengeWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final SaslChallenge value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getChallenge() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000042L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<SaslChallenge>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final SaslChallenge value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getChallenge();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<SaslChallenge> FACTORY = new Factory<SaslChallenge>()
+ {
+
+ public ValueWriter<SaslChallenge> newInstance(Registry registry)
+ {
+ return new SaslChallengeWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(SaslChallenge.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslInitConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslInitConstructor.java
new file mode 100644
index 0000000000..ff21c8e7d9
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslInitConstructor.java
@@ -0,0 +1,153 @@
+
+/*
+*
+* 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.amqp_1_0.type.security.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.security.*;
+import org.apache.qpid.amqp_1_0.type.security.SaslInit;
+
+
+import java.util.List;
+
+public class SaslInitConstructor extends DescribedTypeConstructor<SaslInit>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:sasl-init:list"),UnsignedLong.valueOf(0x0000000000000041L),
+ };
+
+ private static final SaslInitConstructor INSTANCE = new SaslInitConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public SaslInit construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ SaslInit obj = new SaslInit();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setMechanism( (Symbol) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setInitialResponse( (Binary) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setHostname( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslInitWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslInitWriter.java
new file mode 100644
index 0000000000..50c724d9ed
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslInitWriter.java
@@ -0,0 +1,166 @@
+
+/*
+*
+* 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.amqp_1_0.type.security.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.security.SaslInit;
+
+public class SaslInitWriter extends AbstractDescribedTypeWriter<SaslInit>
+{
+ private SaslInit _value;
+ private int _count = -1;
+
+ public SaslInitWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final SaslInit value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getHostname() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getInitialResponse() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getMechanism() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000041L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<SaslInit>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final SaslInit value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getMechanism();
+
+ case 1:
+ return _value.getInitialResponse();
+
+ case 2:
+ return _value.getHostname();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<SaslInit> FACTORY = new Factory<SaslInit>()
+ {
+
+ public ValueWriter<SaslInit> newInstance(Registry registry)
+ {
+ return new SaslInitWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(SaslInit.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslMechanismsConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslMechanismsConstructor.java
new file mode 100644
index 0000000000..0fcdbd2a1a
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslMechanismsConstructor.java
@@ -0,0 +1,106 @@
+
+/*
+*
+* 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.amqp_1_0.type.security.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.security.*;
+import org.apache.qpid.amqp_1_0.type.security.SaslMechanisms;
+
+
+import java.util.List;
+
+public class SaslMechanismsConstructor extends DescribedTypeConstructor<SaslMechanisms>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:sasl-mechanisms:list"),UnsignedLong.valueOf(0x0000000000000040L),
+ };
+
+ private static final SaslMechanismsConstructor INSTANCE = new SaslMechanismsConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public SaslMechanisms construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ SaslMechanisms obj = new SaslMechanisms();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setSaslServerMechanisms( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setSaslServerMechanisms( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslMechanismsWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslMechanismsWriter.java
new file mode 100644
index 0000000000..e630cd0a2f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslMechanismsWriter.java
@@ -0,0 +1,150 @@
+
+/*
+*
+* 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.amqp_1_0.type.security.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.security.SaslMechanisms;
+
+public class SaslMechanismsWriter extends AbstractDescribedTypeWriter<SaslMechanisms>
+{
+ private SaslMechanisms _value;
+ private int _count = -1;
+
+ public SaslMechanismsWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final SaslMechanisms value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getSaslServerMechanisms() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000040L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<SaslMechanisms>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final SaslMechanisms value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getSaslServerMechanisms();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<SaslMechanisms> FACTORY = new Factory<SaslMechanisms>()
+ {
+
+ public ValueWriter<SaslMechanisms> newInstance(Registry registry)
+ {
+ return new SaslMechanismsWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(SaslMechanisms.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslOutcomeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslOutcomeConstructor.java
new file mode 100644
index 0000000000..b1c4760d3e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslOutcomeConstructor.java
@@ -0,0 +1,126 @@
+
+/*
+*
+* 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.amqp_1_0.type.security.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.security.*;
+import org.apache.qpid.amqp_1_0.type.security.SaslOutcome;
+
+
+import java.util.List;
+
+public class SaslOutcomeConstructor extends DescribedTypeConstructor<SaslOutcome>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:sasl-outcome:list"),UnsignedLong.valueOf(0x0000000000000044L),
+ };
+
+ private static final SaslOutcomeConstructor INSTANCE = new SaslOutcomeConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public SaslOutcome construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ SaslOutcome obj = new SaslOutcome();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setCode( SaslCode.valueOf( val ) );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setAdditionalData( (Binary) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslOutcomeWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslOutcomeWriter.java
new file mode 100644
index 0000000000..7c35900ccc
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslOutcomeWriter.java
@@ -0,0 +1,158 @@
+
+/*
+*
+* 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.amqp_1_0.type.security.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.security.SaslOutcome;
+
+public class SaslOutcomeWriter extends AbstractDescribedTypeWriter<SaslOutcome>
+{
+ private SaslOutcome _value;
+ private int _count = -1;
+
+ public SaslOutcomeWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final SaslOutcome value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getAdditionalData() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getCode() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000044L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<SaslOutcome>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final SaslOutcome value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getCode();
+
+ case 1:
+ return _value.getAdditionalData();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<SaslOutcome> FACTORY = new Factory<SaslOutcome>()
+ {
+
+ public ValueWriter<SaslOutcome> newInstance(Registry registry)
+ {
+ return new SaslOutcomeWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(SaslOutcome.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslResponseConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslResponseConstructor.java
new file mode 100644
index 0000000000..364cf59a2f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslResponseConstructor.java
@@ -0,0 +1,99 @@
+
+/*
+*
+* 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.amqp_1_0.type.security.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.security.*;
+import org.apache.qpid.amqp_1_0.type.security.SaslResponse;
+
+
+import java.util.List;
+
+public class SaslResponseConstructor extends DescribedTypeConstructor<SaslResponse>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:sasl-response:list"),UnsignedLong.valueOf(0x0000000000000043L),
+ };
+
+ private static final SaslResponseConstructor INSTANCE = new SaslResponseConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public SaslResponse construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ SaslResponse obj = new SaslResponse();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setResponse( (Binary) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslResponseWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslResponseWriter.java
new file mode 100644
index 0000000000..a8d63085c2
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/security/codec/SaslResponseWriter.java
@@ -0,0 +1,150 @@
+
+/*
+*
+* 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.amqp_1_0.type.security.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.security.SaslResponse;
+
+public class SaslResponseWriter extends AbstractDescribedTypeWriter<SaslResponse>
+{
+ private SaslResponse _value;
+ private int _count = -1;
+
+ public SaslResponseWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final SaslResponse value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getResponse() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000043L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<SaslResponse>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final SaslResponse value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getResponse();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<SaslResponse> FACTORY = new Factory<SaslResponse>()
+ {
+
+ public ValueWriter<SaslResponse> newInstance(Registry registry)
+ {
+ return new SaslResponseWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(SaslResponse.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Coordinator.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Coordinator.java
new file mode 100644
index 0000000000..0417cefd35
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Coordinator.java
@@ -0,0 +1,70 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction;
+
+
+
+import java.util.Arrays;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Coordinator
+ implements Target
+ {
+
+
+ private TxnCapability[] _capabilities;
+
+ public TxnCapability[] getCapabilities()
+ {
+ return _capabilities;
+ }
+
+ public void setCapabilities(TxnCapability[] capabilities)
+ {
+ _capabilities = capabilities;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Coordinator{");
+ final int origLength = builder.length();
+
+ if(_capabilities != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("capabilities=").append(Arrays.asList(_capabilities));
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Declare.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Declare.java
new file mode 100644
index 0000000000..5ec8993392
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Declare.java
@@ -0,0 +1,66 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Declare
+ {
+
+
+ private GlobalTxId _globalId;
+
+ public GlobalTxId getGlobalId()
+ {
+ return _globalId;
+ }
+
+ public void setGlobalId(GlobalTxId globalId)
+ {
+ _globalId = globalId;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Declare{");
+ final int origLength = builder.length();
+
+ if(_globalId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("globalId=").append(_globalId);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Declared.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Declared.java
new file mode 100644
index 0000000000..4878cc3ccf
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Declared.java
@@ -0,0 +1,67 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Declared
+ implements DeliveryState, Outcome
+ {
+
+
+ private Binary _txnId;
+
+ public Binary getTxnId()
+ {
+ return _txnId;
+ }
+
+ public void setTxnId(Binary txnId)
+ {
+ _txnId = txnId;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Declared{");
+ final int origLength = builder.length();
+
+ if(_txnId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("txnId=").append(_txnId);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Discharge.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Discharge.java
new file mode 100644
index 0000000000..356380608b
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/Discharge.java
@@ -0,0 +1,87 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Discharge
+ {
+
+
+ private Binary _txnId;
+
+ private Boolean _fail;
+
+ public Binary getTxnId()
+ {
+ return _txnId;
+ }
+
+ public void setTxnId(Binary txnId)
+ {
+ _txnId = txnId;
+ }
+
+ public Boolean getFail()
+ {
+ return _fail;
+ }
+
+ public void setFail(Boolean fail)
+ {
+ _fail = fail;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Discharge{");
+ final int origLength = builder.length();
+
+ if(_txnId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("txnId=").append(_txnId);
+ }
+
+ if(_fail != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("fail=").append(_fail);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TransactionErrors.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TransactionErrors.java
new file mode 100644
index 0000000000..b87a7eea91
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TransactionErrors.java
@@ -0,0 +1,107 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class TransactionErrors
+ implements ErrorCondition, RestrictedType<Symbol>
+
+ {
+
+
+
+ private final Symbol _val;
+
+
+ public static final TransactionErrors UNKNOWN_ID = new TransactionErrors(Symbol.valueOf("amqp:transaction:unknown-id"));
+
+ public static final TransactionErrors TRANSACTION_ROLLBACK = new TransactionErrors(Symbol.valueOf("amqp:transaction:rollback"));
+
+ public static final TransactionErrors TRANSACTION_TIMEOUT = new TransactionErrors(Symbol.valueOf("amqp:transaction:timeout"));
+
+
+
+ private TransactionErrors(Symbol val)
+ {
+ _val = val;
+ }
+
+ public Symbol getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == UNKNOWN_ID)
+ {
+ return "unknown-id";
+ }
+
+ if(this == TRANSACTION_ROLLBACK)
+ {
+ return "transaction-rollback";
+ }
+
+ if(this == TRANSACTION_TIMEOUT)
+ {
+ return "transaction-timeout";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static TransactionErrors valueOf(Object obj)
+ {
+ Symbol val = (Symbol) obj;
+
+ if(UNKNOWN_ID._val.equals(val))
+ {
+ return UNKNOWN_ID;
+ }
+
+ if(TRANSACTION_ROLLBACK._val.equals(val))
+ {
+ return TRANSACTION_ROLLBACK;
+ }
+
+ if(TRANSACTION_TIMEOUT._val.equals(val))
+ {
+ return TRANSACTION_TIMEOUT;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TransactionalState.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TransactionalState.java
new file mode 100644
index 0000000000..b4fe564cf1
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TransactionalState.java
@@ -0,0 +1,88 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class TransactionalState
+ implements DeliveryState
+ {
+
+
+ private Binary _txnId;
+
+ private Outcome _outcome;
+
+ public Binary getTxnId()
+ {
+ return _txnId;
+ }
+
+ public void setTxnId(Binary txnId)
+ {
+ _txnId = txnId;
+ }
+
+ public Outcome getOutcome()
+ {
+ return _outcome;
+ }
+
+ public void setOutcome(Outcome outcome)
+ {
+ _outcome = outcome;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("TransactionalState{");
+ final int origLength = builder.length();
+
+ if(_txnId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("txnId=").append(_txnId);
+ }
+
+ if(_outcome != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("outcome=").append(_outcome);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TxnCapabilities.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TxnCapabilities.java
new file mode 100644
index 0000000000..840cc57d27
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TxnCapabilities.java
@@ -0,0 +1,144 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.TxnCapability;
+
+public class TxnCapabilities
+ implements TxnCapability, RestrictedType<Symbol>
+
+ {
+
+
+
+ private final Symbol _val;
+
+
+ public static final TxnCapabilities LOCAL_TXN = new TxnCapabilities(Symbol.valueOf("amqp:local-transactions"));
+
+ public static final TxnCapabilities DISTRIBUTED_TXN = new TxnCapabilities(Symbol.valueOf("amqp:distributed-transactions"));
+
+ public static final TxnCapabilities PROMOTABLE_TXN = new TxnCapabilities(Symbol.valueOf("amqp:promotable-transactions"));
+
+ public static final TxnCapabilities MULTI_TXNS_PER_SSN = new TxnCapabilities(Symbol.valueOf("amqp:multi-txns-per-ssn"));
+
+ public static final TxnCapabilities MULTI_SSNS_PER_TXN = new TxnCapabilities(Symbol.valueOf("amqp:multi-ssns-per-txn"));
+
+ public static final TxnCapabilities MULTI_CONNS_PER_TXN = new TxnCapabilities(Symbol.valueOf("amqp:multi-conns-per-txn"));
+
+
+
+ private TxnCapabilities(Symbol val)
+ {
+ _val = val;
+ }
+
+ public Symbol getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == LOCAL_TXN)
+ {
+ return "local-txn";
+ }
+
+ if(this == DISTRIBUTED_TXN)
+ {
+ return "distributed-txn";
+ }
+
+ if(this == PROMOTABLE_TXN)
+ {
+ return "promotable-txn";
+ }
+
+ if(this == MULTI_TXNS_PER_SSN)
+ {
+ return "multi-txns-per-ssn";
+ }
+
+ if(this == MULTI_SSNS_PER_TXN)
+ {
+ return "multi-ssns-per-txn";
+ }
+
+ if(this == MULTI_CONNS_PER_TXN)
+ {
+ return "multi-conns-per-txn";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static TxnCapabilities valueOf(Object obj)
+ {
+ Symbol val = (Symbol) obj;
+
+ if(LOCAL_TXN._val.equals(val))
+ {
+ return LOCAL_TXN;
+ }
+
+ if(DISTRIBUTED_TXN._val.equals(val))
+ {
+ return DISTRIBUTED_TXN;
+ }
+
+ if(PROMOTABLE_TXN._val.equals(val))
+ {
+ return PROMOTABLE_TXN;
+ }
+
+ if(MULTI_TXNS_PER_SSN._val.equals(val))
+ {
+ return MULTI_TXNS_PER_SSN;
+ }
+
+ if(MULTI_SSNS_PER_TXN._val.equals(val))
+ {
+ return MULTI_SSNS_PER_TXN;
+ }
+
+ if(MULTI_CONNS_PER_TXN._val.equals(val))
+ {
+ return MULTI_CONNS_PER_TXN;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TxnCapability.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TxnCapability.java
new file mode 100644
index 0000000000..19763f5b6b
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/TxnCapability.java
@@ -0,0 +1,131 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class TxnCapability
+ implements org.apache.qpid.amqp_1_0.type.TxnCapability, RestrictedType<Symbol>
+
+ {
+
+
+
+ private final Symbol _val;
+
+
+ public static final TxnCapability LOCAL_TXN = new TxnCapability(Symbol.valueOf("amqp:local-transactions"));
+
+ public static final TxnCapability DISTRIBUTED_TXN = new TxnCapability(Symbol.valueOf("amqp:distributed-transactions"));
+
+ public static final TxnCapability PROMOTABLE_TXN = new TxnCapability(Symbol.valueOf("amqp:promotable-transactions"));
+
+ public static final TxnCapability MULTI_TXNS_PER_SSN = new TxnCapability(Symbol.valueOf("amqp:multi-txns-per-ssn"));
+
+ public static final TxnCapability MULTI_SSNS_PER_TXN = new TxnCapability(Symbol.valueOf("amqp:multi-ssns-per-txn"));
+
+
+
+ private TxnCapability(Symbol val)
+ {
+ _val = val;
+ }
+
+ public Symbol getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == LOCAL_TXN)
+ {
+ return "local-txn";
+ }
+
+ if(this == DISTRIBUTED_TXN)
+ {
+ return "distributed-txn";
+ }
+
+ if(this == PROMOTABLE_TXN)
+ {
+ return "promotable-txn";
+ }
+
+ if(this == MULTI_TXNS_PER_SSN)
+ {
+ return "multi-txns-per-ssn";
+ }
+
+ if(this == MULTI_SSNS_PER_TXN)
+ {
+ return "multi-ssns-per-txn";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static TxnCapability valueOf(Object obj)
+ {
+ Symbol val = (Symbol) obj;
+
+ if(LOCAL_TXN._val.equals(val))
+ {
+ return LOCAL_TXN;
+ }
+
+ if(DISTRIBUTED_TXN._val.equals(val))
+ {
+ return DISTRIBUTED_TXN;
+ }
+
+ if(PROMOTABLE_TXN._val.equals(val))
+ {
+ return PROMOTABLE_TXN;
+ }
+
+ if(MULTI_TXNS_PER_SSN._val.equals(val))
+ {
+ return MULTI_TXNS_PER_SSN;
+ }
+
+ if(MULTI_SSNS_PER_TXN._val.equals(val))
+ {
+ return MULTI_SSNS_PER_TXN;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/CoordinatorConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/CoordinatorConstructor.java
new file mode 100644
index 0000000000..de1dbc625e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/CoordinatorConstructor.java
@@ -0,0 +1,117 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transaction.*;
+import org.apache.qpid.amqp_1_0.type.transaction.Coordinator;
+import org.apache.qpid.amqp_1_0.type.transaction.TxnCapability;
+
+import java.util.List;
+
+public class CoordinatorConstructor extends DescribedTypeConstructor<Coordinator>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:coordinator:list"),UnsignedLong.valueOf(0x0000000000000030L),
+ };
+
+ private static final CoordinatorConstructor INSTANCE = new CoordinatorConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Coordinator construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Coordinator obj = new Coordinator();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof TxnCapability[] )
+ {
+ obj.setCapabilities( (TxnCapability[]) val );
+ }
+ else if (val instanceof Symbol[])
+ {
+ Symbol[] symVal = (Symbol[]) val;
+ TxnCapability[] cap = new TxnCapability[symVal.length];
+ int i = 0;
+ for(Symbol sym : symVal)
+ {
+ cap[i++] = TxnCapability.valueOf(sym);
+ }
+ obj.setCapabilities(cap);
+ }
+ else
+ {
+ try
+ {
+ obj.setCapabilities( new TxnCapability[] { (TxnCapability) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/CoordinatorWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/CoordinatorWriter.java
new file mode 100644
index 0000000000..56e3993046
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/CoordinatorWriter.java
@@ -0,0 +1,150 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transaction.Coordinator;
+
+public class CoordinatorWriter extends AbstractDescribedTypeWriter<Coordinator>
+{
+ private Coordinator _value;
+ private int _count = -1;
+
+ public CoordinatorWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Coordinator value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getCapabilities() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000030L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Coordinator>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Coordinator value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getCapabilities();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Coordinator> FACTORY = new Factory<Coordinator>()
+ {
+
+ public ValueWriter<Coordinator> newInstance(Registry registry)
+ {
+ return new CoordinatorWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Coordinator.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclareConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclareConstructor.java
new file mode 100644
index 0000000000..7eaf7dd9a8
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclareConstructor.java
@@ -0,0 +1,99 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transaction.*;
+import org.apache.qpid.amqp_1_0.type.transaction.Declare;
+
+
+import java.util.List;
+
+public class DeclareConstructor extends DescribedTypeConstructor<Declare>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:declare:list"),UnsignedLong.valueOf(0x0000000000000031L),
+ };
+
+ private static final DeclareConstructor INSTANCE = new DeclareConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Declare construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Declare obj = new Declare();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setGlobalId( (GlobalTxId) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclareWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclareWriter.java
new file mode 100644
index 0000000000..bf0687fe92
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclareWriter.java
@@ -0,0 +1,150 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transaction.Declare;
+
+public class DeclareWriter extends AbstractDescribedTypeWriter<Declare>
+{
+ private Declare _value;
+ private int _count = -1;
+
+ public DeclareWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Declare value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getGlobalId() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000031L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Declare>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Declare value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getGlobalId();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Declare> FACTORY = new Factory<Declare>()
+ {
+
+ public ValueWriter<Declare> newInstance(Registry registry)
+ {
+ return new DeclareWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Declare.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclaredConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclaredConstructor.java
new file mode 100644
index 0000000000..1e226ff994
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclaredConstructor.java
@@ -0,0 +1,99 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transaction.*;
+import org.apache.qpid.amqp_1_0.type.transaction.Declared;
+
+
+import java.util.List;
+
+public class DeclaredConstructor extends DescribedTypeConstructor<Declared>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:declared:list"),UnsignedLong.valueOf(0x0000000000000033L),
+ };
+
+ private static final DeclaredConstructor INSTANCE = new DeclaredConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Declared construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Declared obj = new Declared();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setTxnId( (Binary) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclaredWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclaredWriter.java
new file mode 100644
index 0000000000..798ffcc72b
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DeclaredWriter.java
@@ -0,0 +1,150 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transaction.Declared;
+
+public class DeclaredWriter extends AbstractDescribedTypeWriter<Declared>
+{
+ private Declared _value;
+ private int _count = -1;
+
+ public DeclaredWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Declared value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getTxnId() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000033L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Declared>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Declared value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getTxnId();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Declared> FACTORY = new Factory<Declared>()
+ {
+
+ public ValueWriter<Declared> newInstance(Registry registry)
+ {
+ return new DeclaredWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Declared.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DischargeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DischargeConstructor.java
new file mode 100644
index 0000000000..ab088cc74d
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DischargeConstructor.java
@@ -0,0 +1,126 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transaction.*;
+import org.apache.qpid.amqp_1_0.type.transaction.Discharge;
+
+
+import java.util.List;
+
+public class DischargeConstructor extends DescribedTypeConstructor<Discharge>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:discharge:list"),UnsignedLong.valueOf(0x0000000000000032L),
+ };
+
+ private static final DischargeConstructor INSTANCE = new DischargeConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Discharge construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Discharge obj = new Discharge();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setTxnId( (Binary) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setFail( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DischargeWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DischargeWriter.java
new file mode 100644
index 0000000000..ddd8678418
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/DischargeWriter.java
@@ -0,0 +1,158 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transaction.Discharge;
+
+public class DischargeWriter extends AbstractDescribedTypeWriter<Discharge>
+{
+ private Discharge _value;
+ private int _count = -1;
+
+ public DischargeWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Discharge value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getFail() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getTxnId() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000032L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Discharge>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Discharge value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getTxnId();
+
+ case 1:
+ return _value.getFail();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Discharge> FACTORY = new Factory<Discharge>()
+ {
+
+ public ValueWriter<Discharge> newInstance(Registry registry)
+ {
+ return new DischargeWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Discharge.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/TransactionalStateConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/TransactionalStateConstructor.java
new file mode 100644
index 0000000000..88cddba562
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/TransactionalStateConstructor.java
@@ -0,0 +1,126 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transaction.*;
+import org.apache.qpid.amqp_1_0.type.transaction.TransactionalState;
+
+
+import java.util.List;
+
+public class TransactionalStateConstructor extends DescribedTypeConstructor<TransactionalState>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:transactional-state:list"),UnsignedLong.valueOf(0x0000000000000034L),
+ };
+
+ private static final TransactionalStateConstructor INSTANCE = new TransactionalStateConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public TransactionalState construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ TransactionalState obj = new TransactionalState();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setTxnId( (Binary) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setOutcome( (Outcome) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/TransactionalStateWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/TransactionalStateWriter.java
new file mode 100644
index 0000000000..ea450fcf35
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transaction/codec/TransactionalStateWriter.java
@@ -0,0 +1,158 @@
+
+/*
+*
+* 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.amqp_1_0.type.transaction.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transaction.TransactionalState;
+
+public class TransactionalStateWriter extends AbstractDescribedTypeWriter<TransactionalState>
+{
+ private TransactionalState _value;
+ private int _count = -1;
+
+ public TransactionalStateWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final TransactionalState value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getOutcome() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getTxnId() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000034L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<TransactionalState>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final TransactionalState value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getTxnId();
+
+ case 1:
+ return _value.getOutcome();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<TransactionalState> FACTORY = new Factory<TransactionalState>()
+ {
+
+ public ValueWriter<TransactionalState> newInstance(Registry registry)
+ {
+ return new TransactionalStateWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(TransactionalState.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/AmqpError.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/AmqpError.java
new file mode 100644
index 0000000000..075a80ef90
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/AmqpError.java
@@ -0,0 +1,227 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class AmqpError
+ implements ErrorCondition, RestrictedType<Symbol>
+
+ {
+
+
+
+ private final Symbol _val;
+
+
+ public static final AmqpError INTERNAL_ERROR = new AmqpError(Symbol.valueOf("amqp:internal-error"));
+
+ public static final AmqpError NOT_FOUND = new AmqpError(Symbol.valueOf("amqp:not-found"));
+
+ public static final AmqpError UNAUTHORIZED_ACCESS = new AmqpError(Symbol.valueOf("amqp:unauthorized-access"));
+
+ public static final AmqpError DECODE_ERROR = new AmqpError(Symbol.valueOf("amqp:decode-error"));
+
+ public static final AmqpError RESOURCE_LIMIT_EXCEEDED = new AmqpError(Symbol.valueOf("amqp:resource-limit-exceeded"));
+
+ public static final AmqpError NOT_ALLOWED = new AmqpError(Symbol.valueOf("amqp:not-allowed"));
+
+ public static final AmqpError INVALID_FIELD = new AmqpError(Symbol.valueOf("amqp:invalid-field"));
+
+ public static final AmqpError NOT_IMPLEMENTED = new AmqpError(Symbol.valueOf("amqp:not-implemented"));
+
+ public static final AmqpError RESOURCE_LOCKED = new AmqpError(Symbol.valueOf("amqp:resource-locked"));
+
+ public static final AmqpError PRECONDITION_FAILED = new AmqpError(Symbol.valueOf("amqp:precondition-failed"));
+
+ public static final AmqpError RESOURCE_DELETED = new AmqpError(Symbol.valueOf("amqp:resource-deleted"));
+
+ public static final AmqpError ILLEGAL_STATE = new AmqpError(Symbol.valueOf("amqp:illegal-state"));
+
+ public static final AmqpError FRAME_SIZE_TOO_SMALL = new AmqpError(Symbol.valueOf("amqp:frame-size-too-small"));
+
+
+
+ private AmqpError(Symbol val)
+ {
+ _val = val;
+ }
+
+ public Symbol getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == INTERNAL_ERROR)
+ {
+ return "internal-error";
+ }
+
+ if(this == NOT_FOUND)
+ {
+ return "not-found";
+ }
+
+ if(this == UNAUTHORIZED_ACCESS)
+ {
+ return "unauthorized-access";
+ }
+
+ if(this == DECODE_ERROR)
+ {
+ return "decode-error";
+ }
+
+ if(this == RESOURCE_LIMIT_EXCEEDED)
+ {
+ return "resource-limit-exceeded";
+ }
+
+ if(this == NOT_ALLOWED)
+ {
+ return "not-allowed";
+ }
+
+ if(this == INVALID_FIELD)
+ {
+ return "invalid-field";
+ }
+
+ if(this == NOT_IMPLEMENTED)
+ {
+ return "not-implemented";
+ }
+
+ if(this == RESOURCE_LOCKED)
+ {
+ return "resource-locked";
+ }
+
+ if(this == PRECONDITION_FAILED)
+ {
+ return "precondition-failed";
+ }
+
+ if(this == RESOURCE_DELETED)
+ {
+ return "resource-deleted";
+ }
+
+ if(this == ILLEGAL_STATE)
+ {
+ return "illegal-state";
+ }
+
+ if(this == FRAME_SIZE_TOO_SMALL)
+ {
+ return "frame-size-too-small";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static AmqpError valueOf(Object obj)
+ {
+ Symbol val = (Symbol) obj;
+
+ if(INTERNAL_ERROR._val.equals(val))
+ {
+ return INTERNAL_ERROR;
+ }
+
+ if(NOT_FOUND._val.equals(val))
+ {
+ return NOT_FOUND;
+ }
+
+ if(UNAUTHORIZED_ACCESS._val.equals(val))
+ {
+ return UNAUTHORIZED_ACCESS;
+ }
+
+ if(DECODE_ERROR._val.equals(val))
+ {
+ return DECODE_ERROR;
+ }
+
+ if(RESOURCE_LIMIT_EXCEEDED._val.equals(val))
+ {
+ return RESOURCE_LIMIT_EXCEEDED;
+ }
+
+ if(NOT_ALLOWED._val.equals(val))
+ {
+ return NOT_ALLOWED;
+ }
+
+ if(INVALID_FIELD._val.equals(val))
+ {
+ return INVALID_FIELD;
+ }
+
+ if(NOT_IMPLEMENTED._val.equals(val))
+ {
+ return NOT_IMPLEMENTED;
+ }
+
+ if(RESOURCE_LOCKED._val.equals(val))
+ {
+ return RESOURCE_LOCKED;
+ }
+
+ if(PRECONDITION_FAILED._val.equals(val))
+ {
+ return PRECONDITION_FAILED;
+ }
+
+ if(RESOURCE_DELETED._val.equals(val))
+ {
+ return RESOURCE_DELETED;
+ }
+
+ if(ILLEGAL_STATE._val.equals(val))
+ {
+ return ILLEGAL_STATE;
+ }
+
+ if(FRAME_SIZE_TOO_SMALL._val.equals(val))
+ {
+ return FRAME_SIZE_TOO_SMALL;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Attach.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Attach.java
new file mode 100644
index 0000000000..d01dd0146c
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Attach.java
@@ -0,0 +1,365 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+
+import java.util.Map;
+
+
+import java.nio.ByteBuffer;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Attach
+ implements FrameBody
+ {
+
+
+ private ByteBuffer _payload;
+
+ private String _name;
+
+ private UnsignedInteger _handle;
+
+ private Role _role;
+
+ private SenderSettleMode _sndSettleMode;
+
+ private ReceiverSettleMode _rcvSettleMode;
+
+ private Source _source;
+
+ private Target _target;
+
+ private Map _unsettled;
+
+ private Boolean _incompleteUnsettled;
+
+ private UnsignedInteger _initialDeliveryCount;
+
+ private UnsignedLong _maxMessageSize;
+
+ private Symbol[] _offeredCapabilities;
+
+ private Symbol[] _desiredCapabilities;
+
+ private Map _properties;
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public void setName(String name)
+ {
+ _name = name;
+ }
+
+ public UnsignedInteger getHandle()
+ {
+ return _handle;
+ }
+
+ public void setHandle(UnsignedInteger handle)
+ {
+ _handle = handle;
+ }
+
+ public Role getRole()
+ {
+ return _role;
+ }
+
+ public void setRole(Role role)
+ {
+ _role = role;
+ }
+
+ public SenderSettleMode getSndSettleMode()
+ {
+ return _sndSettleMode;
+ }
+
+ public void setSndSettleMode(SenderSettleMode sndSettleMode)
+ {
+ _sndSettleMode = sndSettleMode;
+ }
+
+ public ReceiverSettleMode getRcvSettleMode()
+ {
+ return _rcvSettleMode;
+ }
+
+ public void setRcvSettleMode(ReceiverSettleMode rcvSettleMode)
+ {
+ _rcvSettleMode = rcvSettleMode;
+ }
+
+ public Source getSource()
+ {
+ return _source;
+ }
+
+ public void setSource(Source source)
+ {
+ _source = source;
+ }
+
+ public Target getTarget()
+ {
+ return _target;
+ }
+
+ public void setTarget(Target target)
+ {
+ _target = target;
+ }
+
+ public Map getUnsettled()
+ {
+ return _unsettled;
+ }
+
+ public void setUnsettled(Map unsettled)
+ {
+ _unsettled = unsettled;
+ }
+
+ public Boolean getIncompleteUnsettled()
+ {
+ return _incompleteUnsettled;
+ }
+
+ public void setIncompleteUnsettled(Boolean incompleteUnsettled)
+ {
+ _incompleteUnsettled = incompleteUnsettled;
+ }
+
+ public UnsignedInteger getInitialDeliveryCount()
+ {
+ return _initialDeliveryCount;
+ }
+
+ public void setInitialDeliveryCount(UnsignedInteger initialDeliveryCount)
+ {
+ _initialDeliveryCount = initialDeliveryCount;
+ }
+
+ public UnsignedLong getMaxMessageSize()
+ {
+ return _maxMessageSize;
+ }
+
+ public void setMaxMessageSize(UnsignedLong maxMessageSize)
+ {
+ _maxMessageSize = maxMessageSize;
+ }
+
+ public Symbol[] getOfferedCapabilities()
+ {
+ return _offeredCapabilities;
+ }
+
+ public void setOfferedCapabilities(Symbol[] offeredCapabilities)
+ {
+ _offeredCapabilities = offeredCapabilities;
+ }
+
+ public Symbol[] getDesiredCapabilities()
+ {
+ return _desiredCapabilities;
+ }
+
+ public void setDesiredCapabilities(Symbol[] desiredCapabilities)
+ {
+ _desiredCapabilities = desiredCapabilities;
+ }
+
+ public Map getProperties()
+ {
+ return _properties;
+ }
+
+ public void setProperties(Map properties)
+ {
+ _properties = properties;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Attach{");
+ final int origLength = builder.length();
+
+ if(_name != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("name=").append(_name);
+ }
+
+ if(_handle != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("handle=").append(_handle);
+ }
+
+ if(_role != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("role=").append(_role);
+ }
+
+ if(_sndSettleMode != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("sndSettleMode=").append(_sndSettleMode);
+ }
+
+ if(_rcvSettleMode != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("rcvSettleMode=").append(_rcvSettleMode);
+ }
+
+ if(_source != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("source=").append(_source);
+ }
+
+ if(_target != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("target=").append(_target);
+ }
+
+ if(_unsettled != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("unsettled=").append(_unsettled);
+ }
+
+ if(_incompleteUnsettled != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("incompleteUnsettled=").append(_incompleteUnsettled);
+ }
+
+ if(_initialDeliveryCount != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("initialDeliveryCount=").append(_initialDeliveryCount);
+ }
+
+ if(_maxMessageSize != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("maxMessageSize=").append(_maxMessageSize);
+ }
+
+ if(_offeredCapabilities != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("offeredCapabilities=").append(_offeredCapabilities);
+ }
+
+ if(_desiredCapabilities != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("desiredCapabilities=").append(_desiredCapabilities);
+ }
+
+ if(_properties != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("properties=").append(_properties);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(short channel, ConnectionEndpoint conn)
+ {
+ conn.receiveAttach(channel, this);
+ }
+
+ public void setPayload(ByteBuffer payload)
+ {
+ _payload = payload;
+ }
+
+ public ByteBuffer getPayload()
+ {
+ return _payload;
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Begin.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Begin.java
new file mode 100644
index 0000000000..558fcbf780
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Begin.java
@@ -0,0 +1,239 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+
+import java.util.Map;
+
+
+import java.nio.ByteBuffer;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Begin
+ implements FrameBody
+ {
+
+
+ private ByteBuffer _payload;
+
+ private UnsignedShort _remoteChannel;
+
+ private UnsignedInteger _nextOutgoingId;
+
+ private UnsignedInteger _incomingWindow;
+
+ private UnsignedInteger _outgoingWindow;
+
+ private UnsignedInteger _handleMax;
+
+ private Symbol[] _offeredCapabilities;
+
+ private Symbol[] _desiredCapabilities;
+
+ private Map _properties;
+
+ public UnsignedShort getRemoteChannel()
+ {
+ return _remoteChannel;
+ }
+
+ public void setRemoteChannel(UnsignedShort remoteChannel)
+ {
+ _remoteChannel = remoteChannel;
+ }
+
+ public UnsignedInteger getNextOutgoingId()
+ {
+ return _nextOutgoingId;
+ }
+
+ public void setNextOutgoingId(UnsignedInteger nextOutgoingId)
+ {
+ _nextOutgoingId = nextOutgoingId;
+ }
+
+ public UnsignedInteger getIncomingWindow()
+ {
+ return _incomingWindow;
+ }
+
+ public void setIncomingWindow(UnsignedInteger incomingWindow)
+ {
+ _incomingWindow = incomingWindow;
+ }
+
+ public UnsignedInteger getOutgoingWindow()
+ {
+ return _outgoingWindow;
+ }
+
+ public void setOutgoingWindow(UnsignedInteger outgoingWindow)
+ {
+ _outgoingWindow = outgoingWindow;
+ }
+
+ public UnsignedInteger getHandleMax()
+ {
+ return _handleMax;
+ }
+
+ public void setHandleMax(UnsignedInteger handleMax)
+ {
+ _handleMax = handleMax;
+ }
+
+ public Symbol[] getOfferedCapabilities()
+ {
+ return _offeredCapabilities;
+ }
+
+ public void setOfferedCapabilities(Symbol[] offeredCapabilities)
+ {
+ _offeredCapabilities = offeredCapabilities;
+ }
+
+ public Symbol[] getDesiredCapabilities()
+ {
+ return _desiredCapabilities;
+ }
+
+ public void setDesiredCapabilities(Symbol[] desiredCapabilities)
+ {
+ _desiredCapabilities = desiredCapabilities;
+ }
+
+ public Map getProperties()
+ {
+ return _properties;
+ }
+
+ public void setProperties(Map properties)
+ {
+ _properties = properties;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Begin{");
+ final int origLength = builder.length();
+
+ if(_remoteChannel != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("remoteChannel=").append(_remoteChannel);
+ }
+
+ if(_nextOutgoingId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("nextOutgoingId=").append(_nextOutgoingId);
+ }
+
+ if(_incomingWindow != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("incomingWindow=").append(_incomingWindow);
+ }
+
+ if(_outgoingWindow != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("outgoingWindow=").append(_outgoingWindow);
+ }
+
+ if(_handleMax != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("handleMax=").append(_handleMax);
+ }
+
+ if(_offeredCapabilities != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("offeredCapabilities=").append(_offeredCapabilities);
+ }
+
+ if(_desiredCapabilities != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("desiredCapabilities=").append(_desiredCapabilities);
+ }
+
+ if(_properties != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("properties=").append(_properties);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(short channel, ConnectionEndpoint conn)
+ {
+ conn.receiveBegin(channel, this);
+ }
+
+ public void setPayload(ByteBuffer payload)
+ {
+ _payload = payload;
+ }
+
+ public ByteBuffer getPayload()
+ {
+ return _payload;
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Close.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Close.java
new file mode 100644
index 0000000000..e86342d531
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Close.java
@@ -0,0 +1,89 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+
+import java.nio.ByteBuffer;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Close
+ implements FrameBody
+ {
+
+
+ private ByteBuffer _payload;
+
+ private Error _error;
+
+ public Error getError()
+ {
+ return _error;
+ }
+
+ public void setError(Error error)
+ {
+ _error = error;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Close{");
+ final int origLength = builder.length();
+
+ if(_error != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("error=").append(_error);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(short channel, ConnectionEndpoint conn)
+ {
+ conn.receiveClose(channel, this);
+ }
+
+ public void setPayload(ByteBuffer payload)
+ {
+ _payload = payload;
+ }
+
+ public ByteBuffer getPayload()
+ {
+ return _payload;
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/ConnectionError.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/ConnectionError.java
new file mode 100644
index 0000000000..07f0496e23
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/ConnectionError.java
@@ -0,0 +1,107 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class ConnectionError
+ implements ErrorCondition, RestrictedType<Symbol>
+
+ {
+
+
+
+ private final Symbol _val;
+
+
+ public static final ConnectionError CONNECTION_FORCED = new ConnectionError(Symbol.valueOf("amqp:connection:forced"));
+
+ public static final ConnectionError FRAMING_ERROR = new ConnectionError(Symbol.valueOf("amqp:connection:framing-error"));
+
+ public static final ConnectionError REDIRECT = new ConnectionError(Symbol.valueOf("amqp:connection:redirect"));
+
+
+
+ private ConnectionError(Symbol val)
+ {
+ _val = val;
+ }
+
+ public Symbol getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == CONNECTION_FORCED)
+ {
+ return "connection-forced";
+ }
+
+ if(this == FRAMING_ERROR)
+ {
+ return "framing-error";
+ }
+
+ if(this == REDIRECT)
+ {
+ return "redirect";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static ConnectionError valueOf(Object obj)
+ {
+ Symbol val = (Symbol) obj;
+
+ if(CONNECTION_FORCED._val.equals(val))
+ {
+ return CONNECTION_FORCED;
+ }
+
+ if(FRAMING_ERROR._val.equals(val))
+ {
+ return FRAMING_ERROR;
+ }
+
+ if(REDIRECT._val.equals(val))
+ {
+ return REDIRECT;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Detach.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Detach.java
new file mode 100644
index 0000000000..f788201328
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Detach.java
@@ -0,0 +1,131 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+
+import java.nio.ByteBuffer;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Detach
+ implements FrameBody
+ {
+
+
+ private ByteBuffer _payload;
+
+ private UnsignedInteger _handle;
+
+ private Boolean _closed;
+
+ private Error _error;
+
+ public UnsignedInteger getHandle()
+ {
+ return _handle;
+ }
+
+ public void setHandle(UnsignedInteger handle)
+ {
+ _handle = handle;
+ }
+
+ public Boolean getClosed()
+ {
+ return _closed;
+ }
+
+ public void setClosed(Boolean closed)
+ {
+ _closed = closed;
+ }
+
+ public Error getError()
+ {
+ return _error;
+ }
+
+ public void setError(Error error)
+ {
+ _error = error;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Detach{");
+ final int origLength = builder.length();
+
+ if(_handle != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("handle=").append(_handle);
+ }
+
+ if(_closed != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("closed=").append(_closed);
+ }
+
+ if(_error != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("error=").append(_error);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(short channel, ConnectionEndpoint conn)
+ {
+ conn.receiveDetach(channel, this);
+ }
+
+ public void setPayload(ByteBuffer payload)
+ {
+ _payload = payload;
+ }
+
+ public ByteBuffer getPayload()
+ {
+ return _payload;
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Disposition.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Disposition.java
new file mode 100644
index 0000000000..c7f04dedca
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Disposition.java
@@ -0,0 +1,194 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+
+import java.nio.ByteBuffer;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Disposition
+ implements FrameBody
+ {
+
+
+ private ByteBuffer _payload;
+
+ private Role _role;
+
+ private UnsignedInteger _first;
+
+ private UnsignedInteger _last;
+
+ private Boolean _settled;
+
+ private DeliveryState _state;
+
+ private Boolean _batchable;
+
+ public Role getRole()
+ {
+ return _role;
+ }
+
+ public void setRole(Role role)
+ {
+ _role = role;
+ }
+
+ public UnsignedInteger getFirst()
+ {
+ return _first;
+ }
+
+ public void setFirst(UnsignedInteger first)
+ {
+ _first = first;
+ }
+
+ public UnsignedInteger getLast()
+ {
+ return _last;
+ }
+
+ public void setLast(UnsignedInteger last)
+ {
+ _last = last;
+ }
+
+ public Boolean getSettled()
+ {
+ return _settled;
+ }
+
+ public void setSettled(Boolean settled)
+ {
+ _settled = settled;
+ }
+
+ public DeliveryState getState()
+ {
+ return _state;
+ }
+
+ public void setState(DeliveryState state)
+ {
+ _state = state;
+ }
+
+ public Boolean getBatchable()
+ {
+ return _batchable;
+ }
+
+ public void setBatchable(Boolean batchable)
+ {
+ _batchable = batchable;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Disposition{");
+ final int origLength = builder.length();
+
+ if(_role != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("role=").append(_role);
+ }
+
+ if(_first != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("first=").append(_first);
+ }
+
+ if(_last != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("last=").append(_last);
+ }
+
+ if(_settled != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("settled=").append(_settled);
+ }
+
+ if(_state != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("state=").append(_state);
+ }
+
+ if(_batchable != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("batchable=").append(_batchable);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(short channel, ConnectionEndpoint conn)
+ {
+ conn.receiveDisposition(channel, this);
+ }
+
+ public void setPayload(ByteBuffer payload)
+ {
+ _payload = payload;
+ }
+
+ public ByteBuffer getPayload()
+ {
+ return _payload;
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/End.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/End.java
new file mode 100644
index 0000000000..63fc331360
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/End.java
@@ -0,0 +1,89 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+
+import java.nio.ByteBuffer;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class End
+ implements FrameBody
+ {
+
+
+ private ByteBuffer _payload;
+
+ private Error _error;
+
+ public Error getError()
+ {
+ return _error;
+ }
+
+ public void setError(Error error)
+ {
+ _error = error;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("End{");
+ final int origLength = builder.length();
+
+ if(_error != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("error=").append(_error);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(short channel, ConnectionEndpoint conn)
+ {
+ conn.receiveEnd(channel, this);
+ }
+
+ public void setPayload(ByteBuffer payload)
+ {
+ _payload = payload;
+ }
+
+ public ByteBuffer getPayload()
+ {
+ return _payload;
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Error.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Error.java
new file mode 100644
index 0000000000..6e1af84cc9
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Error.java
@@ -0,0 +1,111 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+
+import java.util.Map;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Error
+ {
+
+
+ private ErrorCondition _condition;
+
+ private String _description;
+
+ private Map _info;
+
+ public ErrorCondition getCondition()
+ {
+ return _condition;
+ }
+
+ public void setCondition(ErrorCondition condition)
+ {
+ _condition = condition;
+ }
+
+ public String getDescription()
+ {
+ return _description;
+ }
+
+ public void setDescription(String description)
+ {
+ _description = description;
+ }
+
+ public Map getInfo()
+ {
+ return _info;
+ }
+
+ public void setInfo(Map info)
+ {
+ _info = info;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Error{");
+ final int origLength = builder.length();
+
+ if(_condition != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("condition=").append(_condition);
+ }
+
+ if(_description != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("description=").append(_description);
+ }
+
+ if(_info != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("info=").append(_info);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Flow.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Flow.java
new file mode 100644
index 0000000000..118d163841
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Flow.java
@@ -0,0 +1,302 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+
+import java.util.Map;
+
+
+import java.nio.ByteBuffer;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Flow
+ implements FrameBody
+ {
+
+
+ private ByteBuffer _payload;
+
+ private UnsignedInteger _nextIncomingId;
+
+ private UnsignedInteger _incomingWindow;
+
+ private UnsignedInteger _nextOutgoingId;
+
+ private UnsignedInteger _outgoingWindow;
+
+ private UnsignedInteger _handle;
+
+ private UnsignedInteger _deliveryCount;
+
+ private UnsignedInteger _linkCredit;
+
+ private UnsignedInteger _available;
+
+ private Boolean _drain;
+
+ private Boolean _echo;
+
+ private Map _properties;
+
+ public UnsignedInteger getNextIncomingId()
+ {
+ return _nextIncomingId;
+ }
+
+ public void setNextIncomingId(UnsignedInteger nextIncomingId)
+ {
+ _nextIncomingId = nextIncomingId;
+ }
+
+ public UnsignedInteger getIncomingWindow()
+ {
+ return _incomingWindow;
+ }
+
+ public void setIncomingWindow(UnsignedInteger incomingWindow)
+ {
+ _incomingWindow = incomingWindow;
+ }
+
+ public UnsignedInteger getNextOutgoingId()
+ {
+ return _nextOutgoingId;
+ }
+
+ public void setNextOutgoingId(UnsignedInteger nextOutgoingId)
+ {
+ _nextOutgoingId = nextOutgoingId;
+ }
+
+ public UnsignedInteger getOutgoingWindow()
+ {
+ return _outgoingWindow;
+ }
+
+ public void setOutgoingWindow(UnsignedInteger outgoingWindow)
+ {
+ _outgoingWindow = outgoingWindow;
+ }
+
+ public UnsignedInteger getHandle()
+ {
+ return _handle;
+ }
+
+ public void setHandle(UnsignedInteger handle)
+ {
+ _handle = handle;
+ }
+
+ public UnsignedInteger getDeliveryCount()
+ {
+ return _deliveryCount;
+ }
+
+ public void setDeliveryCount(UnsignedInteger deliveryCount)
+ {
+ _deliveryCount = deliveryCount;
+ }
+
+ public UnsignedInteger getLinkCredit()
+ {
+ return _linkCredit;
+ }
+
+ public void setLinkCredit(UnsignedInteger linkCredit)
+ {
+ _linkCredit = linkCredit;
+ }
+
+ public UnsignedInteger getAvailable()
+ {
+ return _available;
+ }
+
+ public void setAvailable(UnsignedInteger available)
+ {
+ _available = available;
+ }
+
+ public Boolean getDrain()
+ {
+ return _drain;
+ }
+
+ public void setDrain(Boolean drain)
+ {
+ _drain = drain;
+ }
+
+ public Boolean getEcho()
+ {
+ return _echo;
+ }
+
+ public void setEcho(Boolean echo)
+ {
+ _echo = echo;
+ }
+
+ public Map getProperties()
+ {
+ return _properties;
+ }
+
+ public void setProperties(Map properties)
+ {
+ _properties = properties;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Flow{");
+ final int origLength = builder.length();
+
+ if(_nextIncomingId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("nextIncomingId=").append(_nextIncomingId);
+ }
+
+ if(_incomingWindow != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("incomingWindow=").append(_incomingWindow);
+ }
+
+ if(_nextOutgoingId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("nextOutgoingId=").append(_nextOutgoingId);
+ }
+
+ if(_outgoingWindow != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("outgoingWindow=").append(_outgoingWindow);
+ }
+
+ if(_handle != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("handle=").append(_handle);
+ }
+
+ if(_deliveryCount != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("deliveryCount=").append(_deliveryCount);
+ }
+
+ if(_linkCredit != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("linkCredit=").append(_linkCredit);
+ }
+
+ if(_available != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("available=").append(_available);
+ }
+
+ if(_drain != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("drain=").append(_drain);
+ }
+
+ if(_echo != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("echo=").append(_echo);
+ }
+
+ if(_properties != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("properties=").append(_properties);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(short channel, ConnectionEndpoint conn)
+ {
+ conn.receiveFlow(channel, this);
+ }
+
+ public void setPayload(ByteBuffer payload)
+ {
+ _payload = payload;
+ }
+
+ public ByteBuffer getPayload()
+ {
+ return _payload;
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/LinkError.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/LinkError.java
new file mode 100644
index 0000000000..3c2d025619
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/LinkError.java
@@ -0,0 +1,131 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class LinkError
+ implements ErrorCondition, RestrictedType<Symbol>
+
+ {
+
+
+
+ private final Symbol _val;
+
+
+ public static final LinkError DETACH_FORCED = new LinkError(Symbol.valueOf("amqp:link:detach-forced"));
+
+ public static final LinkError TRANSFER_LIMIT_EXCEEDED = new LinkError(Symbol.valueOf("amqp:link:transfer-limit-exceeded"));
+
+ public static final LinkError MESSAGE_SIZE_EXCEEDED = new LinkError(Symbol.valueOf("amqp:link:message-size-exceeded"));
+
+ public static final LinkError REDIRECT = new LinkError(Symbol.valueOf("amqp:link:redirect"));
+
+ public static final LinkError STOLEN = new LinkError(Symbol.valueOf("amqp:link:stolen"));
+
+
+
+ private LinkError(Symbol val)
+ {
+ _val = val;
+ }
+
+ public Symbol getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == DETACH_FORCED)
+ {
+ return "detach-forced";
+ }
+
+ if(this == TRANSFER_LIMIT_EXCEEDED)
+ {
+ return "transfer-limit-exceeded";
+ }
+
+ if(this == MESSAGE_SIZE_EXCEEDED)
+ {
+ return "message-size-exceeded";
+ }
+
+ if(this == REDIRECT)
+ {
+ return "redirect";
+ }
+
+ if(this == STOLEN)
+ {
+ return "stolen";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static LinkError valueOf(Object obj)
+ {
+ Symbol val = (Symbol) obj;
+
+ if(DETACH_FORCED._val.equals(val))
+ {
+ return DETACH_FORCED;
+ }
+
+ if(TRANSFER_LIMIT_EXCEEDED._val.equals(val))
+ {
+ return TRANSFER_LIMIT_EXCEEDED;
+ }
+
+ if(MESSAGE_SIZE_EXCEEDED._val.equals(val))
+ {
+ return MESSAGE_SIZE_EXCEEDED;
+ }
+
+ if(REDIRECT._val.equals(val))
+ {
+ return REDIRECT;
+ }
+
+ if(STOLEN._val.equals(val))
+ {
+ return STOLEN;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Open.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Open.java
new file mode 100644
index 0000000000..cabee25c73
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Open.java
@@ -0,0 +1,281 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+
+import java.util.Map;
+
+
+import java.nio.ByteBuffer;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Open
+ implements FrameBody
+ {
+
+
+ private ByteBuffer _payload;
+
+ private String _containerId;
+
+ private String _hostname;
+
+ private UnsignedInteger _maxFrameSize;
+
+ private UnsignedShort _channelMax;
+
+ private UnsignedInteger _idleTimeOut;
+
+ private Symbol[] _outgoingLocales;
+
+ private Symbol[] _incomingLocales;
+
+ private Symbol[] _offeredCapabilities;
+
+ private Symbol[] _desiredCapabilities;
+
+ private Map _properties;
+
+ public String getContainerId()
+ {
+ return _containerId;
+ }
+
+ public void setContainerId(String containerId)
+ {
+ _containerId = containerId;
+ }
+
+ public String getHostname()
+ {
+ return _hostname;
+ }
+
+ public void setHostname(String hostname)
+ {
+ _hostname = hostname;
+ }
+
+ public UnsignedInteger getMaxFrameSize()
+ {
+ return _maxFrameSize;
+ }
+
+ public void setMaxFrameSize(UnsignedInteger maxFrameSize)
+ {
+ _maxFrameSize = maxFrameSize;
+ }
+
+ public UnsignedShort getChannelMax()
+ {
+ return _channelMax;
+ }
+
+ public void setChannelMax(UnsignedShort channelMax)
+ {
+ _channelMax = channelMax;
+ }
+
+ public UnsignedInteger getIdleTimeOut()
+ {
+ return _idleTimeOut;
+ }
+
+ public void setIdleTimeOut(UnsignedInteger idleTimeOut)
+ {
+ _idleTimeOut = idleTimeOut;
+ }
+
+ public Symbol[] getOutgoingLocales()
+ {
+ return _outgoingLocales;
+ }
+
+ public void setOutgoingLocales(Symbol[] outgoingLocales)
+ {
+ _outgoingLocales = outgoingLocales;
+ }
+
+ public Symbol[] getIncomingLocales()
+ {
+ return _incomingLocales;
+ }
+
+ public void setIncomingLocales(Symbol[] incomingLocales)
+ {
+ _incomingLocales = incomingLocales;
+ }
+
+ public Symbol[] getOfferedCapabilities()
+ {
+ return _offeredCapabilities;
+ }
+
+ public void setOfferedCapabilities(Symbol[] offeredCapabilities)
+ {
+ _offeredCapabilities = offeredCapabilities;
+ }
+
+ public Symbol[] getDesiredCapabilities()
+ {
+ return _desiredCapabilities;
+ }
+
+ public void setDesiredCapabilities(Symbol[] desiredCapabilities)
+ {
+ _desiredCapabilities = desiredCapabilities;
+ }
+
+ public Map getProperties()
+ {
+ return _properties;
+ }
+
+ public void setProperties(Map properties)
+ {
+ _properties = properties;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Open{");
+ final int origLength = builder.length();
+
+ if(_containerId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("containerId=").append(_containerId);
+ }
+
+ if(_hostname != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("hostname=").append(_hostname);
+ }
+
+ if(_maxFrameSize != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("maxFrameSize=").append(_maxFrameSize);
+ }
+
+ if(_channelMax != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("channelMax=").append(_channelMax);
+ }
+
+ if(_idleTimeOut != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("idleTimeOut=").append(_idleTimeOut);
+ }
+
+ if(_outgoingLocales != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("outgoingLocales=").append(_outgoingLocales);
+ }
+
+ if(_incomingLocales != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("incomingLocales=").append(_incomingLocales);
+ }
+
+ if(_offeredCapabilities != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("offeredCapabilities=").append(_offeredCapabilities);
+ }
+
+ if(_desiredCapabilities != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("desiredCapabilities=").append(_desiredCapabilities);
+ }
+
+ if(_properties != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("properties=").append(_properties);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(short channel, ConnectionEndpoint conn)
+ {
+ conn.receiveOpen(channel, this);
+ }
+
+ public void setPayload(ByteBuffer payload)
+ {
+ _payload = payload;
+ }
+
+ public ByteBuffer getPayload()
+ {
+ return _payload;
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/ReceiverSettleMode.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/ReceiverSettleMode.java
new file mode 100644
index 0000000000..53f0f2b931
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/ReceiverSettleMode.java
@@ -0,0 +1,95 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class ReceiverSettleMode
+ implements RestrictedType<UnsignedByte>
+
+ {
+
+
+
+ private final UnsignedByte _val;
+
+
+ public static final ReceiverSettleMode FIRST = new ReceiverSettleMode(UnsignedByte.valueOf((byte) 0));
+
+ public static final ReceiverSettleMode SECOND = new ReceiverSettleMode(UnsignedByte.valueOf((byte) 1));
+
+
+
+ private ReceiverSettleMode(UnsignedByte val)
+ {
+ _val = val;
+ }
+
+ public UnsignedByte getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == FIRST)
+ {
+ return "first";
+ }
+
+ if(this == SECOND)
+ {
+ return "second";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static ReceiverSettleMode valueOf(Object obj)
+ {
+ UnsignedByte val = (UnsignedByte) obj;
+
+ if(FIRST._val.equals(val))
+ {
+ return FIRST;
+ }
+
+ if(SECOND._val.equals(val))
+ {
+ return SECOND;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Role.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Role.java
new file mode 100644
index 0000000000..55be00b3d7
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Role.java
@@ -0,0 +1,95 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Role
+ implements RestrictedType<Boolean>
+
+ {
+
+
+
+ private final boolean _val;
+
+
+ public static final Role SENDER = new Role(false);
+
+ public static final Role RECEIVER = new Role(true);
+
+
+
+ private Role(boolean val)
+ {
+ _val = val;
+ }
+
+ public Boolean getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == SENDER)
+ {
+ return "sender";
+ }
+
+ if(this == RECEIVER)
+ {
+ return "receiver";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static Role valueOf(Object obj)
+ {
+ boolean val = (Boolean) obj;
+
+ if(SENDER._val == (val))
+ {
+ return SENDER;
+ }
+
+ if(RECEIVER._val == (val))
+ {
+ return RECEIVER;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/SenderSettleMode.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/SenderSettleMode.java
new file mode 100644
index 0000000000..528ec69dbc
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/SenderSettleMode.java
@@ -0,0 +1,107 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class SenderSettleMode
+ implements RestrictedType<UnsignedByte>
+
+ {
+
+
+
+ private final UnsignedByte _val;
+
+
+ public static final SenderSettleMode UNSETTLED = new SenderSettleMode(UnsignedByte.valueOf((byte) 0));
+
+ public static final SenderSettleMode SETTLED = new SenderSettleMode(UnsignedByte.valueOf((byte) 1));
+
+ public static final SenderSettleMode MIXED = new SenderSettleMode(UnsignedByte.valueOf((byte) 2));
+
+
+
+ private SenderSettleMode(UnsignedByte val)
+ {
+ _val = val;
+ }
+
+ public UnsignedByte getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == UNSETTLED)
+ {
+ return "unsettled";
+ }
+
+ if(this == SETTLED)
+ {
+ return "settled";
+ }
+
+ if(this == MIXED)
+ {
+ return "mixed";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static SenderSettleMode valueOf(Object obj)
+ {
+ UnsignedByte val = (UnsignedByte) obj;
+
+ if(UNSETTLED._val.equals(val))
+ {
+ return UNSETTLED;
+ }
+
+ if(SETTLED._val.equals(val))
+ {
+ return SETTLED;
+ }
+
+ if(MIXED._val.equals(val))
+ {
+ return MIXED;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/SessionError.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/SessionError.java
new file mode 100644
index 0000000000..b7b233c879
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/SessionError.java
@@ -0,0 +1,119 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class SessionError
+ implements ErrorCondition, RestrictedType<Symbol>
+
+ {
+
+
+
+ private final Symbol _val;
+
+
+ public static final SessionError WINDOW_VIOLATION = new SessionError(Symbol.valueOf("amqp:session:window-violation"));
+
+ public static final SessionError ERRANT_LINK = new SessionError(Symbol.valueOf("amqp:session:errant-link"));
+
+ public static final SessionError HANDLE_IN_USE = new SessionError(Symbol.valueOf("amqp:session:handle-in-use"));
+
+ public static final SessionError UNATTACHED_HANDLE = new SessionError(Symbol.valueOf("amqp:session:unattached-handle"));
+
+
+
+ private SessionError(Symbol val)
+ {
+ _val = val;
+ }
+
+ public Symbol getValue()
+ {
+ return _val;
+ }
+
+ public String toString()
+ {
+
+ if(this == WINDOW_VIOLATION)
+ {
+ return "window-violation";
+ }
+
+ if(this == ERRANT_LINK)
+ {
+ return "errant-link";
+ }
+
+ if(this == HANDLE_IN_USE)
+ {
+ return "handle-in-use";
+ }
+
+ if(this == UNATTACHED_HANDLE)
+ {
+ return "unattached-handle";
+ }
+
+ else
+ {
+ return String.valueOf(_val);
+ }
+ }
+
+ public static SessionError valueOf(Object obj)
+ {
+ Symbol val = (Symbol) obj;
+
+ if(WINDOW_VIOLATION._val.equals(val))
+ {
+ return WINDOW_VIOLATION;
+ }
+
+ if(ERRANT_LINK._val.equals(val))
+ {
+ return ERRANT_LINK;
+ }
+
+ if(HANDLE_IN_USE._val.equals(val))
+ {
+ return HANDLE_IN_USE;
+ }
+
+ if(UNATTACHED_HANDLE._val.equals(val))
+ {
+ return UNATTACHED_HANDLE;
+ }
+
+ // TODO ERROR
+ return null;
+ }
+
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Transfer.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Transfer.java
new file mode 100644
index 0000000000..a58db63a1f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/Transfer.java
@@ -0,0 +1,299 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport;
+
+
+import org.apache.qpid.amqp_1_0.transport.ConnectionEndpoint;
+
+
+import java.nio.ByteBuffer;
+
+
+import org.apache.qpid.amqp_1_0.type.*;
+
+public class Transfer
+ implements FrameBody
+ {
+
+
+ private ByteBuffer _payload;
+
+ private UnsignedInteger _handle;
+
+ private UnsignedInteger _deliveryId;
+
+ private Binary _deliveryTag;
+
+ private UnsignedInteger _messageFormat;
+
+ private Boolean _settled;
+
+ private Boolean _more;
+
+ private ReceiverSettleMode _rcvSettleMode;
+
+ private DeliveryState _state;
+
+ private Boolean _resume;
+
+ private Boolean _aborted;
+
+ private Boolean _batchable;
+
+ public UnsignedInteger getHandle()
+ {
+ return _handle;
+ }
+
+ public void setHandle(UnsignedInteger handle)
+ {
+ _handle = handle;
+ }
+
+ public UnsignedInteger getDeliveryId()
+ {
+ return _deliveryId;
+ }
+
+ public void setDeliveryId(UnsignedInteger deliveryId)
+ {
+ _deliveryId = deliveryId;
+ }
+
+ public Binary getDeliveryTag()
+ {
+ return _deliveryTag;
+ }
+
+ public void setDeliveryTag(Binary deliveryTag)
+ {
+ _deliveryTag = deliveryTag;
+ }
+
+ public UnsignedInteger getMessageFormat()
+ {
+ return _messageFormat;
+ }
+
+ public void setMessageFormat(UnsignedInteger messageFormat)
+ {
+ _messageFormat = messageFormat;
+ }
+
+ public Boolean getSettled()
+ {
+ return _settled;
+ }
+
+ public void setSettled(Boolean settled)
+ {
+ _settled = settled;
+ }
+
+ public Boolean getMore()
+ {
+ return _more;
+ }
+
+ public void setMore(Boolean more)
+ {
+ _more = more;
+ }
+
+ public ReceiverSettleMode getRcvSettleMode()
+ {
+ return _rcvSettleMode;
+ }
+
+ public void setRcvSettleMode(ReceiverSettleMode rcvSettleMode)
+ {
+ _rcvSettleMode = rcvSettleMode;
+ }
+
+ public DeliveryState getState()
+ {
+ return _state;
+ }
+
+ public void setState(DeliveryState state)
+ {
+ _state = state;
+ }
+
+ public Boolean getResume()
+ {
+ return _resume;
+ }
+
+ public void setResume(Boolean resume)
+ {
+ _resume = resume;
+ }
+
+ public Boolean getAborted()
+ {
+ return _aborted;
+ }
+
+ public void setAborted(Boolean aborted)
+ {
+ _aborted = aborted;
+ }
+
+ public Boolean getBatchable()
+ {
+ return _batchable;
+ }
+
+ public void setBatchable(Boolean batchable)
+ {
+ _batchable = batchable;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder("Transfer{");
+ final int origLength = builder.length();
+
+ if(_handle != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("handle=").append(_handle);
+ }
+
+ if(_deliveryId != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("deliveryId=").append(_deliveryId);
+ }
+
+ if(_deliveryTag != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("deliveryTag=").append(_deliveryTag);
+ }
+
+ if(_messageFormat != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("messageFormat=").append(_messageFormat);
+ }
+
+ if(_settled != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("settled=").append(_settled);
+ }
+
+ if(_more != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("more=").append(_more);
+ }
+
+ if(_rcvSettleMode != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("rcvSettleMode=").append(_rcvSettleMode);
+ }
+
+ if(_state != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("state=").append(_state);
+ }
+
+ if(_resume != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("resume=").append(_resume);
+ }
+
+ if(_aborted != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("aborted=").append(_aborted);
+ }
+
+ if(_batchable != null)
+ {
+ if(builder.length() != origLength)
+ {
+ builder.append(',');
+ }
+ builder.append("batchable=").append(_batchable);
+ }
+
+ builder.append('}');
+ return builder.toString();
+ }
+
+ public void invoke(short channel, ConnectionEndpoint conn)
+ {
+ conn.receiveTransfer(channel, this);
+ }
+
+ public void setPayload(ByteBuffer payload)
+ {
+ _payload = payload;
+ }
+
+ public ByteBuffer getPayload()
+ {
+ return _payload;
+ }
+
+
+ }
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/AttachConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/AttachConstructor.java
new file mode 100644
index 0000000000..0df84ac820
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/AttachConstructor.java
@@ -0,0 +1,465 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Attach;
+
+
+import java.util.List;
+import java.util.Map;
+
+public class AttachConstructor extends DescribedTypeConstructor<Attach>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:attach:list"),UnsignedLong.valueOf(0x0000000000000012L),
+ };
+
+ private static final AttachConstructor INSTANCE = new AttachConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Attach construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Attach obj = new Attach();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setName( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setHandle( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setRole( Role.valueOf( val ) );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setSndSettleMode( SenderSettleMode.valueOf( val ) );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setRcvSettleMode( ReceiverSettleMode.valueOf( val ) );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setSource( (Source) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setTarget( (Target) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setUnsettled( (Map) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setIncompleteUnsettled( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setInitialDeliveryCount( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setMaxMessageSize( (UnsignedLong) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setOfferedCapabilities( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setOfferedCapabilities( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setDesiredCapabilities( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setDesiredCapabilities( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setProperties( (Map) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/AttachWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/AttachWriter.java
new file mode 100644
index 0000000000..0b67635dc0
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/AttachWriter.java
@@ -0,0 +1,254 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transport.Attach;
+
+public class AttachWriter extends AbstractDescribedTypeWriter<Attach>
+{
+ private Attach _value;
+ private int _count = -1;
+
+ public AttachWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Attach value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getProperties() != null)
+ {
+ return 14;
+ }
+
+ if( _value.getDesiredCapabilities() != null)
+ {
+ return 13;
+ }
+
+ if( _value.getOfferedCapabilities() != null)
+ {
+ return 12;
+ }
+
+ if( _value.getMaxMessageSize() != null)
+ {
+ return 11;
+ }
+
+ if( _value.getInitialDeliveryCount() != null)
+ {
+ return 10;
+ }
+
+ if( _value.getIncompleteUnsettled() != null)
+ {
+ return 9;
+ }
+
+ if( _value.getUnsettled() != null)
+ {
+ return 8;
+ }
+
+ if( _value.getTarget() != null)
+ {
+ return 7;
+ }
+
+ if( _value.getSource() != null)
+ {
+ return 6;
+ }
+
+ if( _value.getRcvSettleMode() != null)
+ {
+ return 5;
+ }
+
+ if( _value.getSndSettleMode() != null)
+ {
+ return 4;
+ }
+
+ if( _value.getRole() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getHandle() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getName() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000012L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Attach>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Attach value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getName();
+
+ case 1:
+ return _value.getHandle();
+
+ case 2:
+ return _value.getRole();
+
+ case 3:
+ return _value.getSndSettleMode();
+
+ case 4:
+ return _value.getRcvSettleMode();
+
+ case 5:
+ return _value.getSource();
+
+ case 6:
+ return _value.getTarget();
+
+ case 7:
+ return _value.getUnsettled();
+
+ case 8:
+ return _value.getIncompleteUnsettled();
+
+ case 9:
+ return _value.getInitialDeliveryCount();
+
+ case 10:
+ return _value.getMaxMessageSize();
+
+ case 11:
+ return _value.getOfferedCapabilities();
+
+ case 12:
+ return _value.getDesiredCapabilities();
+
+ case 13:
+ return _value.getProperties();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Attach> FACTORY = new Factory<Attach>()
+ {
+
+ public ValueWriter<Attach> newInstance(Registry registry)
+ {
+ return new AttachWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Attach.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/BeginConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/BeginConstructor.java
new file mode 100644
index 0000000000..94470c5139
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/BeginConstructor.java
@@ -0,0 +1,303 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Begin;
+
+
+import java.util.List;
+import java.util.Map;
+
+public class BeginConstructor extends DescribedTypeConstructor<Begin>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:begin:list"),UnsignedLong.valueOf(0x0000000000000011L),
+ };
+
+ private static final BeginConstructor INSTANCE = new BeginConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Begin construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Begin obj = new Begin();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setRemoteChannel( (UnsignedShort) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setNextOutgoingId( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setIncomingWindow( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setOutgoingWindow( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setHandleMax( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setOfferedCapabilities( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setOfferedCapabilities( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setDesiredCapabilities( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setDesiredCapabilities( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setProperties( (Map) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/BeginWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/BeginWriter.java
new file mode 100644
index 0000000000..84abf6698e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/BeginWriter.java
@@ -0,0 +1,206 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transport.Begin;
+
+public class BeginWriter extends AbstractDescribedTypeWriter<Begin>
+{
+ private Begin _value;
+ private int _count = -1;
+
+ public BeginWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Begin value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getProperties() != null)
+ {
+ return 8;
+ }
+
+ if( _value.getDesiredCapabilities() != null)
+ {
+ return 7;
+ }
+
+ if( _value.getOfferedCapabilities() != null)
+ {
+ return 6;
+ }
+
+ if( _value.getHandleMax() != null)
+ {
+ return 5;
+ }
+
+ if( _value.getOutgoingWindow() != null)
+ {
+ return 4;
+ }
+
+ if( _value.getIncomingWindow() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getNextOutgoingId() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getRemoteChannel() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000011L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Begin>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Begin value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getRemoteChannel();
+
+ case 1:
+ return _value.getNextOutgoingId();
+
+ case 2:
+ return _value.getIncomingWindow();
+
+ case 3:
+ return _value.getOutgoingWindow();
+
+ case 4:
+ return _value.getHandleMax();
+
+ case 5:
+ return _value.getOfferedCapabilities();
+
+ case 6:
+ return _value.getDesiredCapabilities();
+
+ case 7:
+ return _value.getProperties();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Begin> FACTORY = new Factory<Begin>()
+ {
+
+ public ValueWriter<Begin> newInstance(Registry registry)
+ {
+ return new BeginWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Begin.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/CloseConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/CloseConstructor.java
new file mode 100644
index 0000000000..69544dc96f
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/CloseConstructor.java
@@ -0,0 +1,99 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Close;
+
+
+import java.util.List;
+
+public class CloseConstructor extends DescribedTypeConstructor<Close>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:close:list"),UnsignedLong.valueOf(0x0000000000000018L),
+ };
+
+ private static final CloseConstructor INSTANCE = new CloseConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Close construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Close obj = new Close();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setError( (org.apache.qpid.amqp_1_0.type.transport.Error) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/CloseWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/CloseWriter.java
new file mode 100644
index 0000000000..96313efcb9
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/CloseWriter.java
@@ -0,0 +1,150 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transport.Close;
+
+public class CloseWriter extends AbstractDescribedTypeWriter<Close>
+{
+ private Close _value;
+ private int _count = -1;
+
+ public CloseWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Close value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getError() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000018L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Close>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Close value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getError();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Close> FACTORY = new Factory<Close>()
+ {
+
+ public ValueWriter<Close> newInstance(Registry registry)
+ {
+ return new CloseWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Close.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DetachConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DetachConstructor.java
new file mode 100644
index 0000000000..8d90d39769
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DetachConstructor.java
@@ -0,0 +1,153 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Detach;
+
+
+import java.util.List;
+
+public class DetachConstructor extends DescribedTypeConstructor<Detach>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:detach:list"),UnsignedLong.valueOf(0x0000000000000016L),
+ };
+
+ private static final DetachConstructor INSTANCE = new DetachConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Detach construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Detach obj = new Detach();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setHandle( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setClosed( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setError( (org.apache.qpid.amqp_1_0.type.transport.Error) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DetachWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DetachWriter.java
new file mode 100644
index 0000000000..620f087f98
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DetachWriter.java
@@ -0,0 +1,166 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transport.Detach;
+
+public class DetachWriter extends AbstractDescribedTypeWriter<Detach>
+{
+ private Detach _value;
+ private int _count = -1;
+
+ public DetachWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Detach value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getError() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getClosed() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getHandle() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000016L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Detach>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Detach value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getHandle();
+
+ case 1:
+ return _value.getClosed();
+
+ case 2:
+ return _value.getError();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Detach> FACTORY = new Factory<Detach>()
+ {
+
+ public ValueWriter<Detach> newInstance(Registry registry)
+ {
+ return new DetachWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Detach.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DispositionConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DispositionConstructor.java
new file mode 100644
index 0000000000..928f54ea97
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DispositionConstructor.java
@@ -0,0 +1,234 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Disposition;
+
+
+import java.util.List;
+
+public class DispositionConstructor extends DescribedTypeConstructor<Disposition>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:disposition:list"),UnsignedLong.valueOf(0x0000000000000015L),
+ };
+
+ private static final DispositionConstructor INSTANCE = new DispositionConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Disposition construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Disposition obj = new Disposition();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setRole( Role.valueOf( val ) );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setFirst( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setLast( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setSettled( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setState( (DeliveryState) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setBatchable( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DispositionWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DispositionWriter.java
new file mode 100644
index 0000000000..3bfdf840ab
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/DispositionWriter.java
@@ -0,0 +1,190 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transport.Disposition;
+
+public class DispositionWriter extends AbstractDescribedTypeWriter<Disposition>
+{
+ private Disposition _value;
+ private int _count = -1;
+
+ public DispositionWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Disposition value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getBatchable() != null)
+ {
+ return 6;
+ }
+
+ if( _value.getState() != null)
+ {
+ return 5;
+ }
+
+ if( _value.getSettled() != null)
+ {
+ return 4;
+ }
+
+ if( _value.getLast() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getFirst() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getRole() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000015L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Disposition>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Disposition value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getRole();
+
+ case 1:
+ return _value.getFirst();
+
+ case 2:
+ return _value.getLast();
+
+ case 3:
+ return _value.getSettled();
+
+ case 4:
+ return _value.getState();
+
+ case 5:
+ return _value.getBatchable();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Disposition> FACTORY = new Factory<Disposition>()
+ {
+
+ public ValueWriter<Disposition> newInstance(Registry registry)
+ {
+ return new DispositionWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Disposition.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/EndConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/EndConstructor.java
new file mode 100644
index 0000000000..0f8fe63d55
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/EndConstructor.java
@@ -0,0 +1,99 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.End;
+
+
+import java.util.List;
+
+public class EndConstructor extends DescribedTypeConstructor<End>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:end:list"),UnsignedLong.valueOf(0x0000000000000017L),
+ };
+
+ private static final EndConstructor INSTANCE = new EndConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public End construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ End obj = new End();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setError( (org.apache.qpid.amqp_1_0.type.transport.Error) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/EndWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/EndWriter.java
new file mode 100644
index 0000000000..af6a11ae09
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/EndWriter.java
@@ -0,0 +1,150 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transport.End;
+
+public class EndWriter extends AbstractDescribedTypeWriter<End>
+{
+ private End _value;
+ private int _count = -1;
+
+ public EndWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final End value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getError() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000017L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<End>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final End value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getError();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<End> FACTORY = new Factory<End>()
+ {
+
+ public ValueWriter<End> newInstance(Registry registry)
+ {
+ return new EndWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(End.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/ErrorConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/ErrorConstructor.java
new file mode 100644
index 0000000000..6d745adb7e
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/ErrorConstructor.java
@@ -0,0 +1,169 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transaction.TransactionErrors;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+
+
+import java.util.List;
+import java.util.Map;
+
+public class ErrorConstructor extends DescribedTypeConstructor<org.apache.qpid.amqp_1_0.type.transport.Error>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:error:list"),UnsignedLong.valueOf(0x000000000000001dL),
+ };
+
+ private static final ErrorConstructor INSTANCE = new ErrorConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public org.apache.qpid.amqp_1_0.type.transport.Error construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ org.apache.qpid.amqp_1_0.type.transport.Error obj = new org.apache.qpid.amqp_1_0.type.transport.Error();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+ if(val instanceof ErrorCondition)
+ {
+ obj.setCondition( (ErrorCondition) val );
+ }
+ else if(val instanceof Symbol)
+ {
+ ErrorCondition condition = null;
+ condition = AmqpError.valueOf(val);
+ if(condition == null)
+ {
+ condition = ConnectionError.valueOf(val);
+ if(condition == null)
+ {
+ condition = SessionError.valueOf(val);
+ if(condition == null)
+ {
+ condition = LinkError.valueOf(val);
+ if(condition == null)
+ {
+ condition = TransactionErrors.valueOf(val);
+ }
+ }
+ }
+ }
+ obj.setCondition(condition);
+ }
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDescription( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setInfo( (Map) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/ErrorWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/ErrorWriter.java
new file mode 100644
index 0000000000..6c5ebc5dc6
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/ErrorWriter.java
@@ -0,0 +1,166 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transport.Error;
+
+public class ErrorWriter extends AbstractDescribedTypeWriter<Error>
+{
+ private Error _value;
+ private int _count = -1;
+
+ public ErrorWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Error value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getInfo() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getDescription() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getCondition() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x000000000000001dL);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Error>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Error value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getCondition();
+
+ case 1:
+ return _value.getDescription();
+
+ case 2:
+ return _value.getInfo();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Error> FACTORY = new Factory<Error>()
+ {
+
+ public ValueWriter<Error> newInstance(Registry registry)
+ {
+ return new ErrorWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Error.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/FlowConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/FlowConstructor.java
new file mode 100644
index 0000000000..406b5a327a
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/FlowConstructor.java
@@ -0,0 +1,370 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Flow;
+
+
+import java.util.List;
+import java.util.Map;
+
+public class FlowConstructor extends DescribedTypeConstructor<Flow>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:flow:list"),UnsignedLong.valueOf(0x0000000000000013L),
+ };
+
+ private static final FlowConstructor INSTANCE = new FlowConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Flow construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Flow obj = new Flow();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setNextIncomingId( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setIncomingWindow( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setNextOutgoingId( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setOutgoingWindow( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setHandle( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDeliveryCount( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setLinkCredit( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setAvailable( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDrain( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setEcho( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setProperties( (Map) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/FlowWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/FlowWriter.java
new file mode 100644
index 0000000000..a866491cea
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/FlowWriter.java
@@ -0,0 +1,230 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transport.Flow;
+
+public class FlowWriter extends AbstractDescribedTypeWriter<Flow>
+{
+ private Flow _value;
+ private int _count = -1;
+
+ public FlowWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Flow value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getProperties() != null)
+ {
+ return 11;
+ }
+
+ if( _value.getEcho() != null)
+ {
+ return 10;
+ }
+
+ if( _value.getDrain() != null)
+ {
+ return 9;
+ }
+
+ if( _value.getAvailable() != null)
+ {
+ return 8;
+ }
+
+ if( _value.getLinkCredit() != null)
+ {
+ return 7;
+ }
+
+ if( _value.getDeliveryCount() != null)
+ {
+ return 6;
+ }
+
+ if( _value.getHandle() != null)
+ {
+ return 5;
+ }
+
+ if( _value.getOutgoingWindow() != null)
+ {
+ return 4;
+ }
+
+ if( _value.getNextOutgoingId() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getIncomingWindow() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getNextIncomingId() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000013L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Flow>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Flow value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getNextIncomingId();
+
+ case 1:
+ return _value.getIncomingWindow();
+
+ case 2:
+ return _value.getNextOutgoingId();
+
+ case 3:
+ return _value.getOutgoingWindow();
+
+ case 4:
+ return _value.getHandle();
+
+ case 5:
+ return _value.getDeliveryCount();
+
+ case 6:
+ return _value.getLinkCredit();
+
+ case 7:
+ return _value.getAvailable();
+
+ case 8:
+ return _value.getDrain();
+
+ case 9:
+ return _value.getEcho();
+
+ case 10:
+ return _value.getProperties();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Flow> FACTORY = new Factory<Flow>()
+ {
+
+ public ValueWriter<Flow> newInstance(Registry registry)
+ {
+ return new FlowWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Flow.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/OpenConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/OpenConstructor.java
new file mode 100644
index 0000000000..ba2df038e4
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/OpenConstructor.java
@@ -0,0 +1,371 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Open;
+
+
+import java.util.List;
+import java.util.Map;
+
+public class OpenConstructor extends DescribedTypeConstructor<Open>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:open:list"),UnsignedLong.valueOf(0x0000000000000010L),
+ };
+
+ private static final OpenConstructor INSTANCE = new OpenConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Open construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Open obj = new Open();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setContainerId( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setHostname( (String) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setMaxFrameSize( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setChannelMax( (UnsignedShort) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setIdleTimeOut( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setOutgoingLocales( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setOutgoingLocales( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setIncomingLocales( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setIncomingLocales( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setOfferedCapabilities( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setOfferedCapabilities( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+
+ if (val instanceof Symbol[] )
+ {
+ obj.setDesiredCapabilities( (Symbol[]) val );
+ }
+ else
+ {
+ try
+ {
+ obj.setDesiredCapabilities( new Symbol[] { (Symbol) val } );
+ }
+ catch(ClassCastException e)
+ {
+ // TODO Error
+ }
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setProperties( (Map) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/OpenWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/OpenWriter.java
new file mode 100644
index 0000000000..f512384a20
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/OpenWriter.java
@@ -0,0 +1,222 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transport.Open;
+
+public class OpenWriter extends AbstractDescribedTypeWriter<Open>
+{
+ private Open _value;
+ private int _count = -1;
+
+ public OpenWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Open value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getProperties() != null)
+ {
+ return 10;
+ }
+
+ if( _value.getDesiredCapabilities() != null)
+ {
+ return 9;
+ }
+
+ if( _value.getOfferedCapabilities() != null)
+ {
+ return 8;
+ }
+
+ if( _value.getIncomingLocales() != null)
+ {
+ return 7;
+ }
+
+ if( _value.getOutgoingLocales() != null)
+ {
+ return 6;
+ }
+
+ if( _value.getIdleTimeOut() != null)
+ {
+ return 5;
+ }
+
+ if( _value.getChannelMax() != null)
+ {
+ return 4;
+ }
+
+ if( _value.getMaxFrameSize() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getHostname() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getContainerId() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000010L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Open>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Open value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getContainerId();
+
+ case 1:
+ return _value.getHostname();
+
+ case 2:
+ return _value.getMaxFrameSize();
+
+ case 3:
+ return _value.getChannelMax();
+
+ case 4:
+ return _value.getIdleTimeOut();
+
+ case 5:
+ return _value.getOutgoingLocales();
+
+ case 6:
+ return _value.getIncomingLocales();
+
+ case 7:
+ return _value.getOfferedCapabilities();
+
+ case 8:
+ return _value.getDesiredCapabilities();
+
+ case 9:
+ return _value.getProperties();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Open> FACTORY = new Factory<Open>()
+ {
+
+ public ValueWriter<Open> newInstance(Registry registry)
+ {
+ return new OpenWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Open.class, FACTORY);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/TransferConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/TransferConstructor.java
new file mode 100644
index 0000000000..ad3812bbdc
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/TransferConstructor.java
@@ -0,0 +1,369 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.amqp_1_0.type.*;
+import org.apache.qpid.amqp_1_0.type.transport.*;
+import org.apache.qpid.amqp_1_0.type.transport.Transfer;
+
+
+import java.util.List;
+
+public class TransferConstructor extends DescribedTypeConstructor<Transfer>
+{
+ private static final Object[] DESCRIPTORS =
+ {
+ Symbol.valueOf("amqp:transfer:list"),UnsignedLong.valueOf(0x0000000000000014L),
+ };
+
+ private static final TransferConstructor INSTANCE = new TransferConstructor();
+
+ public static void register(DescribedTypeConstructorRegistry registry)
+ {
+ for(Object descriptor : DESCRIPTORS)
+ {
+ registry.register(descriptor, INSTANCE);
+ }
+ }
+
+ public Transfer construct(Object underlying)
+ {
+ if(underlying instanceof List)
+ {
+ List list = (List) underlying;
+ Transfer obj = new Transfer();
+ int position = 0;
+ final int size = list.size();
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setHandle( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDeliveryId( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setDeliveryTag( (Binary) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setMessageFormat( (UnsignedInteger) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setSettled( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setMore( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setRcvSettleMode( ReceiverSettleMode.valueOf( val ) );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setState( (DeliveryState) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setResume( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setAborted( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+ if(position < size)
+ {
+ Object val = list.get(position);
+ position++;
+
+ if(val != null)
+ {
+
+ try
+ {
+ obj.setBatchable( (Boolean) val );
+ }
+ catch(ClassCastException e)
+ {
+
+ // TODO Error
+ }
+
+ }
+
+
+ }
+ else
+ {
+ return obj;
+ }
+
+
+ return obj;
+ }
+ else
+ {
+ // TODO - error
+ return null;
+ }
+ }
+
+
+}
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/TransferWriter.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/TransferWriter.java
new file mode 100644
index 0000000000..f2252cfc4a
--- /dev/null
+++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/transport/codec/TransferWriter.java
@@ -0,0 +1,230 @@
+
+/*
+*
+* 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.amqp_1_0.type.transport.codec;
+
+import org.apache.qpid.amqp_1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.amqp_1_0.codec.AbstractListWriter;
+import org.apache.qpid.amqp_1_0.codec.ValueWriter;
+
+import org.apache.qpid.amqp_1_0.type.UnsignedLong;
+import org.apache.qpid.amqp_1_0.type.transport.Transfer;
+
+public class TransferWriter extends AbstractDescribedTypeWriter<Transfer>
+{
+ private Transfer _value;
+ private int _count = -1;
+
+ public TransferWriter(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Transfer value)
+ {
+ _value = value;
+ _count = calculateCount();
+ }
+
+ private int calculateCount()
+ {
+
+
+ if( _value.getBatchable() != null)
+ {
+ return 11;
+ }
+
+ if( _value.getAborted() != null)
+ {
+ return 10;
+ }
+
+ if( _value.getResume() != null)
+ {
+ return 9;
+ }
+
+ if( _value.getState() != null)
+ {
+ return 8;
+ }
+
+ if( _value.getRcvSettleMode() != null)
+ {
+ return 7;
+ }
+
+ if( _value.getMore() != null)
+ {
+ return 6;
+ }
+
+ if( _value.getSettled() != null)
+ {
+ return 5;
+ }
+
+ if( _value.getMessageFormat() != null)
+ {
+ return 4;
+ }
+
+ if( _value.getDeliveryTag() != null)
+ {
+ return 3;
+ }
+
+ if( _value.getDeliveryId() != null)
+ {
+ return 2;
+ }
+
+ if( _value.getHandle() != null)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ protected void clear()
+ {
+ _value = null;
+ _count = -1;
+ }
+
+
+ protected Object getDescriptor()
+ {
+ return UnsignedLong.valueOf(0x0000000000000014L);
+ }
+
+ @Override
+ protected ValueWriter createDescribedWriter()
+ {
+ final Writer writer = new Writer(getRegistry());
+ writer.setValue(_value);
+ return writer;
+ }
+
+ private class Writer extends AbstractListWriter<Transfer>
+ {
+ private int _field;
+
+ public Writer(final Registry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ protected void onSetValue(final Transfer value)
+ {
+ reset();
+ }
+
+ @Override
+ protected int getCount()
+ {
+ return _count;
+ }
+
+ @Override
+ protected boolean hasNext()
+ {
+ return _field < _count;
+ }
+
+ @Override
+ protected Object next()
+ {
+ switch(_field++)
+ {
+
+ case 0:
+ return _value.getHandle();
+
+ case 1:
+ return _value.getDeliveryId();
+
+ case 2:
+ return _value.getDeliveryTag();
+
+ case 3:
+ return _value.getMessageFormat();
+
+ case 4:
+ return _value.getSettled();
+
+ case 5:
+ return _value.getMore();
+
+ case 6:
+ return _value.getRcvSettleMode();
+
+ case 7:
+ return _value.getState();
+
+ case 8:
+ return _value.getResume();
+
+ case 9:
+ return _value.getAborted();
+
+ case 10:
+ return _value.getBatchable();
+
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void clear()
+ {
+ }
+
+ @Override
+ protected void reset()
+ {
+ _field = 0;
+ }
+ }
+
+ private static Factory<Transfer> FACTORY = new Factory<Transfer>()
+ {
+
+ public ValueWriter<Transfer> newInstance(Registry registry)
+ {
+ return new TransferWriter(registry);
+ }
+ };
+
+ public static void register(ValueWriter.Registry registry)
+ {
+ registry.register(Transfer.class, FACTORY);
+ }
+
+}