activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmacn...@apache.org
Subject svn commit: r908857 [2/17] - in /activemq/sandbox/activemq-apollo-actor/activemq-amqp: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/activemq/ src/main/java/org/apache/activemq/amqp/ src/main/jav...
Date Thu, 11 Feb 2010 07:04:46 GMT
Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/Encoded.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/Encoded.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/Encoded.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/Encoded.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.util.buffer.Buffer;
+
+public interface Encoded<E> extends Encoding {
+
+    public boolean isNull();
+    
+    public int getEncodedSize() throws AmqpEncodingError;
+
+    public int getDataSize() throws AmqpEncodingError;
+
+    public int getDataCount() throws AmqpEncodingError;
+
+    public E getValue() throws AmqpEncodingError;
+    
+    public Buffer getBuffer() throws AmqpEncodingError;
+
+    public void encode(Buffer target, int offset) throws AmqpEncodingError;
+    
+    public void marshal(DataOutput out) throws IOException;
+
+    public void marshalData(DataOutput out) throws IOException;
+
+    public void marshalConstructor(DataOutput out) throws IOException;
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/Encoding.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/Encoding.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/Encoding.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/Encoding.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller;
+
+public interface Encoding {
+    
+    public AmqpVersion getEncodingVersion();
+    
+    public byte getEncodingFormatCode();
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/UnexpectedTypeException.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/UnexpectedTypeException.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/UnexpectedTypeException.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/UnexpectedTypeException.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with his work
+ * for additional information regarding copyright ownership. The ASF licenses
+ * this file to You under the Apache License, Version 2.0 (the "License"); you
+ * may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller;
+
+public class UnexpectedTypeException extends AmqpEncodingError {
+
+    private static final long serialVersionUID = 4306936382810257248L;
+
+    public UnexpectedTypeException(String msg) {
+        super(msg);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpAttachMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpAttachMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpAttachMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpAttachMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,177 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpAttach;
+import org.apache.activemq.amqp.protocol.types.AmqpBoolean;
+import org.apache.activemq.amqp.protocol.types.AmqpOptions;
+import org.apache.activemq.amqp.protocol.types.AmqpSequenceNo;
+import org.apache.activemq.amqp.protocol.types.AmqpSessionName;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUbyte;
+import org.apache.activemq.amqp.protocol.types.AmqpUint;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpAttachMarshaller implements DescribedTypeMarshaller<AmqpAttach>{
+
+    static final AmqpAttachMarshaller SINGLETON = new AmqpAttachMarshaller();
+    private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+    public static final String SYMBOLIC_ID = "amqp:attach:list";
+    //Format code: 0x00000001:0x00000202:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 514;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294967810L)
+    //Hard coded descriptor:
+    public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+        (byte) 0x80,                                         // ulong descriptor encoding)
+        (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,  // CATEGORY CODE
+        (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x02   // DESCRIPTOR ID CODE
+    }), 0);
+
+    private static final ListDecoder DECODER = new ListDecoder() {
+        public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+            switch(pos) {
+            case 0: {
+                return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(in));
+            }
+            case 1: {
+                return AmqpSessionName.AmqpSessionNameBuffer.create(AmqpBinaryMarshaller.createEncoded(in));
+            }
+            case 2: {
+                return AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in));
+            }
+            case 3: {
+                return AmqpSequenceNo.AmqpSequenceNoBuffer.create(AmqpUintMarshaller.createEncoded(in));
+            }
+            case 4: {
+                return AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.createEncoded(in));
+            }
+            case 5: {
+                return AmqpUbyte.AmqpUbyteBuffer.create(AmqpUbyteMarshaller.createEncoded(in));
+            }
+            case 6: {
+                return AmqpUbyte.AmqpUbyteBuffer.create(AmqpUbyteMarshaller.createEncoded(in));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.unmarshalType(in);
+            }
+            }
+        }
+
+        public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+            switch(pos) {
+            case 0: {
+                return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+            }
+            case 1: {
+                return AmqpSessionName.AmqpSessionNameBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+            }
+            case 2: {
+                return AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(buffer));
+            }
+            case 3: {
+                return AmqpSequenceNo.AmqpSequenceNoBuffer.create(AmqpUintMarshaller.createEncoded(buffer));
+            }
+            case 4: {
+                return AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.createEncoded(buffer));
+            }
+            case 5: {
+                return AmqpUbyte.AmqpUbyteBuffer.create(AmqpUbyteMarshaller.createEncoded(buffer));
+            }
+            case 6: {
+                return AmqpUbyte.AmqpUbyteBuffer.create(AmqpUbyteMarshaller.createEncoded(buffer));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.decodeType(buffer);
+            }
+            }
+        }
+    };
+
+    public static class AmqpAttachEncoded extends DescribedEncoded<IAmqpList> {
+
+        public AmqpAttachEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpAttachEncoded(AmqpAttach value) {
+            super(AmqpListMarshaller.encode(value));
+        }
+
+        protected final String getSymbolicId() {
+            return SYMBOLIC_ID;
+        }
+
+        protected final long getNumericId() {
+            return NUMERIC_ID;
+        }
+
+        protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+            return AmqpListMarshaller.createEncoded(encoded, DECODER);
+        }
+
+        protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+            return AmqpListMarshaller.createEncoded(in, DECODER);
+        }
+
+        protected final EncodedBuffer getDescriptor() {
+            return DESCRIPTOR;
+        }
+    }
+
+    public static final Encoded<IAmqpList> encode(AmqpAttach value) throws AmqpEncodingError {
+        return new AmqpAttachEncoded(value);
+    }
+
+    static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        byte fc = buffer.getEncodingFormatCode();
+        if (fc == Encoder.NULL_FORMAT_CODE) {
+            return NULL_ENCODED;
+        }
+
+        DescribedBuffer db = buffer.asDescribed();
+        AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+        if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+               descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+            throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+        }
+        return new AmqpAttachEncoded(db);
+    }
+
+    public final AmqpAttach.AmqpAttachBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpAttach.AmqpAttachBuffer.create(new AmqpAttachEncoded(encoded));
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBarMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBarMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBarMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBarMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,150 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpBar;
+import org.apache.activemq.amqp.protocol.types.AmqpDeliveryTag;
+import org.apache.activemq.amqp.protocol.types.AmqpHandle;
+import org.apache.activemq.amqp.protocol.types.AmqpOptions;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpBarMarshaller implements DescribedTypeMarshaller<AmqpBar>{
+
+    static final AmqpBarMarshaller SINGLETON = new AmqpBarMarshaller();
+    private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+    public static final String SYMBOLIC_ID = "amqp:bar:list";
+    //Format code: 0x00000001:0x00009901:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 39169;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4295006465L)
+    //Hard coded descriptor:
+    public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+        (byte) 0x80,                                         // ulong descriptor encoding)
+        (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,  // CATEGORY CODE
+        (byte) 0x00, (byte) 0x00, (byte) 0x99, (byte) 0x01   // DESCRIPTOR ID CODE
+    }), 0);
+
+    private static final ListDecoder DECODER = new ListDecoder() {
+        public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+            switch(pos) {
+            case 0: {
+                return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(in));
+            }
+            case 1: {
+                return AmqpHandle.AmqpHandleBuffer.create(AmqpUintMarshaller.createEncoded(in));
+            }
+            case 2: {
+                return AmqpDeliveryTag.AmqpDeliveryTagBuffer.create(AmqpBinaryMarshaller.createEncoded(in));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.unmarshalType(in);
+            }
+            }
+        }
+
+        public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+            switch(pos) {
+            case 0: {
+                return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+            }
+            case 1: {
+                return AmqpHandle.AmqpHandleBuffer.create(AmqpUintMarshaller.createEncoded(buffer));
+            }
+            case 2: {
+                return AmqpDeliveryTag.AmqpDeliveryTagBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.decodeType(buffer);
+            }
+            }
+        }
+    };
+
+    public static class AmqpBarEncoded extends DescribedEncoded<IAmqpList> {
+
+        public AmqpBarEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpBarEncoded(AmqpBar value) {
+            super(AmqpListMarshaller.encode(value));
+        }
+
+        protected final String getSymbolicId() {
+            return SYMBOLIC_ID;
+        }
+
+        protected final long getNumericId() {
+            return NUMERIC_ID;
+        }
+
+        protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+            return AmqpListMarshaller.createEncoded(encoded, DECODER);
+        }
+
+        protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+            return AmqpListMarshaller.createEncoded(in, DECODER);
+        }
+
+        protected final EncodedBuffer getDescriptor() {
+            return DESCRIPTOR;
+        }
+    }
+
+    public static final Encoded<IAmqpList> encode(AmqpBar value) throws AmqpEncodingError {
+        return new AmqpBarEncoded(value);
+    }
+
+    static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        byte fc = buffer.getEncodingFormatCode();
+        if (fc == Encoder.NULL_FORMAT_CODE) {
+            return NULL_ENCODED;
+        }
+
+        DescribedBuffer db = buffer.asDescribed();
+        AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+        if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+               descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+            throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+        }
+        return new AmqpBarEncoded(db);
+    }
+
+    public final AmqpBar.AmqpBarBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpBar.AmqpBarBuffer.create(new AmqpBarEncoded(encoded));
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBinaryMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBinaryMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBinaryMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBinaryMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,215 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpVersion;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.Encoding;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpBinary;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpBinaryMarshaller {
+
+    private static final Encoder ENCODER = Encoder.SINGLETON;
+    private static final Encoded<Buffer> NULL_ENCODED = new Encoder.NullEncoded<Buffer>();
+
+    public static final byte VBIN8_FORMAT_CODE = (byte) 0xa0;
+    public static final byte VBIN32_FORMAT_CODE = (byte) 0xb0;
+
+    public static enum BINARY_ENCODING implements Encoding{
+        VBIN8 (VBIN8_FORMAT_CODE), // up to 2^8 - 1 octets of binary data
+        VBIN32 (VBIN32_FORMAT_CODE); // up to 2^32 - 1 octets of binary data
+
+        public final byte FORMAT_CODE;
+        public final FormatSubCategory CATEGORY;
+
+        BINARY_ENCODING(byte formatCode) {
+            this.FORMAT_CODE = formatCode;
+            this.CATEGORY = FormatSubCategory.getCategory(formatCode);
+        }
+
+        public final byte getEncodingFormatCode() {
+            return FORMAT_CODE;
+        }
+
+        public final AmqpVersion getEncodingVersion() {
+            return AmqpMarshaller.VERSION;
+        }
+
+        public static BINARY_ENCODING getEncoding(byte formatCode) throws UnexpectedTypeException {
+            switch(formatCode) {
+            case VBIN8_FORMAT_CODE: {
+                return VBIN8;
+            }
+            case VBIN32_FORMAT_CODE: {
+                return VBIN32;
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for Binary: " + formatCode);
+            }
+            }
+        }
+
+        static final AmqpBinaryEncoded createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+            switch(buffer.getEncodingFormatCode()) {
+            case VBIN8_FORMAT_CODE: {
+                return new AmqpBinaryVbin8Encoded(buffer);
+            }
+            case VBIN32_FORMAT_CODE: {
+                return new AmqpBinaryVbin32Encoded(buffer);
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for Binary: " + buffer.getEncodingFormatCode());
+            }
+            }
+        }
+        static final AmqpBinaryEncoded createEncoded(byte formatCode, Buffer value) throws AmqpEncodingError {
+            switch(formatCode) {
+            case VBIN8_FORMAT_CODE: {
+                return new AmqpBinaryVbin8Encoded(value);
+            }
+            case VBIN32_FORMAT_CODE: {
+                return new AmqpBinaryVbin32Encoded(value);
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for Binary: " + formatCode);
+            }
+            }
+        }
+    }
+    public static abstract class AmqpBinaryEncoded extends AbstractEncoded <Buffer> {
+        public AmqpBinaryEncoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpBinaryEncoded(byte formatCode, Buffer value) throws AmqpEncodingError {
+            super(formatCode, value);
+        }
+    }
+
+    /**
+     * up to 2^8 - 1 octets of binary data
+     */
+    private static class AmqpBinaryVbin8Encoded extends AmqpBinaryEncoded {
+
+        private final BINARY_ENCODING encoding = BINARY_ENCODING.VBIN8;
+        public AmqpBinaryVbin8Encoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpBinaryVbin8Encoded(Buffer value) throws AmqpEncodingError {
+            super(BINARY_ENCODING.VBIN8.FORMAT_CODE, value);
+        }
+
+        protected final int computeDataSize() throws AmqpEncodingError {
+            return ENCODER.getEncodedSizeOfBinary(value, encoding);
+        }
+
+        public final void encode(Buffer value, Buffer encoded, int offset) throws AmqpEncodingError {
+            ENCODER.encodeBinaryVbin8(value, encoded, offset);
+        }
+
+        public final Buffer decode(EncodedBuffer encoded) throws AmqpEncodingError {
+            return ENCODER.decodeBinaryVbin8(encoded.getBuffer(), encoded.getDataOffset(), encoded.getDataSize());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeBinaryVbin8(value, out);
+        }
+
+        public final Buffer unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readBinaryVbin8(getDataSize(), in);
+        }
+    }
+
+    /**
+     * up to 2^32 - 1 octets of binary data
+     */
+    private static class AmqpBinaryVbin32Encoded extends AmqpBinaryEncoded {
+
+        private final BINARY_ENCODING encoding = BINARY_ENCODING.VBIN32;
+        public AmqpBinaryVbin32Encoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpBinaryVbin32Encoded(Buffer value) throws AmqpEncodingError {
+            super(BINARY_ENCODING.VBIN32.FORMAT_CODE, value);
+        }
+
+        protected final int computeDataSize() throws AmqpEncodingError {
+            return ENCODER.getEncodedSizeOfBinary(value, encoding);
+        }
+
+        public final void encode(Buffer value, Buffer encoded, int offset) throws AmqpEncodingError {
+            ENCODER.encodeBinaryVbin32(value, encoded, offset);
+        }
+
+        public final Buffer decode(EncodedBuffer encoded) throws AmqpEncodingError {
+            return ENCODER.decodeBinaryVbin32(encoded.getBuffer(), encoded.getDataOffset(), encoded.getDataSize());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeBinaryVbin32(value, out);
+        }
+
+        public final Buffer unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readBinaryVbin32(getDataSize(), in);
+        }
+    }
+
+
+    private static final BINARY_ENCODING chooseEncoding(AmqpBinary val) throws AmqpEncodingError {
+        return Encoder.chooseBinaryEncoding(val.getValue());
+    }
+
+    private static final BINARY_ENCODING chooseEncoding(Buffer val) throws AmqpEncodingError {
+        return Encoder.chooseBinaryEncoding(val);
+    }
+
+    static final Encoded<Buffer> encode(AmqpBinary data) throws AmqpEncodingError {
+        if(data == null) {
+            return NULL_ENCODED;
+        }
+        return BINARY_ENCODING.createEncoded(chooseEncoding(data).FORMAT_CODE, data.getValue());
+    }
+
+    static final Encoded<Buffer> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<Buffer> createEncoded(Buffer val) throws AmqpEncodingError {
+        return BINARY_ENCODING.createEncoded(chooseEncoding(val).FORMAT_CODE, val);
+    }
+
+    static final Encoded<Buffer> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<Buffer> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        if(buffer.getEncodingFormatCode() == AmqpNullMarshaller.FORMAT_CODE) {
+            return NULL_ENCODED;
+        }
+        return BINARY_ENCODING.createEncoded(buffer);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBooleanMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBooleanMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBooleanMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpBooleanMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,208 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.lang.Boolean;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpVersion;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.Encoding;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpBoolean;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpBooleanMarshaller {
+
+    private static final Encoder ENCODER = Encoder.SINGLETON;
+    private static final Encoded<Boolean> NULL_ENCODED = new Encoder.NullEncoded<Boolean>();
+
+    public static final byte TRUE_FORMAT_CODE = (byte) 0x41;
+    public static final byte FALSE_FORMAT_CODE = (byte) 0x42;
+
+    public static enum BOOLEAN_ENCODING implements Encoding{
+        TRUE (TRUE_FORMAT_CODE), // the boolean value true
+        FALSE (FALSE_FORMAT_CODE); // the boolean value false
+
+        public final byte FORMAT_CODE;
+        public final FormatSubCategory CATEGORY;
+
+        BOOLEAN_ENCODING(byte formatCode) {
+            this.FORMAT_CODE = formatCode;
+            this.CATEGORY = FormatSubCategory.getCategory(formatCode);
+        }
+
+        public final byte getEncodingFormatCode() {
+            return FORMAT_CODE;
+        }
+
+        public final AmqpVersion getEncodingVersion() {
+            return AmqpMarshaller.VERSION;
+        }
+
+        public static BOOLEAN_ENCODING getEncoding(byte formatCode) throws UnexpectedTypeException {
+            switch(formatCode) {
+            case TRUE_FORMAT_CODE: {
+                return TRUE;
+            }
+            case FALSE_FORMAT_CODE: {
+                return FALSE;
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for Boolean: " + formatCode);
+            }
+            }
+        }
+
+        static final AmqpBooleanEncoded createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+            switch(buffer.getEncodingFormatCode()) {
+            case TRUE_FORMAT_CODE: {
+                return new AmqpBooleanTrueEncoded(buffer);
+            }
+            case FALSE_FORMAT_CODE: {
+                return new AmqpBooleanFalseEncoded(buffer);
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for Boolean: " + buffer.getEncodingFormatCode());
+            }
+            }
+        }
+        static final AmqpBooleanEncoded createEncoded(byte formatCode, Boolean value) throws AmqpEncodingError {
+            switch(formatCode) {
+            case TRUE_FORMAT_CODE: {
+                return new AmqpBooleanTrueEncoded(value);
+            }
+            case FALSE_FORMAT_CODE: {
+                return new AmqpBooleanFalseEncoded(value);
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for Boolean: " + formatCode);
+            }
+            }
+        }
+    }
+    public static abstract class AmqpBooleanEncoded extends AbstractEncoded <Boolean> {
+        public AmqpBooleanEncoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpBooleanEncoded(byte formatCode, Boolean value) throws AmqpEncodingError {
+            super(formatCode, value);
+        }
+    }
+
+    /**
+     * the boolean value true
+     */
+    private static class AmqpBooleanTrueEncoded extends AmqpBooleanEncoded {
+
+        private final BOOLEAN_ENCODING encoding = BOOLEAN_ENCODING.TRUE;
+        public AmqpBooleanTrueEncoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpBooleanTrueEncoded(Boolean value) throws AmqpEncodingError {
+            super(BOOLEAN_ENCODING.TRUE.FORMAT_CODE, value);
+        }
+
+        public final void encode(Boolean value, Buffer encoded, int offset) throws AmqpEncodingError {
+
+        }
+
+        public final Boolean decode(EncodedBuffer encoded) throws AmqpEncodingError {
+            return ENCODER.valueOfBoolean(encoding);
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+
+        }
+
+        public final Boolean unmarshalData(DataInput in) throws IOException {
+            return ENCODER.valueOfBoolean(encoding);
+        }
+    }
+
+    /**
+     * the boolean value false
+     */
+    private static class AmqpBooleanFalseEncoded extends AmqpBooleanEncoded {
+
+        private final BOOLEAN_ENCODING encoding = BOOLEAN_ENCODING.FALSE;
+        public AmqpBooleanFalseEncoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpBooleanFalseEncoded(Boolean value) throws AmqpEncodingError {
+            super(BOOLEAN_ENCODING.FALSE.FORMAT_CODE, value);
+        }
+
+        public final void encode(Boolean value, Buffer encoded, int offset) throws AmqpEncodingError {
+
+        }
+
+        public final Boolean decode(EncodedBuffer encoded) throws AmqpEncodingError {
+            return ENCODER.valueOfBoolean(encoding);
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+
+        }
+
+        public final Boolean unmarshalData(DataInput in) throws IOException {
+            return ENCODER.valueOfBoolean(encoding);
+        }
+    }
+
+
+    private static final BOOLEAN_ENCODING chooseEncoding(AmqpBoolean val) throws AmqpEncodingError {
+        return Encoder.chooseBooleanEncoding(val.getValue());
+    }
+
+    private static final BOOLEAN_ENCODING chooseEncoding(Boolean val) throws AmqpEncodingError {
+        return Encoder.chooseBooleanEncoding(val);
+    }
+
+    static final Encoded<Boolean> encode(AmqpBoolean data) throws AmqpEncodingError {
+        if(data == null) {
+            return NULL_ENCODED;
+        }
+        return BOOLEAN_ENCODING.createEncoded(chooseEncoding(data).FORMAT_CODE, data.getValue());
+    }
+
+    static final Encoded<Boolean> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<Boolean> createEncoded(Boolean val) throws AmqpEncodingError {
+        return BOOLEAN_ENCODING.createEncoded(chooseEncoding(val).FORMAT_CODE, val);
+    }
+
+    static final Encoded<Boolean> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<Boolean> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        if(buffer.getEncodingFormatCode() == AmqpNullMarshaller.FORMAT_CODE) {
+            return NULL_ENCODED;
+        }
+        return BOOLEAN_ENCODING.createEncoded(buffer);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpByteMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpByteMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpByteMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpByteMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.lang.Byte;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpByte;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpByteMarshaller {
+
+    private static final Encoder ENCODER = Encoder.SINGLETON;
+    private static final Encoded<Byte> NULL_ENCODED = new Encoder.NullEncoded<Byte>();
+
+    public static final byte FORMAT_CODE = (byte) 0x51;
+    public static final FormatSubCategory FORMAT_CATEGORY  = FormatSubCategory.getCategory(FORMAT_CODE);
+
+    public static class AmqpByteEncoded  extends AbstractEncoded<Byte> {
+
+        public AmqpByteEncoded (EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpByteEncoded (Byte value) throws AmqpEncodingError {
+            super(FORMAT_CODE, value);
+        }
+
+        public final void encode(Byte value, Buffer encoded, int offset) throws AmqpEncodingError{
+            ENCODER.encodeByte(value, encoded, offset);
+        }
+
+        public final Byte decode(EncodedBuffer encoded) throws AmqpEncodingError{
+            return ENCODER.decodeByte(encoded.getBuffer(), encoded.getDataOffset());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeByte(value, out);
+        }
+
+        public final Byte unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readByte(in);
+        }
+    }
+
+    public static final Encoded<Byte> encode(AmqpByte data) throws AmqpEncodingError {
+        if(data == null) {
+            return NULL_ENCODED;
+        }
+        return new AmqpByteEncoded(data.getValue());
+    }
+
+    static final Encoded<Byte> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<Byte> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<Byte> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        if(buffer.getEncodingFormatCode() == AmqpNullMarshaller.FORMAT_CODE) {
+            return new Encoder.NullEncoded<Byte>();
+        }
+        if(buffer.getEncodingFormatCode() != FORMAT_CODE) {
+            throw new AmqpEncodingError("Unexpected format for AmqpByte expected: " + FORMAT_CODE);
+        }
+        return new AmqpByteEncoded(buffer);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCharMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCharMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCharMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCharMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.lang.Integer;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpChar;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpCharMarshaller {
+
+    private static final Encoder ENCODER = Encoder.SINGLETON;
+    private static final Encoded<Integer> NULL_ENCODED = new Encoder.NullEncoded<Integer>();
+
+    public static final byte FORMAT_CODE = (byte) 0x73;
+    public static final FormatSubCategory FORMAT_CATEGORY  = FormatSubCategory.getCategory(FORMAT_CODE);
+
+    public static class AmqpCharEncoded  extends AbstractEncoded<Integer> {
+
+        public AmqpCharEncoded (EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpCharEncoded (Integer value) throws AmqpEncodingError {
+            super(FORMAT_CODE, value);
+        }
+
+        public final void encode(Integer value, Buffer encoded, int offset) throws AmqpEncodingError{
+            ENCODER.encodeChar(value, encoded, offset);
+        }
+
+        public final Integer decode(EncodedBuffer encoded) throws AmqpEncodingError{
+            return ENCODER.decodeChar(encoded.getBuffer(), encoded.getDataOffset());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeChar(value, out);
+        }
+
+        public final Integer unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readChar(in);
+        }
+    }
+
+    public static final Encoded<Integer> encode(AmqpChar data) throws AmqpEncodingError {
+        if(data == null) {
+            return NULL_ENCODED;
+        }
+        return new AmqpCharEncoded(data.getValue());
+    }
+
+    static final Encoded<Integer> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<Integer> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<Integer> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        if(buffer.getEncodingFormatCode() == AmqpNullMarshaller.FORMAT_CODE) {
+            return new Encoder.NullEncoded<Integer>();
+        }
+        if(buffer.getEncodingFormatCode() != FORMAT_CODE) {
+            throw new AmqpEncodingError("Unexpected format for AmqpChar expected: " + FORMAT_CODE);
+        }
+        return new AmqpCharEncoded(buffer);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCloseMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCloseMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCloseMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCloseMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,143 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpClose;
+import org.apache.activemq.amqp.protocol.types.AmqpConnectionError;
+import org.apache.activemq.amqp.protocol.types.AmqpOptions;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpCloseMarshaller implements DescribedTypeMarshaller<AmqpClose>{
+
+    static final AmqpCloseMarshaller SINGLETON = new AmqpCloseMarshaller();
+    private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+    public static final String SYMBOLIC_ID = "amqp:close:list";
+    //Format code: 0x00000001:0x00000204:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 516;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294967812L)
+    //Hard coded descriptor:
+    public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+        (byte) 0x80,                                         // ulong descriptor encoding)
+        (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,  // CATEGORY CODE
+        (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x04   // DESCRIPTOR ID CODE
+    }), 0);
+
+    private static final ListDecoder DECODER = new ListDecoder() {
+        public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+            switch(pos) {
+            case 0: {
+                return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(in));
+            }
+            case 1: {
+                return AmqpConnectionError.AmqpConnectionErrorBuffer.create(AmqpConnectionErrorMarshaller.createEncoded(in));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.unmarshalType(in);
+            }
+            }
+        }
+
+        public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+            switch(pos) {
+            case 0: {
+                return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+            }
+            case 1: {
+                return AmqpConnectionError.AmqpConnectionErrorBuffer.create(AmqpConnectionErrorMarshaller.createEncoded(buffer));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.decodeType(buffer);
+            }
+            }
+        }
+    };
+
+    public static class AmqpCloseEncoded extends DescribedEncoded<IAmqpList> {
+
+        public AmqpCloseEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpCloseEncoded(AmqpClose value) {
+            super(AmqpListMarshaller.encode(value));
+        }
+
+        protected final String getSymbolicId() {
+            return SYMBOLIC_ID;
+        }
+
+        protected final long getNumericId() {
+            return NUMERIC_ID;
+        }
+
+        protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+            return AmqpListMarshaller.createEncoded(encoded, DECODER);
+        }
+
+        protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+            return AmqpListMarshaller.createEncoded(in, DECODER);
+        }
+
+        protected final EncodedBuffer getDescriptor() {
+            return DESCRIPTOR;
+        }
+    }
+
+    public static final Encoded<IAmqpList> encode(AmqpClose value) throws AmqpEncodingError {
+        return new AmqpCloseEncoded(value);
+    }
+
+    static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        byte fc = buffer.getEncodingFormatCode();
+        if (fc == Encoder.NULL_FORMAT_CODE) {
+            return NULL_ENCODED;
+        }
+
+        DescribedBuffer db = buffer.asDescribed();
+        AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+        if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+               descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+            throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+        }
+        return new AmqpCloseEncoded(db);
+    }
+
+    public final AmqpClose.AmqpCloseBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpClose.AmqpCloseBuffer.create(new AmqpCloseEncoded(encoded));
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCompletedMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCompletedMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCompletedMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpCompletedMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,146 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpBoolean;
+import org.apache.activemq.amqp.protocol.types.AmqpCompleted;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpCompletedMarshaller implements DescribedTypeMarshaller<AmqpCompleted>{
+
+    static final AmqpCompletedMarshaller SINGLETON = new AmqpCompletedMarshaller();
+    private static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> NULL_ENCODED = new Encoder.NullEncoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>>();
+
+    public static final String SYMBOLIC_ID = "amqp:completed:map";
+    //Format code: 0x00000001:0x00009806:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 38918;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4295006214L)
+    //Hard coded descriptor:
+    public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+        (byte) 0x80,                                         // ulong descriptor encoding)
+        (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,  // CATEGORY CODE
+        (byte) 0x00, (byte) 0x00, (byte) 0x98, (byte) 0x06   // DESCRIPTOR ID CODE
+    }), 0);
+
+    //Accessor keys for field mapped fields:
+    private static final AmqpSymbol.AmqpSymbolBuffer TRUNCATE_KEY = new AmqpSymbol.AmqpSymbolBean("truncate").getBuffer(AmqpMarshaller.SINGLETON);
+
+
+    private static final MapDecoder DECODER = new MapDecoder() {
+        public void decodeToMap(EncodedBuffer encodedKey, EncodedBuffer encodedValue, Map<AmqpType<?, ?>,AmqpType<?, ?>> map) throws AmqpEncodingError {
+            AmqpSymbol key = AmqpSymbol.AmqpSymbolBuffer.create(AmqpSymbolMarshaller.createEncoded(encodedKey));
+            if (key == null) {
+                throw new AmqpEncodingError("Null Key for " + SYMBOLIC_ID);
+            }
+
+            if (key.getValue().equals(TRUNCATE_KEY.getValue())){
+                map.put(TRUNCATE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(encodedValue)));
+            }
+            else {
+                throw new UnexpectedTypeException("Invalid Key for " + SYMBOLIC_ID + " : " + key);
+            }
+        }
+        public void unmarshalToMap(DataInput in, Map<AmqpType<?, ?>,AmqpType<?, ?>> map) throws AmqpEncodingError, IOException {
+            AmqpSymbol key = AmqpSymbol.AmqpSymbolBuffer.create(AmqpSymbolMarshaller.createEncoded(in));
+            if (key == null) {
+                throw new AmqpEncodingError("Null Key for " + SYMBOLIC_ID);
+            }
+
+            if (key.getValue().equals(TRUNCATE_KEY.getValue())){
+                map.put(TRUNCATE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in)));
+            }
+            else {
+                throw new UnexpectedTypeException("Invalid Key for " + SYMBOLIC_ID + " : " + key);
+            }
+        }
+    };
+
+    public static class AmqpCompletedEncoded extends DescribedEncoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> {
+
+        public AmqpCompletedEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpCompletedEncoded(AmqpCompleted value) {
+            super(AmqpMapMarshaller.encode(value));
+        }
+
+        protected final String getSymbolicId() {
+            return SYMBOLIC_ID;
+        }
+
+        protected final long getNumericId() {
+            return NUMERIC_ID;
+        }
+
+        protected final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+            return AmqpMapMarshaller.createEncoded(encoded, DECODER);
+        }
+
+        protected final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> unmarshalDescribed(DataInput in) throws IOException {
+            return AmqpMapMarshaller.createEncoded(in, DECODER);
+        }
+
+        protected final EncodedBuffer getDescriptor() {
+            return DESCRIPTOR;
+        }
+    }
+
+    public static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> encode(AmqpCompleted value) throws AmqpEncodingError {
+        return new AmqpCompletedEncoded(value);
+    }
+
+    static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        byte fc = buffer.getEncodingFormatCode();
+        if (fc == Encoder.NULL_FORMAT_CODE) {
+            return NULL_ENCODED;
+        }
+
+        DescribedBuffer db = buffer.asDescribed();
+        AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+        if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+               descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+            throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+        }
+        return new AmqpCompletedEncoded(db);
+    }
+
+    public final AmqpCompleted.AmqpCompletedBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpCompleted.AmqpCompletedBuffer.create(new AmqpCompletedEncoded(encoded));
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpConnectionErrorMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpConnectionErrorMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpConnectionErrorMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpConnectionErrorMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,150 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpConnectionError;
+import org.apache.activemq.amqp.protocol.types.AmqpMap;
+import org.apache.activemq.amqp.protocol.types.AmqpString;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.AmqpUshort;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpConnectionErrorMarshaller implements DescribedTypeMarshaller<AmqpConnectionError>{
+
+    static final AmqpConnectionErrorMarshaller SINGLETON = new AmqpConnectionErrorMarshaller();
+    private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+    public static final String SYMBOLIC_ID = "amqp:connection-error:list";
+    //Format code: 0x00000001:0x00000101:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 257;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294967553L)
+    //Hard coded descriptor:
+    public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+        (byte) 0x80,                                         // ulong descriptor encoding)
+        (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,  // CATEGORY CODE
+        (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x01   // DESCRIPTOR ID CODE
+    }), 0);
+
+    private static final ListDecoder DECODER = new ListDecoder() {
+        public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+            switch(pos) {
+            case 0: {
+                return AmqpUshort.AmqpUshortBuffer.create(AmqpUshortMarshaller.createEncoded(in));
+            }
+            case 1: {
+                return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(in));
+            }
+            case 2: {
+                return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(in));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.unmarshalType(in);
+            }
+            }
+        }
+
+        public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+            switch(pos) {
+            case 0: {
+                return AmqpUshort.AmqpUshortBuffer.create(AmqpUshortMarshaller.createEncoded(buffer));
+            }
+            case 1: {
+                return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(buffer));
+            }
+            case 2: {
+                return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.decodeType(buffer);
+            }
+            }
+        }
+    };
+
+    public static class AmqpConnectionErrorEncoded extends DescribedEncoded<IAmqpList> {
+
+        public AmqpConnectionErrorEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpConnectionErrorEncoded(AmqpConnectionError value) {
+            super(AmqpListMarshaller.encode(value));
+        }
+
+        protected final String getSymbolicId() {
+            return SYMBOLIC_ID;
+        }
+
+        protected final long getNumericId() {
+            return NUMERIC_ID;
+        }
+
+        protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+            return AmqpListMarshaller.createEncoded(encoded, DECODER);
+        }
+
+        protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+            return AmqpListMarshaller.createEncoded(in, DECODER);
+        }
+
+        protected final EncodedBuffer getDescriptor() {
+            return DESCRIPTOR;
+        }
+    }
+
+    public static final Encoded<IAmqpList> encode(AmqpConnectionError value) throws AmqpEncodingError {
+        return new AmqpConnectionErrorEncoded(value);
+    }
+
+    static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        byte fc = buffer.getEncodingFormatCode();
+        if (fc == Encoder.NULL_FORMAT_CODE) {
+            return NULL_ENCODED;
+        }
+
+        DescribedBuffer db = buffer.asDescribed();
+        AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+        if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+               descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+            throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+        }
+        return new AmqpConnectionErrorEncoded(db);
+    }
+
+    public final AmqpConnectionError.AmqpConnectionErrorBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpConnectionError.AmqpConnectionErrorBuffer.create(new AmqpConnectionErrorEncoded(encoded));
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpDetachMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpDetachMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpDetachMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpDetachMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,157 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.protocol.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.Encoded;
+import org.apache.activemq.amqp.protocol.marshaller.UnexpectedTypeException;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.*;
+import org.apache.activemq.amqp.protocol.types.AmqpBoolean;
+import org.apache.activemq.amqp.protocol.types.AmqpDetach;
+import org.apache.activemq.amqp.protocol.types.AmqpOptions;
+import org.apache.activemq.amqp.protocol.types.AmqpSessionError;
+import org.apache.activemq.amqp.protocol.types.AmqpSessionName;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpDetachMarshaller implements DescribedTypeMarshaller<AmqpDetach>{
+
+    static final AmqpDetachMarshaller SINGLETON = new AmqpDetachMarshaller();
+    private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+    public static final String SYMBOLIC_ID = "amqp:detach:list";
+    //Format code: 0x00000001:0x00000203:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 515;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294967811L)
+    //Hard coded descriptor:
+    public static final EncodedBuffer DESCRIPTOR = FormatCategory.createBuffer(new Buffer(new byte [] {
+        (byte) 0x80,                                         // ulong descriptor encoding)
+        (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,  // CATEGORY CODE
+        (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x03   // DESCRIPTOR ID CODE
+    }), 0);
+
+    private static final ListDecoder DECODER = new ListDecoder() {
+        public final AmqpType<?, ?> unmarshalType(int pos, DataInput in) throws IOException {
+            switch(pos) {
+            case 0: {
+                return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(in));
+            }
+            case 1: {
+                return AmqpSessionName.AmqpSessionNameBuffer.create(AmqpBinaryMarshaller.createEncoded(in));
+            }
+            case 2: {
+                return AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in));
+            }
+            case 3: {
+                return AmqpSessionError.AmqpSessionErrorBuffer.create(AmqpSessionErrorMarshaller.createEncoded(in));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.unmarshalType(in);
+            }
+            }
+        }
+
+        public final AmqpType<?, ?> decodeType(int pos, EncodedBuffer buffer) throws AmqpEncodingError {
+            switch(pos) {
+            case 0: {
+                return AmqpOptions.AmqpOptionsBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+            }
+            case 1: {
+                return AmqpSessionName.AmqpSessionNameBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+            }
+            case 2: {
+                return AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(buffer));
+            }
+            case 3: {
+                return AmqpSessionError.AmqpSessionErrorBuffer.create(AmqpSessionErrorMarshaller.createEncoded(buffer));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.decodeType(buffer);
+            }
+            }
+        }
+    };
+
+    public static class AmqpDetachEncoded extends DescribedEncoded<IAmqpList> {
+
+        public AmqpDetachEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpDetachEncoded(AmqpDetach value) {
+            super(AmqpListMarshaller.encode(value));
+        }
+
+        protected final String getSymbolicId() {
+            return SYMBOLIC_ID;
+        }
+
+        protected final long getNumericId() {
+            return NUMERIC_ID;
+        }
+
+        protected final Encoded<IAmqpList> decodeDescribed(EncodedBuffer encoded) throws AmqpEncodingError {
+            return AmqpListMarshaller.createEncoded(encoded, DECODER);
+        }
+
+        protected final Encoded<IAmqpList> unmarshalDescribed(DataInput in) throws IOException {
+            return AmqpListMarshaller.createEncoded(in, DECODER);
+        }
+
+        protected final EncodedBuffer getDescriptor() {
+            return DESCRIPTOR;
+        }
+    }
+
+    public static final Encoded<IAmqpList> encode(AmqpDetach value) throws AmqpEncodingError {
+        return new AmqpDetachEncoded(value);
+    }
+
+    static final Encoded<IAmqpList> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<IAmqpList> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<IAmqpList> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        byte fc = buffer.getEncodingFormatCode();
+        if (fc == Encoder.NULL_FORMAT_CODE) {
+            return NULL_ENCODED;
+        }
+
+        DescribedBuffer db = buffer.asDescribed();
+        AmqpType<?, ?> descriptor = AmqpMarshaller.SINGLETON.decodeType(db.getDescriptorBuffer());
+        if(!(descriptor instanceof AmqpUlong && ((AmqpUlong)descriptor).getValue().longValue() == NUMERIC_ID ||
+               descriptor instanceof AmqpSymbol && ((AmqpSymbol)descriptor).getValue().equals(SYMBOLIC_ID))) {
+            throw new UnexpectedTypeException("descriptor mismatch: " + descriptor);
+        }
+        return new AmqpDetachEncoded(db);
+    }
+
+    public final AmqpDetach.AmqpDetachBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpDetach.AmqpDetachBuffer.create(new AmqpDetachEncoded(encoded));
+    }
+}



Mime
View raw message