You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/01/09 15:25:01 UTC
[25/34] qpid-proton git commit: PROTON-1385: remove proton-j from the
existing repo, it now has its own repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton-j.git
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Open.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Open.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Open.java
deleted file mode 100644
index e4ec98b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Open.java
+++ /dev/null
@@ -1,175 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-
-import java.util.Arrays;
-import java.util.Map;
-
-
-public final class Open implements FrameBody
-{
- private String _containerId;
- private String _hostname;
- private UnsignedInteger _maxFrameSize = UnsignedInteger.valueOf(0xffffffff);
- private UnsignedShort _channelMax = UnsignedShort.valueOf((short) 65535);
- 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)
- {
- if( containerId == null )
- {
- throw new NullPointerException("the container-id field is mandatory");
- }
-
- _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;
- }
-
- public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleOpen(this, payload, context);
- }
-
- @Override
- public String toString()
- {
- return "Open{" +
- " containerId='" + _containerId + '\'' +
- ", hostname='" + _hostname + '\'' +
- ", maxFrameSize=" + _maxFrameSize +
- ", channelMax=" + _channelMax +
- ", idleTimeOut=" + _idleTimeOut +
- ", outgoingLocales=" + (_outgoingLocales == null ? null : Arrays.asList(_outgoingLocales)) +
- ", incomingLocales=" + (_incomingLocales == null ? null : Arrays.asList(_incomingLocales)) +
- ", offeredCapabilities=" + (_offeredCapabilities == null ? null : Arrays.asList(_offeredCapabilities)) +
- ", desiredCapabilities=" + (_desiredCapabilities == null ? null : Arrays.asList(_desiredCapabilities)) +
- ", properties=" + _properties +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java
deleted file mode 100644
index c2621e6..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java
+++ /dev/null
@@ -1,54 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.UnsignedByte;
-
-public enum ReceiverSettleMode
-{
- FIRST(0),
- SECOND(1);
-
- private UnsignedByte value;
-
- private ReceiverSettleMode(int value) {
- this.value = UnsignedByte.valueOf((byte)value);
- }
-
- public static ReceiverSettleMode valueOf(UnsignedByte value) {
-
- switch (value.intValue()) {
- case 0:
- return ReceiverSettleMode.FIRST;
- case 1:
- return ReceiverSettleMode.SECOND;
- default:
- throw new IllegalArgumentException("The value can be only 0 (for FIRST) and 1 (for SECOND)");
- }
- }
-
- public UnsignedByte getValue() {
- return this.value;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Role.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Role.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Role.java
deleted file mode 100644
index f40effb..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Role.java
+++ /dev/null
@@ -1,34 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-public enum Role
-{
- SENDER, RECEIVER;
-
- public boolean getValue()
- {
- return this == RECEIVER;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java
deleted file mode 100644
index 6dae3f4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java
+++ /dev/null
@@ -1,58 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.UnsignedByte;
-
-public enum SenderSettleMode
-{
- UNSETTLED(0),
- SETTLED(1),
- MIXED(2);
-
- private UnsignedByte value;
-
- private SenderSettleMode(int value) {
- this.value = UnsignedByte.valueOf((byte)value);
- }
-
- public static SenderSettleMode valueOf(UnsignedByte value) {
-
- switch (value.intValue()) {
-
- case 0:
- return SenderSettleMode.UNSETTLED;
- case 1:
- return SenderSettleMode.SETTLED;
- case 2:
- return SenderSettleMode.MIXED;
- default:
- throw new IllegalArgumentException("The value can be only 0 (for UNSETTLED), 1 (for SETTLED) and 2 (for MIXED)");
- }
- }
-
- public UnsignedByte getValue() {
- return this.value;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SessionError.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SessionError.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SessionError.java
deleted file mode 100644
index e029cfb..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SessionError.java
+++ /dev/null
@@ -1,38 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Symbol;
-
-public interface SessionError
-{
- final static Symbol WINDOW_VIOLATION = Symbol.valueOf("amqp:session:window-violation");
-
- final static Symbol ERRANT_LINK = Symbol.valueOf("amqp:session:errant-link");
-
- final static Symbol HANDLE_IN_USE = Symbol.valueOf("amqp:session:handle-in-use");
-
- final static Symbol UNATTACHED_HANDLE = Symbol.valueOf("amqp:session:unattached-handle");
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Source.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Source.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Source.java
deleted file mode 100644
index 2d6f3b2..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Source.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.qpid.proton.amqp.transport;
-
-public interface Source
-{
- public String getAddress();
-
- public Source copy();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Target.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Target.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Target.java
deleted file mode 100644
index c972c02..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Target.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.apache.qpid.proton.amqp.transport;
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-public interface Target
-{
- public String getAddress();
-
- public Target copy();
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Transfer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Transfer.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Transfer.java
deleted file mode 100644
index 35c421c..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/Transfer.java
+++ /dev/null
@@ -1,181 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.amqp.transport;
-
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-
-public final class Transfer implements FrameBody
-{
- 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)
- {
- if( handle == null )
- {
- throw new NullPointerException("the handle field is mandatory");
- }
-
- _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;
- }
-
- public <E> void invoke(FrameBodyHandler<E> handler, Binary payload, E context)
- {
- handler.handleTransfer(this, payload, context);
- }
-
- @Override
- public String toString()
- {
- return "Transfer{" +
- "handle=" + _handle +
- ", deliveryId=" + _deliveryId +
- ", deliveryTag=" + _deliveryTag +
- ", messageFormat=" + _messageFormat +
- ", settled=" + _settled +
- ", more=" + _more +
- ", rcvSettleMode=" + _rcvSettleMode +
- ", state=" + _state +
- ", resume=" + _resume +
- ", aborted=" + _aborted +
- ", batchable=" + _batchable +
- '}';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPDefinedTypes.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPDefinedTypes.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPDefinedTypes.java
deleted file mode 100644
index 2e2f9e0..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPDefinedTypes.java
+++ /dev/null
@@ -1,107 +0,0 @@
-
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.transport.Attach;
-import org.apache.qpid.proton.amqp.transport.Begin;
-import org.apache.qpid.proton.amqp.transport.Close;
-import org.apache.qpid.proton.amqp.transport.Detach;
-import org.apache.qpid.proton.amqp.transport.Disposition;
-import org.apache.qpid.proton.amqp.transport.End;
-import org.apache.qpid.proton.amqp.transport.Flow;
-import org.apache.qpid.proton.amqp.transport.Open;
-import org.apache.qpid.proton.amqp.transport.Transfer;
-import org.apache.qpid.proton.codec.messaging.*;
-import org.apache.qpid.proton.codec.security.*;
-import org.apache.qpid.proton.codec.transaction.*;
-import org.apache.qpid.proton.codec.transport.*;
-
-public class AMQPDefinedTypes
-{
- public static void registerAllTypes(Decoder decoder, EncoderImpl encoder)
- {
- registerTransportTypes(decoder, encoder);
- registerMessagingTypes(decoder, encoder);
- registerTransactionTypes(decoder, encoder);
- registerSecurityTypes(decoder, encoder);
- }
-
-
- public static void registerTransportTypes(Decoder decoder, EncoderImpl encoder)
- {
- OpenType.register(decoder, encoder);
- BeginType.register(decoder, encoder);
- AttachType.register(decoder, encoder);
- FlowType.register(decoder, encoder);
- TransferType.register(decoder, encoder);
- DispositionType.register(decoder, encoder);
- DetachType.register(decoder, encoder);
- EndType.register(decoder, encoder);
- CloseType.register(decoder, encoder);
- ErrorConditionType.register(decoder, encoder);
- }
-
- public static void registerMessagingTypes(Decoder decoder, EncoderImpl encoder)
- {
- HeaderType.register(decoder, encoder);
- DeliveryAnnotationsType.register(decoder, encoder);
- MessageAnnotationsType.register(decoder, encoder);
- PropertiesType.register( decoder, encoder );
- ApplicationPropertiesType.register(decoder, encoder);
- DataType.register(decoder, encoder);
- AmqpSequenceType.register(decoder, encoder);
- AmqpValueType.register(decoder, encoder);
- FooterType.register(decoder, encoder);
- ReceivedType.register(decoder, encoder);
- AcceptedType.register(decoder , encoder);
- RejectedType.register(decoder, encoder);
- ReleasedType.register(decoder, encoder);
- ModifiedType.register(decoder, encoder);
- SourceType.register(decoder, encoder);
- TargetType.register(decoder, encoder);
- DeleteOnCloseType.register(decoder, encoder);
- DeleteOnNoLinksType.register(decoder, encoder);
- DeleteOnNoMessagesType.register(decoder, encoder);
- DeleteOnNoLinksOrMessagesType.register(decoder, encoder);
- }
-
- public static void registerTransactionTypes(Decoder decoder, EncoderImpl encoder)
- {
- CoordinatorType.register(decoder, encoder);
- DeclareType.register(decoder, encoder);
- DischargeType.register(decoder, encoder);
- DeclaredType.register(decoder, encoder);
- TransactionalStateType.register(decoder, encoder);
- }
-
- public static void registerSecurityTypes(Decoder decoder, EncoderImpl encoder)
- {
- SaslMechanismsType.register(decoder, encoder);
- SaslInitType.register(decoder, encoder);
- SaslChallengeType.register(decoder, encoder);
- SaslResponseType.register(decoder, encoder);
- SaslOutcomeType.register(decoder, encoder);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPType.java
deleted file mode 100644
index 4796b3f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/AMQPType.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-
-public interface AMQPType<V>
-{
- Class<V> getTypeClass();
-
- TypeEncoding<V> getEncoding(V val);
-
- TypeEncoding<V> getCanonicalEncoding();
-
- Collection<? extends TypeEncoding<V>> getAllEncodings();
-
- void write(V val);
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractDescribedType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractDescribedType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractDescribedType.java
deleted file mode 100644
index d31ac40..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractDescribedType.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-
-abstract public class AbstractDescribedType<T,M> implements AMQPType<T>
-{
-
- private final EncoderImpl _encoder;
- private final Map<TypeEncoding<M>, TypeEncoding<T>> _encodings = new HashMap<TypeEncoding<M>, TypeEncoding<T>>();
-
- public AbstractDescribedType(EncoderImpl encoder)
- {
- _encoder = encoder;
- }
-
- abstract protected UnsignedLong getDescriptor();
-
-
- public TypeEncoding<T> getEncoding(final T val)
- {
- M asUnderlying = wrap(val);
- TypeEncoding<M> underlyingEncoding = _encoder.getType(asUnderlying).getEncoding(asUnderlying);
- TypeEncoding<T> encoding = _encodings.get(underlyingEncoding);
- if(encoding == null)
- {
- encoding = new DynamicDescribedTypeEncoding(underlyingEncoding);
- _encodings.put(underlyingEncoding, encoding);
- }
-
- return encoding;
- }
-
- abstract protected M wrap(T val);
-
- public TypeEncoding<T> getCanonicalEncoding()
- {
- return null;
- }
-
- public Collection<TypeEncoding<T>> getAllEncodings()
- {
- Collection values = _encodings.values();
- Collection unmodifiable = Collections.unmodifiableCollection(values);
- return (Collection<TypeEncoding<T>>) unmodifiable;
- }
-
- public void write(final T val)
- {
- TypeEncoding<T> encoding = getEncoding(val);
- encoding.writeConstructor();
- encoding.writeValue(val);
- }
-
- private class DynamicDescribedTypeEncoding implements TypeEncoding<T>
- {
- private final TypeEncoding<M> _underlyingEncoding;
- private final TypeEncoding<UnsignedLong> _descriptorType;
- private final int _constructorSize;
-
-
- public DynamicDescribedTypeEncoding(final TypeEncoding<M> underlyingEncoding)
- {
- _underlyingEncoding = underlyingEncoding;
- _descriptorType = _encoder.getType(getDescriptor()).getEncoding(getDescriptor());
- _constructorSize = 1 + _descriptorType.getConstructorSize()
- + _descriptorType.getValueSize(getDescriptor())
- + _underlyingEncoding.getConstructorSize();
- }
-
- public AMQPType<T> getType()
- {
- return AbstractDescribedType.this;
- }
-
- public void writeConstructor()
- {
- _encoder.writeRaw(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
- _descriptorType.writeConstructor();
- _descriptorType.writeValue(getDescriptor());
- _underlyingEncoding.writeConstructor();
- }
-
- public int getConstructorSize()
- {
- return _constructorSize;
- }
-
- public void writeValue(final T val)
- {
- _underlyingEncoding.writeValue(wrap(val));
- }
-
- public int getValueSize(final T val)
- {
- return _underlyingEncoding.getValueSize(wrap(val));
- }
-
- public boolean isFixedSizeVal()
- {
- return _underlyingEncoding.isFixedSizeVal();
- }
-
- public boolean encodesSuperset(final TypeEncoding<T> encoding)
- {
- return (getType() == encoding.getType())
- && (_underlyingEncoding.encodesSuperset(((DynamicDescribedTypeEncoding)encoding)
- ._underlyingEncoding));
- }
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return false;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveType.java
deleted file mode 100644
index 9a8c9c4..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveType.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-abstract class AbstractPrimitiveType<T> implements PrimitiveType<T>
-{
- public final void write(T val)
- {
- final TypeEncoding<T> encoding = getEncoding(val);
- encoding.writeConstructor();
- encoding.writeValue(val);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveTypeEncoding.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveTypeEncoding.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveTypeEncoding.java
deleted file mode 100644
index 56079ee..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/AbstractPrimitiveTypeEncoding.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-abstract class AbstractPrimitiveTypeEncoding<T> implements PrimitiveTypeEncoding<T>
-{
- private final EncoderImpl _encoder;
- private final DecoderImpl _decoder;
-
- AbstractPrimitiveTypeEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _encoder = encoder;
- _decoder = decoder;
- }
-
- public final void writeConstructor()
- {
- _encoder.writeRaw(getEncodingCode());
- }
-
- public int getConstructorSize()
- {
- return 1;
- }
-
- public abstract byte getEncodingCode();
-
- protected EncoderImpl getEncoder()
- {
- return _encoder;
- }
-
- public Class<T> getTypeClass()
- {
- return getType().getTypeClass();
- }
-
- protected DecoderImpl getDecoder()
- {
- return _decoder;
- }
-
-
- public boolean encodesJavaPrimitive()
- {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/ArrayType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/ArrayType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/ArrayType.java
deleted file mode 100644
index 45b8dd5..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/ArrayType.java
+++ /dev/null
@@ -1,1150 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.lang.reflect.Array;
-import java.util.Arrays;
-import java.util.Collection;
-
-public class ArrayType implements PrimitiveType<Object[]>
-{
- private final EncoderImpl _encoder;
- private final BooleanType _booleanType;
- private final ByteType _byteType;
- private final ShortType _shortType;
- private final IntegerType _integerType;
- private final LongType _longType;
- private final FloatType _floatType;
- private final DoubleType _doubleType;
- private final CharacterType _characterType;
-
- public static interface ArrayEncoding extends PrimitiveTypeEncoding<Object[]>
- {
- void writeValue(boolean[] a);
- void writeValue(byte[] a);
- void writeValue(short[] a);
- void writeValue(int[] a);
- void writeValue(long[] a);
- void writeValue(float[] a);
- void writeValue(double[] a);
- void writeValue(char[] a);
-
- void setValue(Object[] val, TypeEncoding encoder, int size);
-
- int getSizeBytes();
-
- Object readValueArray();
- }
-
- private final ArrayEncoding _shortArrayEncoding;
- private final ArrayEncoding _arrayEncoding;
-
- public ArrayType(EncoderImpl encoder,
- final DecoderImpl decoder, BooleanType boolType,
- ByteType byteType,
- ShortType shortType,
- IntegerType intType,
- LongType longType,
- FloatType floatType,
- DoubleType doubleType,
- CharacterType characterType)
- {
- _encoder = encoder;
- _booleanType = boolType;
- _byteType = byteType;
- _shortType = shortType;
- _integerType = intType;
- _longType = longType;
- _floatType = floatType;
- _doubleType = doubleType;
- _characterType = characterType;
-
- _arrayEncoding = new AllArrayEncoding(encoder, decoder);
- _shortArrayEncoding = new ShortArrayEncoding(encoder, decoder);
-
- encoder.register(Object[].class, this);
- decoder.register(this);
- }
-
- public Class<Object[]> getTypeClass()
- {
- return Object[].class;
- }
-
- public ArrayEncoding getEncoding(final Object[] val)
- {
- TypeEncoding encoder = calculateEncoder(val,_encoder);
- int size = calculateSize(val, encoder);
- ArrayEncoding arrayEncoding = (val.length > 255 || size > 254)
- ? _arrayEncoding
- : _shortArrayEncoding;
- arrayEncoding.setValue(val, encoder, size);
- return arrayEncoding;
- }
-
- private static TypeEncoding calculateEncoder(final Object[] val, final EncoderImpl encoder)
- {
-
- if(val.length == 0)
- {
- AMQPType underlyingType = encoder.getTypeFromClass(val.getClass().getComponentType());
- return underlyingType.getCanonicalEncoding();
- }
- else
- {
- AMQPType underlyingType = encoder.getTypeFromClass(val.getClass().getComponentType());
- boolean checkTypes = false;
-
- if(val[0].getClass().isArray() && val[0].getClass().getComponentType().isPrimitive())
- {
- Class componentType = val[0].getClass().getComponentType();
- if(componentType == Boolean.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((boolean[])val[0]);
- }
- else if(componentType == Byte.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((byte[])val[0]);
- }
- else if(componentType == Short.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((short[])val[0]);
- }
- else if(componentType == Integer.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((int[])val[0]);
- }
- else if(componentType == Long.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((long[])val[0]);
- }
- else if(componentType == Float.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((float[])val[0]);
- }
- else if(componentType == Double.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((double[])val[0]);
- }
- else if(componentType == Character.TYPE)
- {
- return ((ArrayType)underlyingType).getEncoding((char[])val[0]);
- }
- else
- {
- throw new IllegalArgumentException("Cannot encode arrays of type " + componentType.getName());
- }
- }
- else
- {
-
- if(underlyingType == null)
- {
- checkTypes = true;
- underlyingType = encoder.getType(val[0]);
- }
- TypeEncoding underlyingEncoding = underlyingType.getEncoding(val[0]);
- TypeEncoding canonicalEncoding = underlyingType.getCanonicalEncoding();
-
- for(int i = 0; i < val.length && (checkTypes || underlyingEncoding != canonicalEncoding); i++)
- {
- if(checkTypes && encoder.getType(val[i]) != underlyingType)
- {
- throw new IllegalArgumentException("Non matching types " + underlyingType + " and " + encoder
- .getType(val[i]) + " in array");
- }
-
-
- TypeEncoding elementEncoding = underlyingType.getEncoding(val[i]);
- if(elementEncoding != underlyingEncoding && !underlyingEncoding.encodesSuperset(elementEncoding))
- {
- if(elementEncoding.encodesSuperset(underlyingEncoding))
- {
- underlyingEncoding = elementEncoding;
- }
- else
- {
- underlyingEncoding = canonicalEncoding;
- }
- }
-
- }
-
- return underlyingEncoding;
- }
- }
- }
-
- private static int calculateSize(final Object[] val, final TypeEncoding encoder)
- {
- int size = encoder.getConstructorSize();
- if(encoder.isFixedSizeVal())
- {
- size += val.length * encoder.getValueSize(null);
- }
- else
- {
- for(Object o : val)
- {
- if(o.getClass().isArray() && o.getClass().getComponentType().isPrimitive())
- {
- ArrayEncoding arrayEncoding = (ArrayEncoding) encoder;
- ArrayType arrayType = (ArrayType) arrayEncoding.getType();
-
- Class componentType = o.getClass().getComponentType();
-
- size += 2 * arrayEncoding.getSizeBytes();
-
- TypeEncoding componentEncoding;
- int componentCount;
-
- if(componentType == Boolean.TYPE)
- {
- boolean[] componentArray = (boolean[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Byte.TYPE)
- {
- byte[] componentArray = (byte[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Short.TYPE)
- {
- short[] componentArray = (short[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Integer.TYPE)
- {
- int[] componentArray = (int[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Long.TYPE)
- {
- long[] componentArray = (long[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Float.TYPE)
- {
- float[] componentArray = (float[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Double.TYPE)
- {
- double[] componentArray = (double[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else if(componentType == Character.TYPE)
- {
- char[] componentArray = (char[]) o;
- componentEncoding = arrayType.getUnderlyingEncoding(componentArray);
- componentCount = componentArray.length;
- }
- else
- {
- throw new IllegalArgumentException("Cannot encode arrays of type " + componentType.getName());
- }
-
- size += componentEncoding.getConstructorSize()
- + componentEncoding.getValueSize(null) * componentCount;
-
- }
- else
- {
- size += encoder.getValueSize(o);
- }
- }
- }
-
- return size;
- }
-
- public ArrayEncoding getCanonicalEncoding()
- {
- return _arrayEncoding;
- }
-
- public Collection<ArrayEncoding> getAllEncodings()
- {
- return Arrays.asList(_shortArrayEncoding, _arrayEncoding);
- }
-
- public void write(final Object[] val)
- {
- ArrayEncoding encoding = getEncoding(val);
- encoding.writeConstructor();
- encoding.writeValue(val);
- }
-
- public void write(boolean[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final boolean[] a)
- {
- return a.length < 254 || a.length <= 255 && allSameValue(a) ? _shortArrayEncoding : _arrayEncoding;
- }
-
- private boolean allSameValue(final boolean[] a)
- {
- boolean val = a[0];
- for(int i = 1; i < a.length; i++)
- {
- if(val != a[i])
- {
- return false;
- }
- }
- return true;
- }
-
- public void write(byte[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final byte[] a)
- {
- return a.length < 254 ? _shortArrayEncoding : _arrayEncoding;
- }
-
- public void write(short[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final short[] a)
- {
- return a.length < 127 ? _shortArrayEncoding : _arrayEncoding;
- }
-
- public void write(int[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final int[] a)
- {
- return a.length < 63 || (a.length < 254 && allSmallInts(a)) ? _shortArrayEncoding : _arrayEncoding;
- }
-
- private boolean allSmallInts(final int[] a)
- {
- for(int i = 0; i < a.length; i++)
- {
- if(a[i] < -128 || a[i] > 127)
- {
- return false;
- }
- }
- return true;
- }
-
- public void write(long[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final long[] a)
- {
- return a.length < 31 || (a.length < 254 && allSmallLongs(a)) ? _shortArrayEncoding : _arrayEncoding;
- }
-
- private boolean allSmallLongs(final long[] a)
- {
- for(int i = 0; i < a.length; i++)
- {
- if(a[i] < -128L || a[i] > 127L)
- {
- return false;
- }
- }
- return true;
- }
-
- public void write(float[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final float[] a)
- {
- return a.length < 63 ? _shortArrayEncoding : _arrayEncoding;
- }
-
- public void write(double[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final double[] a)
- {
- return a.length < 31 ? _shortArrayEncoding : _arrayEncoding;
- }
-
- public void write(char[] a)
- {
- ArrayEncoding encoding = getEncoding(a);
- encoding.writeConstructor();
- encoding.writeValue(a);
- }
-
- private ArrayEncoding getEncoding(final char[] a)
- {
- return a.length < 63 ? _shortArrayEncoding : _arrayEncoding;
- }
-
- private class AllArrayEncoding
- extends LargeFloatingSizePrimitiveTypeEncoding<Object[]>
- implements ArrayEncoding
- {
-
- private Object[] _val;
- private TypeEncoding _underlyingEncoder;
- private int _size;
-
- AllArrayEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- public void writeValue(final boolean[] a)
- {
- BooleanType.BooleanEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(boolean b : a)
- {
- underlyingEncoder.writeValue(b);
- }
-
- }
-
- public void writeValue(final byte[] a)
- {
- ByteType.ByteEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(byte b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final short[] a)
- {
- ShortType.ShortEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(short b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final int[] a)
- {
-
- IntegerType.IntegerEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(int b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final long[] a)
- {
-
- LongType.LongEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(long b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final float[] a)
- {
-
- FloatType.FloatEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(float b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final double[] a)
- {
-
- DoubleType.DoubleEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(double b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final char[] a)
- {
-
- CharacterType.CharacterEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw(4 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null));
- getEncoder().writeRaw(a.length);
- underlyingEncoder.writeConstructor();
- for(char b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void setValue(final Object[] val, final TypeEncoding encoder, final int size)
- {
- _val = val;
- _underlyingEncoder = encoder;
- _size = size;
- }
-
- @Override
- protected void writeEncodedValue(final Object[] val)
- {
- TypeEncoding underlyingEncoder;
-
- if(_val != val)
- {
- _val = val;
- _underlyingEncoder = underlyingEncoder = calculateEncoder(val, getEncoder());
- _size = calculateSize(val, underlyingEncoder);
- }
- else
- {
- underlyingEncoder = _underlyingEncoder;
- }
- getEncoder().writeRaw(val.length);
- underlyingEncoder.writeConstructor();
- for(Object o : val)
- {
- underlyingEncoder.writeValue(o);
- }
- }
-
- @Override
- protected int getEncodedValueSize(final Object[] val)
- {
- if(_val != val)
- {
- _val = val;
- _underlyingEncoder = calculateEncoder(val, getEncoder());
- _size = calculateSize(val, _underlyingEncoder);
- }
- return 4 + _size;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.ARRAY32;
- }
-
- public ArrayType getType()
- {
- return ArrayType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Object[]> encoding)
- {
- return getType() == encoding.getType();
- }
-
- public Object[] readValue()
- {
- DecoderImpl decoder = getDecoder();
- int size = decoder.readRawInt();
- int count = decoder.readRawInt();
- return decodeArray(decoder, count);
- }
-
- public Object readValueArray()
- {
- DecoderImpl decoder = getDecoder();
- int size = decoder.readRawInt();
- int count = decoder.readRawInt();
- return decodeArrayAsObject(decoder, count);
- }
-
-
-
- }
-
-
-
- private class ShortArrayEncoding
- extends SmallFloatingSizePrimitiveTypeEncoding<Object[]>
- implements ArrayEncoding
- {
-
- private Object[] _val;
- private TypeEncoding _underlyingEncoder;
- private int _size;
-
- ShortArrayEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- public void writeValue(final boolean[] a)
- {
- BooleanType.BooleanEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(boolean b : a)
- {
- underlyingEncoder.writeValue(b);
- }
-
- }
-
- public void writeValue(final byte[] a)
- {
- ByteType.ByteEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(byte b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final short[] a)
- {
- ShortType.ShortEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(short b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final int[] a)
- {
-
- IntegerType.IntegerEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(int b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final long[] a)
- {
-
- LongType.LongEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(long b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final float[] a)
- {
-
- FloatType.FloatEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(float b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final double[] a)
- {
-
- DoubleType.DoubleEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(double b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void writeValue(final char[] a)
- {
-
- CharacterType.CharacterEncoding underlyingEncoder = getUnderlyingEncoding(a);
- getEncoder().writeRaw((byte)(1 + underlyingEncoder.getConstructorSize()
- + a.length*underlyingEncoder.getValueSize(null)));
- getEncoder().writeRaw((byte)a.length);
- underlyingEncoder.writeConstructor();
- for(char b : a)
- {
- underlyingEncoder.writeValue(b);
- }
- }
-
- public void setValue(final Object[] val, final TypeEncoding encoder, final int size)
- {
- _val = val;
- _underlyingEncoder = encoder;
- _size = size;
- }
-
- @Override
- protected void writeEncodedValue(final Object[] val)
- {
- TypeEncoding underlyingEncoder;
-
- if(_val != val)
- {
- _val = val;
- _underlyingEncoder = underlyingEncoder = calculateEncoder(val, getEncoder());
- _size = calculateSize(val, underlyingEncoder);
- }
- else
- {
- underlyingEncoder = _underlyingEncoder;
- }
- getEncoder().writeRaw((byte)val.length);
- underlyingEncoder.writeConstructor();
- for(Object o : val)
- {
- if(o.getClass().isArray() && o.getClass().getComponentType().isPrimitive())
- {
- ArrayEncoding arrayEncoding = (ArrayEncoding) underlyingEncoder;
- ArrayType arrayType = (ArrayType) arrayEncoding.getType();
-
- Class componentType = o.getClass().getComponentType();
-
- if(componentType == Boolean.TYPE)
- {
- boolean[] componentArray = (boolean[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Byte.TYPE)
- {
- byte[] componentArray = (byte[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Short.TYPE)
- {
- short[] componentArray = (short[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Integer.TYPE)
- {
- int[] componentArray = (int[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Long.TYPE)
- {
- long[] componentArray = (long[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Float.TYPE)
- {
- float[] componentArray = (float[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Double.TYPE)
- {
- double[] componentArray = (double[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else if(componentType == Character.TYPE)
- {
- char[] componentArray = (char[]) o;
- arrayEncoding.writeValue(componentArray);
- }
- else
- {
- throw new IllegalArgumentException("Cannot encode arrays of type " + componentType.getName());
- }
-
- }
- else
- {
- underlyingEncoder.writeValue(o);
- }
- }
- }
-
- @Override
- protected int getEncodedValueSize(final Object[] val)
- {
- if(_val != val)
- {
- _val = val;
- _underlyingEncoder = calculateEncoder(val, getEncoder());
- _size = calculateSize(val, _underlyingEncoder);
- }
- return 1 + _size;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.ARRAY8;
- }
-
- public ArrayType getType()
- {
- return ArrayType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Object[]> encoding)
- {
- return getType() == encoding.getType();
- }
-
- public Object[] readValue()
- {
- DecoderImpl decoder = getDecoder();
- int size = ((int)decoder.readRawByte()) & 0xFF;
- int count = ((int)decoder.readRawByte()) & 0xFF;
- return decodeArray(decoder, count);
- }
-
- public Object readValueArray()
- {
- DecoderImpl decoder = getDecoder();
- int size = ((int)decoder.readRawByte()) & 0xFF;
- int count = ((int)decoder.readRawByte()) & 0xFF;
- return decodeArrayAsObject(decoder, count);
- }
-
- }
-
- private BooleanType.BooleanEncoding getUnderlyingEncoding(final boolean[] a)
- {
- if(a.length == 0)
- {
- return _booleanType.getCanonicalEncoding();
- }
- else
- {
- boolean val = a[0];
- for(int i = 1; i < a.length; i++)
- {
- if(val != a[i])
- {
- return _booleanType.getCanonicalEncoding();
- }
- }
- return _booleanType.getEncoding(val);
- }
- }
-
-
- private ByteType.ByteEncoding getUnderlyingEncoding(final byte[] a)
- {
- return _byteType.getCanonicalEncoding();
- }
-
-
- private ShortType.ShortEncoding getUnderlyingEncoding(final short[] a)
- {
- return _shortType.getCanonicalEncoding();
- }
-
- private IntegerType.IntegerEncoding getUnderlyingEncoding(final int[] a)
- {
- if(a.length == 0 || !allSmallInts(a))
- {
- return _integerType.getCanonicalEncoding();
- }
- else
- {
- return _integerType.getEncoding(a[0]);
- }
- }
-
- private LongType.LongEncoding getUnderlyingEncoding(final long[] a)
- {
- if(a.length == 0 || !allSmallLongs(a))
- {
- return _longType.getCanonicalEncoding();
- }
- else
- {
- return _longType.getEncoding(a[0]);
- }
- }
-
-
- private FloatType.FloatEncoding getUnderlyingEncoding(final float[] a)
- {
- return _floatType.getCanonicalEncoding();
- }
-
-
- private DoubleType.DoubleEncoding getUnderlyingEncoding(final double[] a)
- {
- return _doubleType.getCanonicalEncoding();
- }
-
-
- private CharacterType.CharacterEncoding getUnderlyingEncoding(final char[] a)
- {
- return _characterType.getCanonicalEncoding();
- }
-
- private static Object[] decodeArray(final DecoderImpl decoder, final int count)
- {
- TypeConstructor constructor = decoder.readConstructor();
- return decodeNonPrimitive(decoder, constructor, count);
- }
-
- private static Object[] decodeNonPrimitive(final DecoderImpl decoder,
- final TypeConstructor constructor,
- final int count)
- {
- if (count > decoder.getByteBufferRemaining()) {
- throw new IllegalArgumentException("Array element count "+count+" is specified to be greater than the amount of data available ("+
- decoder.getByteBufferRemaining()+")");
- }
-
- if(constructor instanceof ArrayEncoding)
- {
- ArrayEncoding arrayEncoding = (ArrayEncoding) constructor;
-
- Object[] array = new Object[count];
- for(int i = 0; i < count; i++)
- {
- array[i] = arrayEncoding.readValueArray();
- }
-
- return array;
- }
- else
- {
- Object[] array = (Object[]) Array.newInstance(constructor.getTypeClass(), count);
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readValue();
- }
-
- return array;
- }
- }
-
- private static Object decodeArrayAsObject(final DecoderImpl decoder, final int count)
- {
- TypeConstructor constructor = decoder.readConstructor();
- if(constructor.encodesJavaPrimitive())
- {
- if (count > decoder.getByteBufferRemaining()) {
- throw new IllegalArgumentException("Array element count "+count+" is specified to be greater than the amount of data available ("+
- decoder.getByteBufferRemaining()+")");
- }
-
- if(constructor instanceof BooleanType.BooleanEncoding)
- {
- return decodeBooleanArray((BooleanType.BooleanEncoding) constructor, count);
- }
- else if(constructor instanceof ByteType.ByteEncoding)
- {
- return decodeByteArray((ByteType.ByteEncoding)constructor, count);
- }
- else if(constructor instanceof ShortType.ShortEncoding)
- {
- return decodeShortArray((ShortType.ShortEncoding)constructor, count);
- }
- else if(constructor instanceof IntegerType.IntegerEncoding)
- {
- return decodeIntArray((IntegerType.IntegerEncoding)constructor, count);
- }
- else if(constructor instanceof LongType.LongEncoding)
- {
- return decodeLongArray((LongType.LongEncoding) constructor, count);
- }
- else if(constructor instanceof FloatType.FloatEncoding)
- {
- return decodeFloatArray((FloatType.FloatEncoding) constructor, count);
- }
- else if(constructor instanceof DoubleType.DoubleEncoding)
- {
- return decodeDoubleArray((DoubleType.DoubleEncoding)constructor, count);
- }
- else
- {
- throw new ClassCastException("Unexpected class " + constructor.getClass().getName());
- }
-
- }
- else
- {
- return decodeNonPrimitive(decoder, constructor, count);
- }
-
- }
-
- private static boolean[] decodeBooleanArray(BooleanType.BooleanEncoding constructor, final int count)
- {
- boolean[] array = new boolean[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
- private static byte[] decodeByteArray(ByteType.ByteEncoding constructor , final int count)
- {
- byte[] array = new byte[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
- private static short[] decodeShortArray(ShortType.ShortEncoding constructor, final int count)
- {
- short[] array = new short[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
- private static int[] decodeIntArray(IntegerType.IntegerEncoding constructor, final int count)
- {
- int[] array = new int[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
-
- private static long[] decodeLongArray(LongType.LongEncoding constructor, final int count)
- {
- long[] array = new long[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
- private static float[] decodeFloatArray(FloatType.FloatEncoding constructor, final int count)
- {
- float[] array = new float[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
- private static double[] decodeDoubleArray(DoubleType.DoubleEncoding constructor, final int count)
- {
- double[] array = new double[count];
-
- for(int i = 0; i < count; i++)
- {
- array[i] = constructor.readPrimitiveValue();
- }
-
- return array;
- }
-
-
-
-
-}
-
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/BigIntegerType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/BigIntegerType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/BigIntegerType.java
deleted file mode 100644
index f74e80b..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/BigIntegerType.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Collection;
-
-public class BigIntegerType extends AbstractPrimitiveType<BigInteger> {
-
- public static interface BigIntegerEncoding extends PrimitiveTypeEncoding<BigInteger>
- {
- void write(BigInteger l);
- void writeValue(BigInteger l);
- public BigInteger readPrimitiveValue();
- }
-
- private static final BigInteger BIG_BYTE_MIN = BigInteger.valueOf(Byte.MIN_VALUE);
- private static final BigInteger BIG_BYTE_MAX = BigInteger.valueOf(Byte.MAX_VALUE);
- private static final BigInteger BIG_LONG_MIN = BigInteger.valueOf(Long.MIN_VALUE);;
- private static final BigInteger BIG_LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE);;
-
- private BigIntegerEncoding _BigIntegerEncoding;
- private BigIntegerEncoding _smallBigIntegerEncoding;
-
- BigIntegerType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _BigIntegerEncoding = new AllBigIntegerEncoding(encoder, decoder);
- _smallBigIntegerEncoding = new SmallBigIntegerEncoding(encoder, decoder);
- encoder.register(BigInteger.class, this);
- }
-
- public Class<BigInteger> getTypeClass()
- {
- return BigInteger.class;
- }
-
- public BigIntegerEncoding getEncoding(final BigInteger l)
- {
- return (l.compareTo(BIG_BYTE_MIN) >= 0 && l.compareTo(BIG_BYTE_MAX) <= 0) ? _smallBigIntegerEncoding : _BigIntegerEncoding;
- }
-
-
- public BigIntegerEncoding getCanonicalEncoding()
- {
- return _BigIntegerEncoding;
- }
-
- public Collection<BigIntegerEncoding> getAllEncodings()
- {
- return Arrays.asList(_smallBigIntegerEncoding, _BigIntegerEncoding);
- }
-
- private long longValueExact(final BigInteger val) {
- if (val.compareTo(BIG_LONG_MIN) < 0 || val.compareTo(BIG_LONG_MAX) > 0) {
- throw new ArithmeticException("cannot encode BigInteger not representable as long");
- }
- return val.longValue();
- }
-
- private class AllBigIntegerEncoding extends FixedSizePrimitiveTypeEncoding<BigInteger> implements BigIntegerEncoding
- {
-
- public AllBigIntegerEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected int getFixedSize()
- {
- return 8;
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.LONG;
- }
-
- public BigIntegerType getType()
- {
- return BigIntegerType.this;
- }
-
- public void writeValue(final BigInteger val)
- {
- getEncoder().writeRaw(longValueExact(val));
- }
-
- public void write(final BigInteger l)
- {
- writeConstructor();
- getEncoder().writeRaw(longValueExact(l));
-
- }
-
- public boolean encodesSuperset(final TypeEncoding<BigInteger> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public BigInteger readValue()
- {
- return readPrimitiveValue();
- }
-
- public BigInteger readPrimitiveValue()
- {
- return BigInteger.valueOf(getDecoder().readLong());
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-
- private class SmallBigIntegerEncoding extends FixedSizePrimitiveTypeEncoding<BigInteger> implements BigIntegerEncoding
- {
- public SmallBigIntegerEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.SMALLLONG;
- }
-
- @Override
- protected int getFixedSize()
- {
- return 1;
- }
-
- public void write(final BigInteger l)
- {
- writeConstructor();
- getEncoder().writeRaw(l.byteValue());
- }
-
- public BigInteger readPrimitiveValue()
- {
- return BigInteger.valueOf(getDecoder().readRawByte());
- }
-
- public BigIntegerType getType()
- {
- return BigIntegerType.this;
- }
-
- public void writeValue(final BigInteger val)
- {
- getEncoder().writeRaw(val.byteValue());
- }
-
- public boolean encodesSuperset(final TypeEncoding<BigInteger> encoder)
- {
- return encoder == this;
- }
-
- public BigInteger readValue()
- {
- return readPrimitiveValue();
- }
-
-
- @Override
- public boolean encodesJavaPrimitive()
- {
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/BinaryType.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/BinaryType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/BinaryType.java
deleted file mode 100644
index 88c204f..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/BinaryType.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.proton.codec;
-
-import org.apache.qpid.proton.amqp.Binary;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-public class BinaryType extends AbstractPrimitiveType<Binary>
-{
- private final BinaryEncoding _binaryEncoding;
- private final BinaryEncoding _shortBinaryEncoding;
-
- private static interface BinaryEncoding extends PrimitiveTypeEncoding<Binary>
- {
-
- }
-
- BinaryType(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- _binaryEncoding = new LongBinaryEncoding(encoder, decoder);
- _shortBinaryEncoding = new ShortBinaryEncoding(encoder, decoder);
- encoder.register(Binary.class, this);
- decoder.register(this);
- }
-
- public Class<Binary> getTypeClass()
- {
- return Binary.class;
- }
-
- public BinaryEncoding getEncoding(final Binary val)
- {
- return val.getLength() <= 255 ? _shortBinaryEncoding : _binaryEncoding;
- }
-
-
- public BinaryEncoding getCanonicalEncoding()
- {
- return _binaryEncoding;
- }
-
- public Collection<BinaryEncoding> getAllEncodings()
- {
- return Arrays.asList(_shortBinaryEncoding, _binaryEncoding);
- }
-
- private class LongBinaryEncoding
- extends LargeFloatingSizePrimitiveTypeEncoding<Binary>
- implements BinaryEncoding
- {
-
- public LongBinaryEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected void writeEncodedValue(final Binary val)
- {
- getEncoder().writeRaw(val.getArray(), val.getArrayOffset(), val.getLength());
- }
-
- @Override
- protected int getEncodedValueSize(final Binary val)
- {
- return val.getLength();
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.VBIN32;
- }
-
- public BinaryType getType()
- {
- return BinaryType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Binary> encoding)
- {
- return (getType() == encoding.getType());
- }
-
- public Binary readValue()
- {
- final DecoderImpl decoder = getDecoder();
- int size = decoder.readRawInt();
- if (size > decoder.getByteBufferRemaining()) {
- throw new IllegalArgumentException("Binary data size "+size+" is specified to be greater than the amount of data available ("+
- decoder.getByteBufferRemaining()+")");
- }
- byte[] data = new byte[size];
- decoder.readRaw(data, 0, size);
- return new Binary(data);
- }
- }
-
- private class ShortBinaryEncoding
- extends SmallFloatingSizePrimitiveTypeEncoding<Binary>
- implements BinaryEncoding
- {
-
- public ShortBinaryEncoding(final EncoderImpl encoder, final DecoderImpl decoder)
- {
- super(encoder, decoder);
- }
-
- @Override
- protected void writeEncodedValue(final Binary val)
- {
- getEncoder().writeRaw(val.getArray(), val.getArrayOffset(), val.getLength());
- }
-
- @Override
- protected int getEncodedValueSize(final Binary val)
- {
- return val.getLength();
- }
-
-
- @Override
- public byte getEncodingCode()
- {
- return EncodingCodes.VBIN8;
- }
-
- public BinaryType getType()
- {
- return BinaryType.this;
- }
-
- public boolean encodesSuperset(final TypeEncoding<Binary> encoder)
- {
- return encoder == this;
- }
-
- public Binary readValue()
- {
- int size = ((int)getDecoder().readRawByte()) & 0xff;
- byte[] data = new byte[size];
- getDecoder().readRaw(data, 0, size);
- return new Binary(data);
- }
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org