This is an automated email from the ASF dual-hosted git repository. tabish pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git
The following commit(s) were added to refs/heads/main by this push: new c331e34a PROTON-2637 Remove excessive getEncoder calls and direct write nulls c331e34a is described below commit c331e34a129f3faab49b4cc943ddc4e4fc3fdc41 Author: Timothy Bish <tabish...@gmail.com> AuthorDate: Fri Oct 28 18:34:11 2022 -0400 PROTON-2637 Remove excessive getEncoder calls and direct write nulls Remove some redundant fetches of the encoder as it doesn't change during operation and direct write the null type byte in more cases as opposed to asking the encoder to do it. --- .../encoders/AbstractDescribedListTypeEncoder.java | 25 ++++++++----- .../encoders/AbstractDescribedMapTypeEncoder.java | 25 ++++++++----- .../encoders/messaging/AcceptedTypeEncoder.java | 3 +- .../ApplicationPropertiesTypeEncoder.java | 7 ++-- .../messaging/DeleteOnCloseTypeEncoder.java | 3 +- .../DeleteOnNoLinksOrMessagesTypeEncoder.java | 3 +- .../messaging/DeleteOnNoLinksTypeEncoder.java | 3 +- .../messaging/DeleteOnNoMessagesTypeEncoder.java | 3 +- .../messaging/DeliveryAnnotationsTypeEncoder.java | 7 ++-- .../encoders/messaging/FooterTypeEncoder.java | 7 ++-- .../encoders/messaging/HeaderTypeEncoder.java | 9 +++-- .../messaging/MessageAnnotationsTypeEncoder.java | 7 ++-- .../encoders/messaging/ModifiedTypeEncoder.java | 5 ++- .../encoders/messaging/PropertiesTypeEncoder.java | 29 ++++++++------- .../encoders/messaging/ReceivedTypeEncoder.java | 7 ++-- .../encoders/messaging/RejectedTypeEncoder.java | 5 ++- .../encoders/messaging/ReleasedTypeEncoder.java | 3 +- .../encoders/messaging/SourceTypeEncoder.java | 23 ++++++------ .../encoders/messaging/TargetTypeEncoder.java | 15 ++++---- .../security/SaslChallengeTypeEncoder.java | 5 ++- .../encoders/security/SaslInitTypeEncoder.java | 9 +++-- .../security/SaslMechanismsTypeEncoder.java | 5 ++- .../encoders/security/SaslOutcomeTypeEncoder.java | 7 ++-- .../encoders/security/SaslResponseTypeEncoder.java | 5 ++- .../transactions/CoordinatorTypeEncoder.java | 5 ++- .../encoders/transactions/DeclareTypeEncoder.java | 5 ++- .../encoders/transactions/DeclaredTypeEncoder.java | 5 ++- .../transactions/DischargeTypeEncoder.java | 5 ++- .../transactions/TransactionStateTypeEncoder.java | 7 ++-- .../encoders/transport/AttachTypeEncoder.java | 27 +++++++------- .../codec/encoders/transport/BeginTypeEncoder.java | 19 +++++----- .../codec/encoders/transport/CloseTypeEncoder.java | 5 ++- .../encoders/transport/DetachTypeEncoder.java | 7 ++-- .../encoders/transport/DispositionTypeEncoder.java | 9 +++-- .../codec/encoders/transport/EndTypeEncoder.java | 5 ++- .../transport/ErrorConditionTypeEncoder.java | 9 +++-- .../codec/encoders/transport/FlowTypeEncoder.java | 21 ++++++----- .../codec/encoders/transport/OpenTypeEncoder.java | 43 +++++++++++----------- .../encoders/transport/TransferTypeEncoder.java | 15 ++++---- 39 files changed, 228 insertions(+), 179 deletions(-) diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/AbstractDescribedListTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/AbstractDescribedListTypeEncoder.java index aa29f2ae..ea3ddf2f 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/AbstractDescribedListTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/AbstractDescribedListTypeEncoder.java @@ -18,6 +18,7 @@ package org.apache.qpid.protonj2.codec.encoders; import org.apache.qpid.protonj2.buffer.ProtonBuffer; import org.apache.qpid.protonj2.codec.EncodeException; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; @@ -55,10 +56,12 @@ public abstract class AbstractDescribedListTypeEncoder<V> extends AbstractDescri * the element index that needs to be written * @param buffer * the buffer to write the element to + * @param encoder + * the current Encoder value to use. * @param state * the current EncoderState value to use. */ - public abstract void writeElement(V source, int index, ProtonBuffer buffer, EncoderState state); + public abstract void writeElement(V source, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state); /** * Gets the number of elements that will result when this type is encoded @@ -83,8 +86,10 @@ public abstract class AbstractDescribedListTypeEncoder<V> extends AbstractDescri @Override public void writeType(ProtonBuffer buffer, EncoderState state, V value) { + final Encoder encoder = state.getEncoder(); + buffer.writeByte(EncodingCodes.DESCRIBED_TYPE_INDICATOR); - state.getEncoder().writeUnsignedLong(buffer, state, getDescriptorCode().byteValue()); + encoder.writeUnsignedLong(buffer, state, getDescriptorCode().byteValue()); final int count = getElementCount(value); final byte encodingCode = getListEncoding(value); @@ -97,15 +102,15 @@ public abstract class AbstractDescribedListTypeEncoder<V> extends AbstractDescri switch (encodingCode) { case EncodingCodes.LIST8: - writeSmallType(buffer, state, value, count); + writeSmallType(buffer, encoder, state, value, count); break; case EncodingCodes.LIST32: - writeLargeType(buffer, state, value, count); + writeLargeType(buffer, encoder, state, value, count); break; } } - private void writeSmallType(ProtonBuffer buffer, EncoderState state, V value, int elementCount) { + private void writeSmallType(ProtonBuffer buffer, Encoder encoder, EncoderState state, V value, int elementCount) { final int startIndex = buffer.getWriteIndex(); // Reserve space for the size and write the count of list elements. @@ -114,7 +119,7 @@ public abstract class AbstractDescribedListTypeEncoder<V> extends AbstractDescri // Write the list elements and then compute total size written. for (int i = 0; i < elementCount; ++i) { - writeElement(value, i, buffer, state); + writeElement(value, i, buffer, encoder, state); } // Move back and write the size @@ -123,7 +128,7 @@ public abstract class AbstractDescribedListTypeEncoder<V> extends AbstractDescri buffer.setByte(startIndex, writeSize); } - private void writeLargeType(ProtonBuffer buffer, EncoderState state, V value, int elementCount) { + private void writeLargeType(ProtonBuffer buffer, Encoder encoder, EncoderState state, V value, int elementCount) { final int startIndex = buffer.getWriteIndex(); // Reserve space for the size and write the count of list elements. @@ -132,7 +137,7 @@ public abstract class AbstractDescribedListTypeEncoder<V> extends AbstractDescri // Write the list elements and then compute total size written. for (int i = 0; i < elementCount; ++i) { - writeElement(value, i, buffer, state); + writeElement(value, i, buffer, encoder, state); } // Move back and write the size @@ -172,6 +177,8 @@ public abstract class AbstractDescribedListTypeEncoder<V> extends AbstractDescri public void writeRawArray(ProtonBuffer buffer, EncoderState state, Object[] values) { buffer.writeByte(EncodingCodes.LIST32); + final Encoder encoder = state.getEncoder(); + for (int i = 0; i < values.length; ++i) { final V listType = (V) values[i]; final int count = getElementCount(listType); @@ -183,7 +190,7 @@ public abstract class AbstractDescribedListTypeEncoder<V> extends AbstractDescri // Write the list elements and then compute total size written. for (int j = 0; j < count; ++j) { - writeElement(listType, j, buffer, state); + writeElement(listType, j, buffer, encoder, state); } // Move back and write the size diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/AbstractDescribedMapTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/AbstractDescribedMapTypeEncoder.java index b33206a9..7284327b 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/AbstractDescribedMapTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/AbstractDescribedMapTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; @@ -76,17 +77,21 @@ public abstract class AbstractDescribedMapTypeEncoder<K, V, M> extends AbstractD * * @param buffer * the buffer where the type should be encoded to. + * @param encoder + * the current encoder. * @param state * the current encoder state. * @param value * the value which will be encoded as a map type. */ - public abstract void writeMapEntries(ProtonBuffer buffer, EncoderState state, M value); + public abstract void writeMapEntries(ProtonBuffer buffer, Encoder encoder, EncoderState state, M value); @Override public void writeType(ProtonBuffer buffer, EncoderState state, M value) { + final Encoder encoder = state.getEncoder(); + buffer.writeByte(EncodingCodes.DESCRIBED_TYPE_INDICATOR); - state.getEncoder().writeUnsignedLong(buffer, state, getDescriptorCode().byteValue()); + encoder.writeUnsignedLong(buffer, state, getDescriptorCode().byteValue()); if (hasMap(value)) { final int count = getMapSize(value); @@ -96,25 +101,25 @@ public abstract class AbstractDescribedMapTypeEncoder<K, V, M> extends AbstractD switch (encodingCode) { case EncodingCodes.MAP8: - writeSmallType(buffer, state, value, count); + writeSmallType(buffer, encoder, state, value, count); break; case EncodingCodes.MAP32: - writeLargeType(buffer, state, value, count); + writeLargeType(buffer, encoder, state, value, count); break; } } else { - state.getEncoder().writeNull(buffer, state); + buffer.writeByte(EncodingCodes.NULL); } } - private void writeSmallType(ProtonBuffer buffer, EncoderState state, M value, int elementCount) { + private void writeSmallType(ProtonBuffer buffer, Encoder encoder, EncoderState state, M value, int elementCount) { final int startIndex = buffer.getWriteIndex(); // Reserve space for the size and write the count of list elements. buffer.writeByte((byte) 0); buffer.writeByte((byte) (elementCount * 2)); - writeMapEntries(buffer, state, value); + writeMapEntries(buffer, encoder, state, value); // Move back and write the size final int writeSize = (buffer.getWriteIndex() - startIndex) - Byte.BYTES; @@ -122,14 +127,14 @@ public abstract class AbstractDescribedMapTypeEncoder<K, V, M> extends AbstractD buffer.setByte(startIndex, writeSize); } - private void writeLargeType(ProtonBuffer buffer, EncoderState state, M value, int elementCount) { + private void writeLargeType(ProtonBuffer buffer, Encoder encoder, EncoderState state, M value, int elementCount) { final int startIndex = buffer.getWriteIndex(); // Reserve space for the size and write the count of list elements. buffer.writeInt(0); buffer.writeInt(elementCount * 2); - writeMapEntries(buffer, state, value); + writeMapEntries(buffer, encoder, state, value); // Move back and write the size final int writeSize = (buffer.getWriteIndex() - startIndex) - Integer.BYTES; @@ -177,7 +182,7 @@ public abstract class AbstractDescribedMapTypeEncoder<K, V, M> extends AbstractD buffer.writeInt(0); buffer.writeInt(count * 2); - writeMapEntries(buffer, state, map); + writeMapEntries(buffer, state.getEncoder(), state, map); // Move back and write the size final int writeSize = buffer.getWriteIndex() - mapStartIndex - Integer.BYTES; diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/AcceptedTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/AcceptedTypeEncoder.java index 2de17eec..1eefa017 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/AcceptedTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/AcceptedTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -62,7 +63,7 @@ public final class AcceptedTypeEncoder extends AbstractDescribedListTypeEncoder< } @Override - public void writeElement(Accepted source, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Accepted source, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { } @Override diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ApplicationPropertiesTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ApplicationPropertiesTypeEncoder.java index f80b5626..a0548e4e 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ApplicationPropertiesTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ApplicationPropertiesTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedMapTypeEncoder; import org.apache.qpid.protonj2.types.Symbol; @@ -58,11 +59,11 @@ public final class ApplicationPropertiesTypeEncoder extends AbstractDescribedMap } @Override - public void writeMapEntries(ProtonBuffer buffer, EncoderState state, ApplicationProperties properties) { + public void writeMapEntries(ProtonBuffer buffer, Encoder encoder, EncoderState state, ApplicationProperties properties) { // Write the Map elements and then compute total size written. properties.getValue().forEach((key, value) -> { - state.getEncoder().writeString(buffer, state, key); - state.getEncoder().writeObject(buffer, state, value); + encoder.writeString(buffer, state, key); + encoder.writeObject(buffer, state, value); }); } } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnCloseTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnCloseTypeEncoder.java index 71085744..410e4563 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnCloseTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnCloseTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -50,7 +51,7 @@ public final class DeleteOnCloseTypeEncoder extends AbstractDescribedListTypeEnc } @Override - public void writeElement(DeleteOnClose source, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(DeleteOnClose source, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { } @Override diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoLinksOrMessagesTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoLinksOrMessagesTypeEncoder.java index 396b4416..7e1bdac6 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoLinksOrMessagesTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoLinksOrMessagesTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -50,7 +51,7 @@ public final class DeleteOnNoLinksOrMessagesTypeEncoder extends AbstractDescribe } @Override - public void writeElement(DeleteOnNoLinksOrMessages source, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(DeleteOnNoLinksOrMessages source, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { } @Override diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoLinksTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoLinksTypeEncoder.java index 238845db..fbb987c4 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoLinksTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoLinksTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -50,7 +51,7 @@ public final class DeleteOnNoLinksTypeEncoder extends AbstractDescribedListTypeE } @Override - public void writeElement(DeleteOnNoLinks source, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(DeleteOnNoLinks source, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { } @Override diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoMessagesTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoMessagesTypeEncoder.java index c8dda58e..20f796b9 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoMessagesTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeleteOnNoMessagesTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -50,7 +51,7 @@ public final class DeleteOnNoMessagesTypeEncoder extends AbstractDescribedListTy } @Override - public void writeElement(DeleteOnNoMessages source, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(DeleteOnNoMessages source, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { } @Override diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeliveryAnnotationsTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeliveryAnnotationsTypeEncoder.java index 769a3ca6..3f9bd019 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeliveryAnnotationsTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/DeliveryAnnotationsTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedMapTypeEncoder; import org.apache.qpid.protonj2.types.Symbol; @@ -58,11 +59,11 @@ public final class DeliveryAnnotationsTypeEncoder extends AbstractDescribedMapTy } @Override - public void writeMapEntries(ProtonBuffer buffer, EncoderState state, DeliveryAnnotations annotations) { + public void writeMapEntries(ProtonBuffer buffer, Encoder encoder, EncoderState state, DeliveryAnnotations annotations) { // Write the Map elements and then compute total size written. annotations.getValue().forEach((key, value) -> { - state.getEncoder().writeSymbol(buffer, state, key); - state.getEncoder().writeObject(buffer, state, value); + encoder.writeSymbol(buffer, state, key); + encoder.writeObject(buffer, state, value); }); } } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/FooterTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/FooterTypeEncoder.java index c584e537..3cd0493d 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/FooterTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/FooterTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedMapTypeEncoder; import org.apache.qpid.protonj2.types.Symbol; @@ -58,11 +59,11 @@ public final class FooterTypeEncoder extends AbstractDescribedMapTypeEncoder<Obj } @Override - public void writeMapEntries(ProtonBuffer buffer, EncoderState state, Footer footers) { + public void writeMapEntries(ProtonBuffer buffer, Encoder encoder, EncoderState state, Footer footers) { // Write the Map elements and then compute total size written. footers.getValue().forEach((key, value) -> { - state.getEncoder().writeObject(buffer, state, key); - state.getEncoder().writeObject(buffer, state, value); + encoder.writeObject(buffer, state, key); + encoder.writeObject(buffer, state, value); }); } } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/HeaderTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/HeaderTypeEncoder.java index 6bcdf621..47a83e44 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/HeaderTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/HeaderTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -50,7 +51,7 @@ public final class HeaderTypeEncoder extends AbstractDescribedListTypeEncoder<He } @Override - public void writeElement(Header header, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Header header, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { // When encoding ensure that values that were never set are omitted and a simple // NULL entry is written in the slot instead (don't write defaults). @@ -64,14 +65,14 @@ public final class HeaderTypeEncoder extends AbstractDescribedListTypeEncoder<He break; case 1: if (header.hasPriority()) { - state.getEncoder().writeUnsignedByte(buffer, state, header.getPriority()); + encoder.writeUnsignedByte(buffer, state, header.getPriority()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 2: if (header.hasTimeToLive()) { - state.getEncoder().writeUnsignedInteger(buffer, state, header.getTimeToLive()); + encoder.writeUnsignedInteger(buffer, state, header.getTimeToLive()); } else { buffer.writeByte(EncodingCodes.NULL); } @@ -85,7 +86,7 @@ public final class HeaderTypeEncoder extends AbstractDescribedListTypeEncoder<He break; case 4: if (header.hasDeliveryCount()) { - state.getEncoder().writeUnsignedInteger(buffer, state, header.getDeliveryCount()); + encoder.writeUnsignedInteger(buffer, state, header.getDeliveryCount()); } else { buffer.writeByte(EncodingCodes.NULL); } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/MessageAnnotationsTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/MessageAnnotationsTypeEncoder.java index 02b692f1..c4943bc4 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/MessageAnnotationsTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/MessageAnnotationsTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedMapTypeEncoder; import org.apache.qpid.protonj2.types.Symbol; @@ -58,11 +59,11 @@ public final class MessageAnnotationsTypeEncoder extends AbstractDescribedMapTyp } @Override - public void writeMapEntries(ProtonBuffer buffer, EncoderState state, MessageAnnotations annotations) { + public void writeMapEntries(ProtonBuffer buffer, Encoder encoder, EncoderState state, MessageAnnotations annotations) { // Write the Map elements and then compute total size written. annotations.getValue().forEach((key, value) -> { - state.getEncoder().writeSymbol(buffer, state, key); - state.getEncoder().writeObject(buffer, state, value); + encoder.writeSymbol(buffer, state, key); + encoder.writeObject(buffer, state, value); }); } } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ModifiedTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ModifiedTypeEncoder.java index c8eb03e6..704ceb3a 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ModifiedTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ModifiedTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,7 +46,7 @@ public final class ModifiedTypeEncoder extends AbstractDescribedListTypeEncoder< } @Override - public void writeElement(Modified source, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Modified source, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: buffer.writeByte(source.isDeliveryFailed() ? EncodingCodes.BOOLEAN_TRUE : EncodingCodes.BOOLEAN_FALSE); @@ -54,7 +55,7 @@ public final class ModifiedTypeEncoder extends AbstractDescribedListTypeEncoder< buffer.writeByte(source.isUndeliverableHere() ? EncodingCodes.BOOLEAN_TRUE : EncodingCodes.BOOLEAN_FALSE); break; case 2: - state.getEncoder().writeMap(buffer, state, source.getMessageAnnotations()); + encoder.writeMap(buffer, state, source.getMessageAnnotations()); break; default: throw new IllegalArgumentException("Unknown Modified value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/PropertiesTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/PropertiesTypeEncoder.java index d95bc2d2..fd1b9f76 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/PropertiesTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/PropertiesTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,58 +46,58 @@ public final class PropertiesTypeEncoder extends AbstractDescribedListTypeEncode } @Override - public void writeElement(Properties properties, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Properties properties, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeObject(buffer, state, properties.getMessageId()); + encoder.writeObject(buffer, state, properties.getMessageId()); break; case 1: - state.getEncoder().writeBinary(buffer, state, properties.getUserId()); + encoder.writeBinary(buffer, state, properties.getUserId()); break; case 2: - state.getEncoder().writeString(buffer, state, properties.getTo()); + encoder.writeString(buffer, state, properties.getTo()); break; case 3: - state.getEncoder().writeString(buffer, state, properties.getSubject()); + encoder.writeString(buffer, state, properties.getSubject()); break; case 4: - state.getEncoder().writeString(buffer, state, properties.getReplyTo()); + encoder.writeString(buffer, state, properties.getReplyTo()); break; case 5: - state.getEncoder().writeObject(buffer, state, properties.getCorrelationId()); + encoder.writeObject(buffer, state, properties.getCorrelationId()); break; case 6: - state.getEncoder().writeSymbol(buffer, state, properties.getContentType()); + encoder.writeSymbol(buffer, state, properties.getContentType()); break; case 7: - state.getEncoder().writeSymbol(buffer, state, properties.getContentEncoding()); + encoder.writeSymbol(buffer, state, properties.getContentEncoding()); break; case 8: if (properties.hasAbsoluteExpiryTime()) { - state.getEncoder().writeTimestamp(buffer, state, properties.getAbsoluteExpiryTime()); + encoder.writeTimestamp(buffer, state, properties.getAbsoluteExpiryTime()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 9: if (properties.hasCreationTime()) { - state.getEncoder().writeTimestamp(buffer, state, properties.getCreationTime()); + encoder.writeTimestamp(buffer, state, properties.getCreationTime()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 10: - state.getEncoder().writeString(buffer, state, properties.getGroupId()); + encoder.writeString(buffer, state, properties.getGroupId()); break; case 11: if (properties.hasGroupSequence()) { - state.getEncoder().writeUnsignedInteger(buffer, state, properties.getGroupSequence()); + encoder.writeUnsignedInteger(buffer, state, properties.getGroupSequence()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 12: - state.getEncoder().writeString(buffer, state, properties.getReplyToGroupId()); + encoder.writeString(buffer, state, properties.getReplyToGroupId()); break; default: throw new IllegalArgumentException("Unknown Properties value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ReceivedTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ReceivedTypeEncoder.java index c2b8161d..60251665 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ReceivedTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ReceivedTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,13 +46,13 @@ public final class ReceivedTypeEncoder extends AbstractDescribedListTypeEncoder< } @Override - public void writeElement(Received source, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Received source, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeUnsignedInteger(buffer, state, source.getSectionNumber()); + encoder.writeUnsignedInteger(buffer, state, source.getSectionNumber()); break; case 1: - state.getEncoder().writeUnsignedLong(buffer, state, source.getSectionOffset()); + encoder.writeUnsignedLong(buffer, state, source.getSectionOffset()); break; default: throw new IllegalArgumentException("Unknown Received value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/RejectedTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/RejectedTypeEncoder.java index 39dd8d44..6249434a 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/RejectedTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/RejectedTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,10 +46,10 @@ public final class RejectedTypeEncoder extends AbstractDescribedListTypeEncoder< } @Override - public void writeElement(Rejected source, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Rejected source, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeObject(buffer, state, source.getError()); + encoder.writeObject(buffer, state, source.getError()); break; default: throw new IllegalArgumentException("Unknown Rejected value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ReleasedTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ReleasedTypeEncoder.java index 3e75529d..7da90975 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ReleasedTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/ReleasedTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -62,7 +63,7 @@ public final class ReleasedTypeEncoder extends AbstractDescribedListTypeEncoder< } @Override - public void writeElement(Released source, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Released source, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { } @Override diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/SourceTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/SourceTypeEncoder.java index da304bfc..5436300f 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/SourceTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/SourceTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -48,40 +49,40 @@ public final class SourceTypeEncoder extends AbstractDescribedListTypeEncoder<So } @Override - public void writeElement(Source source, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Source source, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeString(buffer, state, source.getAddress()); + encoder.writeString(buffer, state, source.getAddress()); break; case 1: - state.getEncoder().writeUnsignedInteger(buffer, state, source.getDurable().getValue()); + encoder.writeUnsignedInteger(buffer, state, source.getDurable().getValue()); break; case 2: - state.getEncoder().writeSymbol(buffer, state, source.getExpiryPolicy().getPolicy()); + encoder.writeSymbol(buffer, state, source.getExpiryPolicy().getPolicy()); break; case 3: - state.getEncoder().writeUnsignedInteger(buffer, state, source.getTimeout()); + encoder.writeUnsignedInteger(buffer, state, source.getTimeout()); break; case 4: buffer.writeByte(source.isDynamic() ? EncodingCodes.BOOLEAN_TRUE : EncodingCodes.BOOLEAN_FALSE); break; case 5: - state.getEncoder().writeMap(buffer, state, source.getDynamicNodeProperties()); + encoder.writeMap(buffer, state, source.getDynamicNodeProperties()); break; case 6: - state.getEncoder().writeSymbol(buffer, state, source.getDistributionMode()); + encoder.writeSymbol(buffer, state, source.getDistributionMode()); break; case 7: - state.getEncoder().writeMap(buffer, state, source.getFilter()); + encoder.writeMap(buffer, state, source.getFilter()); break; case 8: - state.getEncoder().writeObject(buffer, state, source.getDefaultOutcome()); + encoder.writeObject(buffer, state, source.getDefaultOutcome()); break; case 9: - state.getEncoder().writeArray(buffer, state, source.getOutcomes()); + encoder.writeArray(buffer, state, source.getOutcomes()); break; case 10: - state.getEncoder().writeArray(buffer, state, source.getCapabilities()); + encoder.writeArray(buffer, state, source.getCapabilities()); break; default: throw new IllegalArgumentException("Unknown Source value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/TargetTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/TargetTypeEncoder.java index c5000377..722a19ac 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/TargetTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/messaging/TargetTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.messaging; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -48,28 +49,28 @@ public final class TargetTypeEncoder extends AbstractDescribedListTypeEncoder<Ta } @Override - public void writeElement(Target target, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Target target, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeString(buffer, state, target.getAddress()); + encoder.writeString(buffer, state, target.getAddress()); break; case 1: - state.getEncoder().writeUnsignedInteger(buffer, state, target.getDurable().getValue()); + encoder.writeUnsignedInteger(buffer, state, target.getDurable().getValue()); break; case 2: - state.getEncoder().writeSymbol(buffer, state, target.getExpiryPolicy().getPolicy()); + encoder.writeSymbol(buffer, state, target.getExpiryPolicy().getPolicy()); break; case 3: - state.getEncoder().writeUnsignedInteger(buffer, state, target.getTimeout()); + encoder.writeUnsignedInteger(buffer, state, target.getTimeout()); break; case 4: buffer.writeByte(target.isDynamic() ? EncodingCodes.BOOLEAN_TRUE : EncodingCodes.BOOLEAN_FALSE); break; case 5: - state.getEncoder().writeMap(buffer, state, target.getDynamicNodeProperties()); + encoder.writeMap(buffer, state, target.getDynamicNodeProperties()); break; case 6: - state.getEncoder().writeArray(buffer, state, target.getCapabilities()); + encoder.writeArray(buffer, state, target.getCapabilities()); break; default: throw new IllegalArgumentException("Unknown Target value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslChallengeTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslChallengeTypeEncoder.java index ac70faaa..198ce80c 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslChallengeTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslChallengeTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.security; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,10 +46,10 @@ public final class SaslChallengeTypeEncoder extends AbstractDescribedListTypeEnc } @Override - public void writeElement(SaslChallenge challenge, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(SaslChallenge challenge, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeBinary(buffer, state, challenge.getChallenge()); + encoder.writeBinary(buffer, state, challenge.getChallenge()); break; default: throw new IllegalArgumentException("Unknown SaslChallenge value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslInitTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslInitTypeEncoder.java index e874cc1a..95a63c85 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslInitTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslInitTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.security; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; import org.apache.qpid.protonj2.types.Symbol; @@ -44,16 +45,16 @@ public final class SaslInitTypeEncoder extends AbstractDescribedListTypeEncoder< } @Override - public void writeElement(SaslInit init, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(SaslInit init, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeSymbol(buffer, state, init.getMechanism()); + encoder.writeSymbol(buffer, state, init.getMechanism()); break; case 1: - state.getEncoder().writeBinary(buffer, state, init.getInitialResponse()); + encoder.writeBinary(buffer, state, init.getInitialResponse()); break; case 2: - state.getEncoder().writeString(buffer, state, init.getHostname()); + encoder.writeString(buffer, state, init.getHostname()); break; default: throw new IllegalArgumentException("Unknown SaslInit value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslMechanismsTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslMechanismsTypeEncoder.java index af8f55ed..a7fcfbcc 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslMechanismsTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslMechanismsTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.security; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; import org.apache.qpid.protonj2.types.Symbol; @@ -44,10 +45,10 @@ public final class SaslMechanismsTypeEncoder extends AbstractDescribedListTypeEn } @Override - public void writeElement(SaslMechanisms mechanisms, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(SaslMechanisms mechanisms, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeArray(buffer, state, mechanisms.getSaslServerMechanisms()); + encoder.writeArray(buffer, state, mechanisms.getSaslServerMechanisms()); break; default: throw new IllegalArgumentException("Unknown SaslChallenge value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslOutcomeTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslOutcomeTypeEncoder.java index 3596f2d3..1bb25b1b 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslOutcomeTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslOutcomeTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.security; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,13 +46,13 @@ public final class SaslOutcomeTypeEncoder extends AbstractDescribedListTypeEncod } @Override - public void writeElement(SaslOutcome outcome, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(SaslOutcome outcome, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeUnsignedByte(buffer, state, outcome.getCode().getValue()); + encoder.writeUnsignedByte(buffer, state, outcome.getCode().getValue()); break; case 1: - state.getEncoder().writeBinary(buffer, state, outcome.getAdditionalData()); + encoder.writeBinary(buffer, state, outcome.getAdditionalData()); break; default: throw new IllegalArgumentException("Unknown SaslOutcome value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslResponseTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslResponseTypeEncoder.java index df89468e..19c0654b 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslResponseTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/security/SaslResponseTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.security; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -54,10 +55,10 @@ public final class SaslResponseTypeEncoder extends AbstractDescribedListTypeEnco } @Override - public void writeElement(SaslResponse response, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(SaslResponse response, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeBinary(buffer, state, response.getResponse()); + encoder.writeBinary(buffer, state, response.getResponse()); break; default: throw new IllegalArgumentException("Unknown SaslResponse value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/CoordinatorTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/CoordinatorTypeEncoder.java index 88c5048a..514f038e 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/CoordinatorTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/CoordinatorTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transactions; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,10 +46,10 @@ public final class CoordinatorTypeEncoder extends AbstractDescribedListTypeEncod } @Override - public void writeElement(Coordinator coordinator, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Coordinator coordinator, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeArray(buffer, state, coordinator.getCapabilities()); + encoder.writeArray(buffer, state, coordinator.getCapabilities()); break; default: throw new IllegalArgumentException("Unknown Coordinator value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DeclareTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DeclareTypeEncoder.java index beeaa818..7b71c95e 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DeclareTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DeclareTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transactions; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,10 +46,10 @@ public final class DeclareTypeEncoder extends AbstractDescribedListTypeEncoder<D } @Override - public void writeElement(Declare declare, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Declare declare, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeObject(buffer, state, declare.getGlobalId()); + encoder.writeObject(buffer, state, declare.getGlobalId()); break; default: throw new IllegalArgumentException("Unknown Declare value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DeclaredTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DeclaredTypeEncoder.java index 4eebf777..2a721693 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DeclaredTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DeclaredTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transactions; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,10 +46,10 @@ public final class DeclaredTypeEncoder extends AbstractDescribedListTypeEncoder< } @Override - public void writeElement(Declared declared, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Declared declared, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeBinary(buffer, state, declared.getTxnId()); + encoder.writeBinary(buffer, state, declared.getTxnId()); break; default: throw new IllegalArgumentException("Unknown Declared value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DischargeTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DischargeTypeEncoder.java index b78efff6..aa442c42 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DischargeTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/DischargeTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transactions; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,10 +46,10 @@ public final class DischargeTypeEncoder extends AbstractDescribedListTypeEncoder } @Override - public void writeElement(Discharge discharge, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Discharge discharge, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeBinary(buffer, state, discharge.getTxnId()); + encoder.writeBinary(buffer, state, discharge.getTxnId()); break; case 1: buffer.writeByte(discharge.getFail() ? EncodingCodes.BOOLEAN_TRUE : EncodingCodes.BOOLEAN_FALSE); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/TransactionStateTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/TransactionStateTypeEncoder.java index 7459459e..390ee7d6 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/TransactionStateTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transactions/TransactionStateTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transactions; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,13 +46,13 @@ public final class TransactionStateTypeEncoder extends AbstractDescribedListType } @Override - public void writeElement(TransactionalState txState, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(TransactionalState txState, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeBinary(buffer, state, txState.getTxnId()); + encoder.writeBinary(buffer, state, txState.getTxnId()); break; case 1: - state.getEncoder().writeObject(buffer, state, txState.getOutcome()); + encoder.writeObject(buffer, state, txState.getOutcome()); break; default: throw new IllegalArgumentException("Unknown TransactionalState value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/AttachTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/AttachTypeEncoder.java index 3aae08c1..920cc494 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/AttachTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/AttachTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transport; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,18 +46,18 @@ public final class AttachTypeEncoder extends AbstractDescribedListTypeEncoder<At } @Override - public void writeElement(Attach attach, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Attach attach, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: if (attach.hasName()) { - state.getEncoder().writeString(buffer, state, attach.getName()); + encoder.writeString(buffer, state, attach.getName()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 1: if (attach.hasHandle()) { - state.getEncoder().writeUnsignedInteger(buffer, state, attach.getHandle()); + encoder.writeUnsignedInteger(buffer, state, attach.getHandle()); } else { buffer.writeByte(EncodingCodes.NULL); } @@ -70,35 +71,35 @@ public final class AttachTypeEncoder extends AbstractDescribedListTypeEncoder<At break; case 3: if (attach.hasSenderSettleMode()) { - state.getEncoder().writeUnsignedByte(buffer, state, attach.getSenderSettleMode().byteValue()); + encoder.writeUnsignedByte(buffer, state, attach.getSenderSettleMode().byteValue()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 4: if (attach.hasReceiverSettleMode()) { - state.getEncoder().writeUnsignedByte(buffer, state, attach.getReceiverSettleMode().byteValue()); + encoder.writeUnsignedByte(buffer, state, attach.getReceiverSettleMode().byteValue()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 5: if (attach.hasSource()) { - state.getEncoder().writeObject(buffer, state, attach.getSource()); + encoder.writeObject(buffer, state, attach.getSource()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 6: if (attach.hasTargetOrCoordinator()) { - state.getEncoder().writeObject(buffer, state, attach.getTarget()); + encoder.writeObject(buffer, state, attach.getTarget()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 7: if (attach.hasUnsettled()) { - state.getEncoder().writeMap(buffer, state, attach.getUnsettled()); + encoder.writeMap(buffer, state, attach.getUnsettled()); } else { buffer.writeByte(EncodingCodes.NULL); } @@ -112,35 +113,35 @@ public final class AttachTypeEncoder extends AbstractDescribedListTypeEncoder<At break; case 9: if (attach.hasInitialDeliveryCount()) { - state.getEncoder().writeUnsignedInteger(buffer, state, attach.getInitialDeliveryCount()); + encoder.writeUnsignedInteger(buffer, state, attach.getInitialDeliveryCount()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 10: if (attach.hasMaxMessageSize()) { - state.getEncoder().writeUnsignedLong(buffer, state, attach.getMaxMessageSize()); + encoder.writeUnsignedLong(buffer, state, attach.getMaxMessageSize()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 11: if (attach.hasOfferedCapabilities()) { - state.getEncoder().writeArray(buffer, state, attach.getOfferedCapabilities()); + encoder.writeArray(buffer, state, attach.getOfferedCapabilities()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 12: if (attach.hasDesiredCapabilities()) { - state.getEncoder().writeArray(buffer, state, attach.getDesiredCapabilities()); + encoder.writeArray(buffer, state, attach.getDesiredCapabilities()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 13: if (attach.hasProperties()) { - state.getEncoder().writeMap(buffer, state, attach.getProperties()); + encoder.writeMap(buffer, state, attach.getProperties()); } else { buffer.writeByte(EncodingCodes.NULL); } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/BeginTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/BeginTypeEncoder.java index d98ae332..c3007979 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/BeginTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/BeginTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transport; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,60 +46,60 @@ public final class BeginTypeEncoder extends AbstractDescribedListTypeEncoder<Beg } @Override - public void writeElement(Begin begin, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Begin begin, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: if (begin.hasRemoteChannel()) { - state.getEncoder().writeUnsignedShort(buffer, state, begin.getRemoteChannel()); + encoder.writeUnsignedShort(buffer, state, begin.getRemoteChannel()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 1: if (begin.hasNextOutgoingId()) { - state.getEncoder().writeUnsignedInteger(buffer, state, begin.getNextOutgoingId()); + encoder.writeUnsignedInteger(buffer, state, begin.getNextOutgoingId()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 2: if (begin.hasIncomingWindow()) { - state.getEncoder().writeUnsignedInteger(buffer, state, begin.getIncomingWindow()); + encoder.writeUnsignedInteger(buffer, state, begin.getIncomingWindow()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 3: if (begin.hasOutgoingWindow()) { - state.getEncoder().writeUnsignedInteger(buffer, state, begin.getOutgoingWindow()); + encoder.writeUnsignedInteger(buffer, state, begin.getOutgoingWindow()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 4: if (begin.hasHandleMax()) { - state.getEncoder().writeUnsignedInteger(buffer, state, begin.getHandleMax()); + encoder.writeUnsignedInteger(buffer, state, begin.getHandleMax()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 5: if (begin.hasOfferedCapabilities()) { - state.getEncoder().writeArray(buffer, state, begin.getOfferedCapabilities()); + encoder.writeArray(buffer, state, begin.getOfferedCapabilities()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 6: if (begin.hasDesiredCapabilities()) { - state.getEncoder().writeArray(buffer, state, begin.getDesiredCapabilities()); + encoder.writeArray(buffer, state, begin.getDesiredCapabilities()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 7: if (begin.hasProperties()) { - state.getEncoder().writeMap(buffer, state, begin.getProperties()); + encoder.writeMap(buffer, state, begin.getProperties()); } else { buffer.writeByte(EncodingCodes.NULL); } diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/CloseTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/CloseTypeEncoder.java index 830501ab..af461b55 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/CloseTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/CloseTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transport; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,10 +46,10 @@ public final class CloseTypeEncoder extends AbstractDescribedListTypeEncoder<Clo } @Override - public void writeElement(Close close, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Close close, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeObject(buffer, state, close.getError()); + encoder.writeObject(buffer, state, close.getError()); break; default: throw new IllegalArgumentException("Unknown Close value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/DetachTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/DetachTypeEncoder.java index 348a6b3a..d2c7cd96 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/DetachTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/DetachTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transport; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,11 +46,11 @@ public final class DetachTypeEncoder extends AbstractDescribedListTypeEncoder<De } @Override - public void writeElement(Detach detach, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Detach detach, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: if (detach.hasHandle()) { - state.getEncoder().writeUnsignedInteger(buffer, state, detach.getHandle()); + encoder.writeUnsignedInteger(buffer, state, detach.getHandle()); } else { buffer.writeByte(EncodingCodes.NULL); } @@ -58,7 +59,7 @@ public final class DetachTypeEncoder extends AbstractDescribedListTypeEncoder<De buffer.writeByte(detach.getClosed() ? EncodingCodes.BOOLEAN_TRUE : EncodingCodes.BOOLEAN_FALSE); break; case 2: - state.getEncoder().writeObject(buffer, state, detach.getError()); + encoder.writeObject(buffer, state, detach.getError()); break; default: throw new IllegalArgumentException("Unknown Detach value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/DispositionTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/DispositionTypeEncoder.java index 8199a145..b03fdb61 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/DispositionTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/DispositionTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transport; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -54,7 +55,7 @@ public final class DispositionTypeEncoder extends AbstractDescribedListTypeEncod } @Override - public void writeElement(Disposition disposition, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Disposition disposition, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: if (disposition.hasRole()) { @@ -65,14 +66,14 @@ public final class DispositionTypeEncoder extends AbstractDescribedListTypeEncod break; case 1: if (disposition.hasFirst()) { - state.getEncoder().writeUnsignedInteger(buffer, state, disposition.getFirst()); + encoder.writeUnsignedInteger(buffer, state, disposition.getFirst()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 2: if (disposition.hasLast()) { - state.getEncoder().writeUnsignedInteger(buffer, state, disposition.getLast()); + encoder.writeUnsignedInteger(buffer, state, disposition.getLast()); } else { buffer.writeByte(EncodingCodes.NULL); } @@ -89,7 +90,7 @@ public final class DispositionTypeEncoder extends AbstractDescribedListTypeEncod if (disposition.getState() == Accepted.getInstance()) { buffer.writeBytes(ACCEPTED_ENCODING); } else { - state.getEncoder().writeObject(buffer, state, disposition.getState()); + encoder.writeObject(buffer, state, disposition.getState()); } } else { buffer.writeByte(EncodingCodes.NULL); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/EndTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/EndTypeEncoder.java index 169ad30f..4972e6dc 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/EndTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/EndTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transport; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,10 +46,10 @@ public final class EndTypeEncoder extends AbstractDescribedListTypeEncoder<End> } @Override - public void writeElement(End end, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(End end, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeObject(buffer, state, end.getError()); + encoder.writeObject(buffer, state, end.getError()); break; default: throw new IllegalArgumentException("Unknown End value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/ErrorConditionTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/ErrorConditionTypeEncoder.java index 373ae947..f1341116 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/ErrorConditionTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/ErrorConditionTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transport; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,16 +46,16 @@ public final class ErrorConditionTypeEncoder extends AbstractDescribedListTypeEn } @Override - public void writeElement(ErrorCondition error, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(ErrorCondition error, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: - state.getEncoder().writeSymbol(buffer, state, error.getCondition()); + encoder.writeSymbol(buffer, state, error.getCondition()); break; case 1: - state.getEncoder().writeString(buffer, state, error.getDescription()); + encoder.writeString(buffer, state, error.getDescription()); break; case 2: - state.getEncoder().writeMap(buffer, state, error.getInfo()); + encoder.writeMap(buffer, state, error.getInfo()); break; default: throw new IllegalArgumentException("Unknown ErrorCondition value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/FlowTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/FlowTypeEncoder.java index 3b5ff659..b2cf747b 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/FlowTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/FlowTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transport; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,60 +46,60 @@ public final class FlowTypeEncoder extends AbstractDescribedListTypeEncoder<Flow } @Override - public void writeElement(Flow flow, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Flow flow, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: if (flow.hasNextIncomingId()) { - state.getEncoder().writeUnsignedInteger(buffer, state, flow.getNextIncomingId()); + encoder.writeUnsignedInteger(buffer, state, flow.getNextIncomingId()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 1: if (flow.hasIncomingWindow()) { - state.getEncoder().writeUnsignedInteger(buffer, state, flow.getIncomingWindow()); + encoder.writeUnsignedInteger(buffer, state, flow.getIncomingWindow()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 2: if (flow.hasNextOutgoingId()) { - state.getEncoder().writeUnsignedInteger(buffer, state, flow.getNextOutgoingId()); + encoder.writeUnsignedInteger(buffer, state, flow.getNextOutgoingId()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 3: if (flow.hasOutgoingWindow()) { - state.getEncoder().writeUnsignedInteger(buffer, state, flow.getOutgoingWindow()); + encoder.writeUnsignedInteger(buffer, state, flow.getOutgoingWindow()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 4: if (flow.hasHandle()) { - state.getEncoder().writeUnsignedInteger(buffer, state, flow.getHandle()); + encoder.writeUnsignedInteger(buffer, state, flow.getHandle()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 5: if (flow.hasDeliveryCount()) { - state.getEncoder().writeUnsignedInteger(buffer, state, flow.getDeliveryCount()); + encoder.writeUnsignedInteger(buffer, state, flow.getDeliveryCount()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 6: if (flow.hasLinkCredit()) { - state.getEncoder().writeUnsignedInteger(buffer, state, flow.getLinkCredit()); + encoder.writeUnsignedInteger(buffer, state, flow.getLinkCredit()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 7: if (flow.hasAvailable()) { - state.getEncoder().writeUnsignedInteger(buffer, state, flow.getAvailable()); + encoder.writeUnsignedInteger(buffer, state, flow.getAvailable()); } else { buffer.writeByte(EncodingCodes.NULL); } @@ -118,7 +119,7 @@ public final class FlowTypeEncoder extends AbstractDescribedListTypeEncoder<Flow } break; case 10: - state.getEncoder().writeMap(buffer, state, flow.getProperties()); + encoder.writeMap(buffer, state, flow.getProperties()); break; default: throw new IllegalArgumentException("Unknown Flow value index: " + index); diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/OpenTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/OpenTypeEncoder.java index 5b2915cb..66131281 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/OpenTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/OpenTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transport; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,76 +46,76 @@ public final class OpenTypeEncoder extends AbstractDescribedListTypeEncoder<Open } @Override - public void writeElement(Open open, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Open open, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: if (open.hasContainerId()) { - state.getEncoder().writeString(buffer, state, open.getContainerId()); + encoder.writeString(buffer, state, open.getContainerId()); } else { - state.getEncoder().writeNull(buffer, state); + buffer.writeByte(EncodingCodes.NULL); } break; case 1: if (open.hasHostname()) { - state.getEncoder().writeString(buffer, state, open.getHostname()); + encoder.writeString(buffer, state, open.getHostname()); } else { - state.getEncoder().writeNull(buffer, state); + buffer.writeByte(EncodingCodes.NULL); } break; case 2: if (open.hasMaxFrameSize()) { - state.getEncoder().writeUnsignedInteger(buffer, state, open.getMaxFrameSize()); + encoder.writeUnsignedInteger(buffer, state, open.getMaxFrameSize()); } else { - state.getEncoder().writeNull(buffer, state); + buffer.writeByte(EncodingCodes.NULL); } break; case 3: if (open.hasChannelMax()) { - state.getEncoder().writeUnsignedShort(buffer, state, open.getChannelMax()); + encoder.writeUnsignedShort(buffer, state, open.getChannelMax()); } else { - state.getEncoder().writeNull(buffer, state); + buffer.writeByte(EncodingCodes.NULL); } break; case 4: if (open.hasIdleTimeout()) { - state.getEncoder().writeUnsignedInteger(buffer, state, open.getIdleTimeout()); + encoder.writeUnsignedInteger(buffer, state, open.getIdleTimeout()); } else { - state.getEncoder().writeNull(buffer, state); + buffer.writeByte(EncodingCodes.NULL); } break; case 5: if (open.hasOutgoingLocales()) { - state.getEncoder().writeArray(buffer, state, open.getOutgoingLocales()); + encoder.writeArray(buffer, state, open.getOutgoingLocales()); } else { - state.getEncoder().writeNull(buffer, state); + buffer.writeByte(EncodingCodes.NULL); } break; case 6: if (open.hasIncomingLocales()) { - state.getEncoder().writeArray(buffer, state, open.getIncomingLocales()); + encoder.writeArray(buffer, state, open.getIncomingLocales()); } else { - state.getEncoder().writeNull(buffer, state); + buffer.writeByte(EncodingCodes.NULL); } break; case 7: if (open.hasOfferedCapabilities()) { - state.getEncoder().writeArray(buffer, state, open.getOfferedCapabilities()); + encoder.writeArray(buffer, state, open.getOfferedCapabilities()); } else { - state.getEncoder().writeNull(buffer, state); + buffer.writeByte(EncodingCodes.NULL); } break; case 8: if (open.hasDesiredCapabilities()) { - state.getEncoder().writeArray(buffer, state, open.getDesiredCapabilities()); + encoder.writeArray(buffer, state, open.getDesiredCapabilities()); } else { - state.getEncoder().writeNull(buffer, state); + buffer.writeByte(EncodingCodes.NULL); } break; case 9: if (open.hasProperties()) { - state.getEncoder().writeMap(buffer, state, open.getProperties()); + encoder.writeMap(buffer, state, open.getProperties()); } else { - state.getEncoder().writeNull(buffer, state); + buffer.writeByte(EncodingCodes.NULL); } break; default: diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/TransferTypeEncoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/TransferTypeEncoder.java index 8c50fad6..5120df1b 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/TransferTypeEncoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/encoders/transport/TransferTypeEncoder.java @@ -17,6 +17,7 @@ package org.apache.qpid.protonj2.codec.encoders.transport; import org.apache.qpid.protonj2.buffer.ProtonBuffer; +import org.apache.qpid.protonj2.codec.Encoder; import org.apache.qpid.protonj2.codec.EncoderState; import org.apache.qpid.protonj2.codec.EncodingCodes; import org.apache.qpid.protonj2.codec.encoders.AbstractDescribedListTypeEncoder; @@ -45,32 +46,32 @@ public final class TransferTypeEncoder extends AbstractDescribedListTypeEncoder< } @Override - public void writeElement(Transfer transfer, int index, ProtonBuffer buffer, EncoderState state) { + public void writeElement(Transfer transfer, int index, ProtonBuffer buffer, Encoder encoder, EncoderState state) { switch (index) { case 0: if (transfer.hasHandle()) { - state.getEncoder().writeUnsignedInteger(buffer, state, transfer.getHandle()); + encoder.writeUnsignedInteger(buffer, state, transfer.getHandle()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 1: if (transfer.hasDeliveryId()) { - state.getEncoder().writeUnsignedInteger(buffer, state, transfer.getDeliveryId()); + encoder.writeUnsignedInteger(buffer, state, transfer.getDeliveryId()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 2: if (transfer.hasDeliveryTag()) { - state.getEncoder().writeDeliveryTag(buffer, state, transfer.getDeliveryTag()); + encoder.writeDeliveryTag(buffer, state, transfer.getDeliveryTag()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 3: if (transfer.hasMessageFormat()) { - state.getEncoder().writeUnsignedInteger(buffer, state, transfer.getMessageFormat()); + encoder.writeUnsignedInteger(buffer, state, transfer.getMessageFormat()); } else { buffer.writeByte(EncodingCodes.NULL); } @@ -91,13 +92,13 @@ public final class TransferTypeEncoder extends AbstractDescribedListTypeEncoder< break; case 6: if (transfer.hasRcvSettleMode()) { - state.getEncoder().writeUnsignedByte(buffer, state, transfer.getRcvSettleMode().byteValue()); + encoder.writeUnsignedByte(buffer, state, transfer.getRcvSettleMode().byteValue()); } else { buffer.writeByte(EncodingCodes.NULL); } break; case 7: - state.getEncoder().writeObject(buffer, state, transfer.getState()); + encoder.writeObject(buffer, state, transfer.getState()); break; case 8: if (transfer.hasResume()) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org