activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmacn...@apache.org
Subject svn commit: r908857 [7/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/v1_0_0/AmqpUbyteMarshaller.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/AmqpUbyteMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUbyteMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUbyteMarshaller.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.Short;
+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.AmqpUbyte;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpUbyteMarshaller {
+
+    private static final Encoder ENCODER = Encoder.SINGLETON;
+    private static final Encoded<Short> NULL_ENCODED = new Encoder.NullEncoded<Short>();
+
+    public static final byte FORMAT_CODE = (byte) 0x50;
+    public static final FormatSubCategory FORMAT_CATEGORY  = FormatSubCategory.getCategory(FORMAT_CODE);
+
+    public static class AmqpUbyteEncoded  extends AbstractEncoded<Short> {
+
+        public AmqpUbyteEncoded (EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpUbyteEncoded (Short value) throws AmqpEncodingError {
+            super(FORMAT_CODE, value);
+        }
+
+        public final void encode(Short value, Buffer encoded, int offset) throws AmqpEncodingError{
+            ENCODER.encodeUbyte(value, encoded, offset);
+        }
+
+        public final Short decode(EncodedBuffer encoded) throws AmqpEncodingError{
+            return ENCODER.decodeUbyte(encoded.getBuffer(), encoded.getDataOffset());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeUbyte(value, out);
+        }
+
+        public final Short unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readUbyte(in);
+        }
+    }
+
+    public static final Encoded<Short> encode(AmqpUbyte data) throws AmqpEncodingError {
+        if(data == null) {
+            return NULL_ENCODED;
+        }
+        return new AmqpUbyteEncoded(data.getValue());
+    }
+
+    static final Encoded<Short> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<Short> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<Short> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        if(buffer.getEncodingFormatCode() == AmqpNullMarshaller.FORMAT_CODE) {
+            return new Encoder.NullEncoded<Short>();
+        }
+        if(buffer.getEncodingFormatCode() != FORMAT_CODE) {
+            throw new AmqpEncodingError("Unexpected format for AmqpUbyte expected: " + FORMAT_CODE);
+        }
+        return new AmqpUbyteEncoded(buffer);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUintMarshaller.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/AmqpUintMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUintMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUintMarshaller.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.Long;
+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.AmqpUint;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpUintMarshaller {
+
+    private static final Encoder ENCODER = Encoder.SINGLETON;
+    private static final Encoded<Long> NULL_ENCODED = new Encoder.NullEncoded<Long>();
+
+    public static final byte FORMAT_CODE = (byte) 0x70;
+    public static final FormatSubCategory FORMAT_CATEGORY  = FormatSubCategory.getCategory(FORMAT_CODE);
+
+    public static class AmqpUintEncoded  extends AbstractEncoded<Long> {
+
+        public AmqpUintEncoded (EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpUintEncoded (Long value) throws AmqpEncodingError {
+            super(FORMAT_CODE, value);
+        }
+
+        public final void encode(Long value, Buffer encoded, int offset) throws AmqpEncodingError{
+            ENCODER.encodeUint(value, encoded, offset);
+        }
+
+        public final Long decode(EncodedBuffer encoded) throws AmqpEncodingError{
+            return ENCODER.decodeUint(encoded.getBuffer(), encoded.getDataOffset());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeUint(value, out);
+        }
+
+        public final Long unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readUint(in);
+        }
+    }
+
+    public static final Encoded<Long> encode(AmqpUint data) throws AmqpEncodingError {
+        if(data == null) {
+            return NULL_ENCODED;
+        }
+        return new AmqpUintEncoded(data.getValue());
+    }
+
+    static final Encoded<Long> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<Long> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<Long> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        if(buffer.getEncodingFormatCode() == AmqpNullMarshaller.FORMAT_CODE) {
+            return new Encoder.NullEncoded<Long>();
+        }
+        if(buffer.getEncodingFormatCode() != FORMAT_CODE) {
+            throw new AmqpEncodingError("Unexpected format for AmqpUint expected: " + FORMAT_CODE);
+        }
+        return new AmqpUintEncoded(buffer);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUlongMarshaller.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/AmqpUlongMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUlongMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUlongMarshaller.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.math.BigInteger;
+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.AmqpUlong;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpUlongMarshaller {
+
+    private static final Encoder ENCODER = Encoder.SINGLETON;
+    private static final Encoded<BigInteger> NULL_ENCODED = new Encoder.NullEncoded<BigInteger>();
+
+    public static final byte FORMAT_CODE = (byte) 0x80;
+    public static final FormatSubCategory FORMAT_CATEGORY  = FormatSubCategory.getCategory(FORMAT_CODE);
+
+    public static class AmqpUlongEncoded  extends AbstractEncoded<BigInteger> {
+
+        public AmqpUlongEncoded (EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpUlongEncoded (BigInteger value) throws AmqpEncodingError {
+            super(FORMAT_CODE, value);
+        }
+
+        public final void encode(BigInteger value, Buffer encoded, int offset) throws AmqpEncodingError{
+            ENCODER.encodeUlong(value, encoded, offset);
+        }
+
+        public final BigInteger decode(EncodedBuffer encoded) throws AmqpEncodingError{
+            return ENCODER.decodeUlong(encoded.getBuffer(), encoded.getDataOffset());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeUlong(value, out);
+        }
+
+        public final BigInteger unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readUlong(in);
+        }
+    }
+
+    public static final Encoded<BigInteger> encode(AmqpUlong data) throws AmqpEncodingError {
+        if(data == null) {
+            return NULL_ENCODED;
+        }
+        return new AmqpUlongEncoded(data.getValue());
+    }
+
+    static final Encoded<BigInteger> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<BigInteger> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<BigInteger> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        if(buffer.getEncodingFormatCode() == AmqpNullMarshaller.FORMAT_CODE) {
+            return new Encoder.NullEncoded<BigInteger>();
+        }
+        if(buffer.getEncodingFormatCode() != FORMAT_CODE) {
+            throw new AmqpEncodingError("Unexpected format for AmqpUlong expected: " + FORMAT_CODE);
+        }
+        return new AmqpUlongEncoded(buffer);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUnlinkMarshaller.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/AmqpUnlinkMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUnlinkMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUnlinkMarshaller.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.AmqpHandle;
+import org.apache.activemq.amqp.protocol.types.AmqpLinkError;
+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.AmqpUnlink;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpUnlinkMarshaller implements DescribedTypeMarshaller<AmqpUnlink>{
+
+    static final AmqpUnlinkMarshaller SINGLETON = new AmqpUnlinkMarshaller();
+    private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+    public static final String SYMBOLIC_ID = "amqp:unlink:list";
+    //Format code: 0x00000001:0x00000306:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 774;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294968070L)
+    //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) 0x03, (byte) 0x06   // 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 AmqpLinkError.AmqpLinkErrorBuffer.create(AmqpLinkErrorMarshaller.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 AmqpLinkError.AmqpLinkErrorBuffer.create(AmqpLinkErrorMarshaller.createEncoded(buffer));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.decodeType(buffer);
+            }
+            }
+        }
+    };
+
+    public static class AmqpUnlinkEncoded extends DescribedEncoded<IAmqpList> {
+
+        public AmqpUnlinkEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpUnlinkEncoded(AmqpUnlink 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(AmqpUnlink value) throws AmqpEncodingError {
+        return new AmqpUnlinkEncoded(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 AmqpUnlinkEncoded(db);
+    }
+
+    public final AmqpUnlink.AmqpUnlinkBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpUnlink.AmqpUnlinkBuffer.create(new AmqpUnlinkEncoded(encoded));
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUshortMarshaller.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/AmqpUshortMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUshortMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUshortMarshaller.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.AmqpUshort;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpUshortMarshaller {
+
+    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) 0x60;
+    public static final FormatSubCategory FORMAT_CATEGORY  = FormatSubCategory.getCategory(FORMAT_CODE);
+
+    public static class AmqpUshortEncoded  extends AbstractEncoded<Integer> {
+
+        public AmqpUshortEncoded (EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpUshortEncoded (Integer value) throws AmqpEncodingError {
+            super(FORMAT_CODE, value);
+        }
+
+        public final void encode(Integer value, Buffer encoded, int offset) throws AmqpEncodingError{
+            ENCODER.encodeUshort(value, encoded, offset);
+        }
+
+        public final Integer decode(EncodedBuffer encoded) throws AmqpEncodingError{
+            return ENCODER.decodeUshort(encoded.getBuffer(), encoded.getDataOffset());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeUshort(value, out);
+        }
+
+        public final Integer unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readUshort(in);
+        }
+    }
+
+    public static final Encoded<Integer> encode(AmqpUshort data) throws AmqpEncodingError {
+        if(data == null) {
+            return NULL_ENCODED;
+        }
+        return new AmqpUshortEncoded(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 AmqpUshort expected: " + FORMAT_CODE);
+        }
+        return new AmqpUshortEncoded(buffer);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUuidMarshaller.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/AmqpUuidMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUuidMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpUuidMarshaller.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.util.UUID;
+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.AmqpUuid;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpUuidMarshaller {
+
+    private static final Encoder ENCODER = Encoder.SINGLETON;
+    private static final Encoded<UUID> NULL_ENCODED = new Encoder.NullEncoded<UUID>();
+
+    public static final byte FORMAT_CODE = (byte) 0x98;
+    public static final FormatSubCategory FORMAT_CATEGORY  = FormatSubCategory.getCategory(FORMAT_CODE);
+
+    public static class AmqpUuidEncoded  extends AbstractEncoded<UUID> {
+
+        public AmqpUuidEncoded (EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpUuidEncoded (UUID value) throws AmqpEncodingError {
+            super(FORMAT_CODE, value);
+        }
+
+        public final void encode(UUID value, Buffer encoded, int offset) throws AmqpEncodingError{
+            ENCODER.encodeUuid(value, encoded, offset);
+        }
+
+        public final UUID decode(EncodedBuffer encoded) throws AmqpEncodingError{
+            return ENCODER.decodeUuid(encoded.getBuffer(), encoded.getDataOffset());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeUuid(value, out);
+        }
+
+        public final UUID unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readUuid(in);
+        }
+    }
+
+    public static final Encoded<UUID> encode(AmqpUuid data) throws AmqpEncodingError {
+        if(data == null) {
+            return NULL_ENCODED;
+        }
+        return new AmqpUuidEncoded(data.getValue());
+    }
+
+    static final Encoded<UUID> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<UUID> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<UUID> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        if(buffer.getEncodingFormatCode() == AmqpNullMarshaller.FORMAT_CODE) {
+            return new Encoder.NullEncoded<UUID>();
+        }
+        if(buffer.getEncodingFormatCode() != FORMAT_CODE) {
+            throw new AmqpEncodingError("Unexpected format for AmqpUuid expected: " + FORMAT_CODE);
+        }
+        return new AmqpUuidEncoded(buffer);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpXidMarshaller.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/AmqpXidMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpXidMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpXidMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,149 @@
+/**
+ * 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.AmqpBinary;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+import org.apache.activemq.amqp.protocol.types.AmqpUint;
+import org.apache.activemq.amqp.protocol.types.AmqpUlong;
+import org.apache.activemq.amqp.protocol.types.AmqpXid;
+import org.apache.activemq.amqp.protocol.types.IAmqpList;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpXidMarshaller implements DescribedTypeMarshaller<AmqpXid>{
+
+    static final AmqpXidMarshaller SINGLETON = new AmqpXidMarshaller();
+    private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+    public static final String SYMBOLIC_ID = "amqp:xid:list";
+    //Format code: 0x00000001:0x00000104:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 260;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294967556L)
+    //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) 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 AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.createEncoded(in));
+            }
+            case 1: {
+                return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(in));
+            }
+            case 2: {
+                return AmqpBinary.AmqpBinaryBuffer.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 AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.createEncoded(buffer));
+            }
+            case 1: {
+                return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+            }
+            case 2: {
+                return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.decodeType(buffer);
+            }
+            }
+        }
+    };
+
+    public static class AmqpXidEncoded extends DescribedEncoded<IAmqpList> {
+
+        public AmqpXidEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpXidEncoded(AmqpXid 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(AmqpXid value) throws AmqpEncodingError {
+        return new AmqpXidEncoded(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 AmqpXidEncoded(db);
+    }
+
+    public final AmqpXid.AmqpXidBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpXid.AmqpXidBuffer.create(new AmqpXidEncoded(encoded));
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/BaseEncoder.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/BaseEncoder.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/BaseEncoder.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/BaseEncoder.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,540 @@
+/**
+ * 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.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.util.Date;
+import java.util.UUID;
+
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.AmqpStringMarshaller.STRING_ENCODING;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.AmqpSymbolMarshaller.SYMBOL_ENCODING;
+import org.apache.activemq.amqp.protocol.BitUtils;
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.util.buffer.Buffer;
+
+class BaseEncoder implements PrimitiveEncoder {
+    public final Buffer decodeBinary(Buffer encoded, int offset, int length) throws AmqpEncodingError {
+        return new Buffer(encoded.data, encoded.offset + offset, length);
+    }
+
+    public final Buffer decodeBinaryVbin32(Buffer encoded, int offset, int length) throws AmqpEncodingError {
+        return decodeBinary(encoded, encoded.offset + offset, length);
+    }
+
+    public final Buffer decodeBinaryVbin8(Buffer encoded, int offset, int length) throws AmqpEncodingError {
+        return decodeBinary(encoded, encoded.offset + offset, length);
+    }
+
+    public final Byte decodeByte(Buffer encoded, int offset) throws AmqpEncodingError {
+        return encoded.get(encoded.offset + offset);
+    }
+
+    public final Integer decodeChar(Buffer encoded, int offset) throws AmqpEncodingError {
+        return BitUtils.getInt(encoded.data, encoded.offset + offset);
+    }
+
+    public final Double decodeDouble(Buffer encoded, int offset) throws AmqpEncodingError {
+        return Double.longBitsToDouble(decodeLong(encoded, encoded.offset + offset));
+    }
+
+    public final Float decodeFloat(Buffer encoded, int offset) throws AmqpEncodingError {
+        return Float.intBitsToFloat(decodeInt(encoded, encoded.offset + offset));
+    }
+
+    public final Integer decodeInt(Buffer encoded, int offset) throws AmqpEncodingError {
+        return BitUtils.getInt(encoded.data, encoded.offset + offset);
+    }
+
+    public final Long decodeLong(Buffer encoded, int offset) throws AmqpEncodingError {
+        return BitUtils.getLong(encoded.data, encoded.offset + offset);
+    }
+
+    public final Short decodeShort(Buffer encoded, int offset) throws AmqpEncodingError {
+        return BitUtils.getShort(encoded.data, encoded.offset + offset);
+    }
+
+    public final String decodeString(Buffer encoded, int offset, int length, String charset) throws AmqpEncodingError {
+        try {
+            return new String(encoded.data, encoded.offset + offset, length, charset);
+        } catch (UnsupportedEncodingException e) {
+            throw new AmqpEncodingError(e.getMessage(), e);
+        }
+    }
+
+    public final String decodeStringStr32Utf16(Buffer encoded, int offset, int length) throws AmqpEncodingError {
+        return decodeString(encoded, encoded.offset + offset, length, "utf-16");
+    }
+
+    public final String decodeStringStr32Utf8(Buffer encoded, int offset, int length) throws AmqpEncodingError {
+        return decodeString(encoded, encoded.offset + offset, length, "utf-8");
+    }
+
+    public final String decodeStringStr8Utf16(Buffer encoded, int offset, int length) throws AmqpEncodingError {
+        return decodeString(encoded, encoded.offset + offset, length, "utf-16");
+    }
+
+    public final String decodeStringStr8Utf8(Buffer encoded, int offset, int length) throws AmqpEncodingError {
+        return decodeString(encoded, encoded.offset + offset, length, "utf-8");
+    }
+
+    public final String decodeSymbolSym32(Buffer encoded, int offset, int length) throws AmqpEncodingError {
+        return decodeString(encoded, encoded.offset + offset, length, "us-ascii");
+    }
+
+    public final String decodeSymbolSym8(Buffer encoded, int offset, int length) throws AmqpEncodingError {
+        return decodeString(encoded, encoded.offset + offset, length, "us-ascii");
+    }
+
+    public final Date decodeTimestamp(Buffer encoded, int offset) throws AmqpEncodingError {
+        return new Date(decodeInt(encoded, encoded.offset + offset));
+    }
+
+    public final Short decodeUbyte(Buffer encoded, int offset) throws AmqpEncodingError {
+        return BitUtils.getUByte(encoded.data, encoded.offset + offset);
+    }
+
+    public Long decodeUint(Buffer encoded, int offset) throws AmqpEncodingError {
+        return BitUtils.getUInt(encoded.data, encoded.offset + offset);
+    }
+
+    public BigInteger decodeUlong(Buffer encoded, int offset) throws AmqpEncodingError {
+        return BitUtils.getULong(encoded.data, encoded.offset + offset);
+    }
+
+    public Integer decodeUshort(Buffer encoded, int offset) throws AmqpEncodingError {
+        return BitUtils.getUShort(encoded.data, encoded.offset + offset);
+    }
+
+    public UUID decodeUuid(Buffer encoded, int offset) throws AmqpEncodingError {
+        return new UUID(decodeLong(encoded, offset), decodeLong(encoded, offset + 8));
+    }
+
+    public void encodeBinaryVbin32(Buffer val, Buffer buf, int offset) throws AmqpEncodingError {
+        System.arraycopy(val, val.offset, buf.data, buf.offset + offset, val.length);
+
+    }
+
+    public void encodeBinaryVbin8(Buffer val, Buffer buf, int offset) throws AmqpEncodingError {
+        System.arraycopy(val, val.offset, buf.data, buf.offset + offset, val.length);
+    }
+
+    public void encodeByte(Byte val, Buffer buf, int offset) throws AmqpEncodingError {
+        buf.data[buf.offset + offset] = val;
+
+    }
+
+    public void encodeChar(Integer val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setUInt(buf.data, buf.offset + offset, val);
+
+    }
+
+    public void encodeDouble(Double val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setLong(buf.data, buf.offset + offset, Double.doubleToLongBits(val));
+
+    }
+
+    public void encodeFloat(Float val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setInt(buf.data, buf.offset + offset, Float.floatToIntBits(val));
+
+    }
+
+    public void encodeInt(Integer val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setInt(buf.data, buf.offset + offset, val);
+    }
+
+    public void encodeLong(Long val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setLong(buf.data, buf.offset + offset, val);
+    }
+
+    public void encodeShort(Short val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setShort(buf.data, buf.offset + offset, val);
+    }
+
+    public void encodeStringStr32Utf16(String val, Buffer buf, int offset) throws AmqpEncodingError {
+        byte[] s;
+        try {
+            s = val.getBytes("utf-16");
+        } catch (UnsupportedEncodingException e) {
+            throw new AmqpEncodingError(e.getMessage(), e);
+        }
+        System.arraycopy(s, 0, buf.data, buf.offset + offset, s.length);
+
+    }
+
+    public void encodeStringStr32Utf8(String val, Buffer buf, int offset) throws AmqpEncodingError {
+        byte[] s;
+        try {
+            s = val.getBytes("utf-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new AmqpEncodingError(e.getMessage(), e);
+        }
+        System.arraycopy(s, 0, buf.data, buf.offset + offset, s.length);
+    }
+
+    public void encodeStringStr8Utf16(String val, Buffer buf, int offset) throws AmqpEncodingError {
+        byte[] s;
+        try {
+            s = val.getBytes("utf-16");
+        } catch (UnsupportedEncodingException e) {
+            throw new AmqpEncodingError(e.getMessage(), e);
+        }
+        System.arraycopy(s, 0, buf.data, buf.offset + offset, s.length);
+
+    }
+
+    public void encodeStringStr8Utf8(String val, Buffer buf, int offset) throws AmqpEncodingError {
+        byte[] s;
+        try {
+            s = val.getBytes("utf-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new AmqpEncodingError(e.getMessage(), e);
+        }
+        System.arraycopy(s, 0, buf.data, buf.offset + offset, s.length);
+
+    }
+
+    public void encodeSymbolSym32(String val, Buffer buf, int offset) throws AmqpEncodingError {
+        byte[] s;
+        try {
+            s = val.getBytes("us-ascii");
+        } catch (UnsupportedEncodingException e) {
+            throw new AmqpEncodingError(e.getMessage(), e);
+        }
+        System.arraycopy(s, 0, buf.data, buf.offset + offset, s.length);
+
+    }
+
+    public void encodeSymbolSym8(String val, Buffer buf, int offset) throws AmqpEncodingError {
+        byte[] s;
+        try {
+            s = val.getBytes("us-ascii");
+        } catch (UnsupportedEncodingException e) {
+            throw new AmqpEncodingError(e.getMessage(), e);
+        }
+        System.arraycopy(s, 0, buf.data, buf.offset + offset, s.length);
+    }
+
+    public void encodeTimestamp(Date val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setLong(buf.data, buf.offset + offset, val.getTime());
+    }
+
+    public void encodeUbyte(Short val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setUByte(buf.data, buf.offset + offset, val);
+    }
+
+    public void encodeUint(Long val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setUInt(buf.data, buf.offset + offset, val);
+    }
+
+    public void encodeUlong(BigInteger val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setULong(buf.data, buf.offset + offset, val);
+    }
+
+    public void encodeUshort(Integer val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setUShort(buf.data, buf.offset + offset, val);
+    }
+
+    public void encodeUuid(UUID val, Buffer buf, int offset) throws AmqpEncodingError {
+        BitUtils.setLong(buf.data, buf.offset + offset, val.getMostSignificantBits());
+        BitUtils.setLong(buf.data, buf.offset + offset + 8, val.getLeastSignificantBits());
+    }
+
+    public final int getEncodedSizeOfString(String val, STRING_ENCODING encoding) throws AmqpEncodingError {
+        try {
+            switch (encoding) {
+            case STR32_UTF16:
+            case STR8_UTF16: {
+                return val.getBytes("utf-16").length;
+            }
+            case STR32_UTF8:
+            case STR8_UTF8: {
+                return val.getBytes("utf-8").length;
+            }
+            default:
+                throw new UnsupportedEncodingException(encoding.name());
+            }
+        } catch (UnsupportedEncodingException uee) {
+            throw new AmqpEncodingError(uee.getMessage(), uee);
+        }
+    }
+
+    public final int getEncodedSizeOfSymbol(String val, SYMBOL_ENCODING encoding) {
+        return val.length();
+    }
+
+    public final byte[] readBinary(AmqpBinaryMarshaller.BINARY_ENCODING encoding, int length, int count, DataInput dis) throws IOException {
+        byte[] rc = new byte[(int) length];
+        dis.readFully(rc);
+        return rc;
+    }
+
+    public Buffer readBinaryVbin32(int size, DataInput dis) throws IOException, AmqpEncodingError {
+        return readBinaryVbin32(size, dis);
+    }
+
+    public Buffer readBinaryVbin8(int size, DataInput dis) throws IOException, AmqpEncodingError {
+        return readBinaryVbin32(size, dis);
+    }
+
+    public final Byte readByte(DataInput dis) throws IOException {
+        return (byte) dis.readByte();
+    }
+
+    public final Integer readChar(DataInput dis) throws IOException {
+        return dis.readInt();
+    }
+
+    public final Double readDouble(DataInput dis) throws IOException {
+        return dis.readDouble();
+    }
+
+    public final Float readFloat(DataInput dis) throws IOException {
+        return dis.readFloat();
+    }
+
+    public final Integer readInt(DataInput dis) throws IOException {
+        return dis.readInt();
+    }
+
+    public final Long readLong(DataInput dis) throws IOException {
+        return dis.readLong();
+    }
+
+    public final Short readShort(DataInput dis) throws IOException {
+        return dis.readShort();
+    }
+
+    public final String readString(AmqpStringMarshaller.STRING_ENCODING encoding, int size, int count, DataInput dis) throws IOException {
+        byte[] str = new byte[size];
+        dis.readFully(str);
+        switch (encoding) {
+        case STR32_UTF16:
+        case STR8_UTF16:
+            return new String(str, "utf-16");
+        case STR32_UTF8:
+        case STR8_UTF8:
+            return new String(str, "utf-8");
+        default:
+            throw new UnsupportedEncodingException(encoding.name());
+        }
+    }
+
+    public String readStringStr32Utf16(int size, DataInput dis) throws IOException, AmqpEncodingError {
+        byte[] str = new byte[size];
+        dis.readFully(str);
+        return new String(str, "utf-16");
+    }
+
+    public String readStringStr32Utf8(int size, DataInput dis) throws IOException, AmqpEncodingError {
+        byte[] str = new byte[size];
+        dis.readFully(str);
+        return new String(str, "utf-8");
+    }
+
+    public String readStringStr8Utf16(int size, DataInput dis) throws IOException, AmqpEncodingError {
+        byte[] str = new byte[size];
+        dis.readFully(str);
+        return new String(str, "utf-16");
+    }
+
+    public String readStringStr8Utf8(int size, DataInput dis) throws IOException, AmqpEncodingError {
+        byte[] str = new byte[size];
+        dis.readFully(str);
+        return new String(str, "utf-8");
+    }
+
+    public final String readSymbol(AmqpSymbolMarshaller.SYMBOL_ENCODING encoding, int size, int count, DataInput dis) throws IOException {
+        byte[] str = new byte[size];
+        dis.readFully(str);
+        return new String(str, "us-ascii");
+    }
+
+    public String readSymbolSym32(int size, DataInput dis) throws IOException, AmqpEncodingError {
+        byte[] str = new byte[size];
+        dis.readFully(str);
+        return new String(str, "us-ascii");
+    }
+
+    public String readSymbolSym8(int size, DataInput dis) throws IOException, AmqpEncodingError {
+        byte[] str = new byte[size];
+        dis.readFully(str);
+        return new String(str, "us-ascii");
+    }
+
+    public final Date readTimestamp(DataInput dis) throws IOException {
+        return new Date(dis.readLong());
+    }
+
+    public final Short readUbyte(DataInput dis) throws IOException {
+        return (short) (0xFF & (short) dis.readByte());
+    }
+
+    public final Long readUint(DataInput dis) throws IOException {
+        long rc = 0;
+        rc = rc | (0xFFFFFFFFL & (((long) dis.readByte()) << 24));
+        rc = rc | (0xFFFFFFFFL & (((long) dis.readByte()) << 16));
+        rc = rc | (0xFFFFFFFFL & (((long) dis.readByte()) << 8));
+        rc = rc | (0xFFFFFFFFL & (long) dis.readByte());
+
+        return rc;
+    }
+
+    public final BigInteger readUlong(DataInput dis) throws IOException {
+        byte[] rc = new byte[9];
+        rc[0] = 0;
+        dis.readFully(rc, 1, 8);
+        return new BigInteger(rc);
+    }
+
+    public final Integer readUshort(DataInput dis) throws IOException {
+        int rc = 0;
+        rc = rc | ((int) 0xFFFF & (((int) dis.readByte()) << 8));
+        rc = rc | ((int) 0xFFFF & (int) dis.readByte());
+
+        return rc;
+    }
+
+    public final UUID readUuid(DataInput dis) throws IOException {
+        return new UUID(dis.readLong(), dis.readLong());
+    }
+
+    public final void writeBinary(byte[] val, AmqpBinaryMarshaller.BINARY_ENCODING encoding, DataOutput dos) throws IOException {
+        dos.write(val);
+    }
+
+    public void writeBinaryVbin32(Buffer val, DataOutput out) throws IOException, AmqpEncodingError {
+        out.write(val.data, val.offset, val.length);
+    }
+
+    public void writeBinaryVbin8(Buffer val, DataOutput out) throws IOException, AmqpEncodingError {
+        out.write(val.data, val.offset, val.length);
+
+    }
+
+    public final void writeByte(Byte val, DataOutput dos) throws IOException {
+        dos.writeByte(val);
+    }
+
+    public final void writeChar(Integer val, DataOutput dos) throws IOException {
+        dos.writeInt(val);
+
+    }
+
+    public final void writeDouble(Double val, DataOutput dos) throws IOException {
+        dos.writeLong(Double.doubleToLongBits(val));
+    }
+
+    public final void writeFloat(Float val, DataOutput dos) throws IOException {
+        dos.writeInt(Float.floatToIntBits(val));
+    }
+
+    public final void writeInt(Integer val, DataOutput dos) throws IOException {
+        dos.writeInt(val);
+    }
+
+    public final void writeLong(Long val, DataOutput dos) throws IOException {
+        dos.writeLong(val);
+    }
+
+    public final void writeShort(Short val, DataOutput dos) throws IOException {
+        dos.writeShort(val);
+    }
+
+    public final void writeString(String val, AmqpStringMarshaller.STRING_ENCODING encoding, DataOutput dos) throws IOException {
+        switch (encoding) {
+        case STR32_UTF16:
+        case STR8_UTF16: {
+            dos.write(val.getBytes("utf-16"));
+        }
+        case STR32_UTF8:
+        case STR8_UTF8: {
+            dos.write(val.getBytes("utf-8"));
+        }
+        default:
+            throw new UnsupportedEncodingException(encoding.name());
+        }
+
+    }
+
+    public void writeStringStr32Utf16(String val, DataOutput out) throws IOException, AmqpEncodingError {
+        out.write(val.getBytes("utf-16"));
+
+    }
+
+    public void writeStringStr32Utf8(String val, DataOutput out) throws IOException, AmqpEncodingError {
+        out.write(val.getBytes("utf-8"));
+
+    }
+
+    public void writeStringStr8Utf16(String val, DataOutput out) throws IOException, AmqpEncodingError {
+        out.write(val.getBytes("utf-16"));
+
+    }
+
+    public void writeStringStr8Utf8(String val, DataOutput out) throws IOException, AmqpEncodingError {
+        out.write(val.getBytes("utf-8"));
+    }
+
+    public final void writeSymbol(String val, SYMBOL_ENCODING encoding, DataOutput dos) throws IOException {
+        dos.write(val.getBytes("us-ascii"));
+    }
+
+    public void writeSymbolSym32(String val, DataOutput out) throws IOException, AmqpEncodingError {
+        out.write(val.getBytes("us-ascii"));
+    }
+
+    public void writeSymbolSym8(String val, DataOutput out) throws IOException, AmqpEncodingError {
+        out.write(val.getBytes("us-ascii"));
+    }
+
+    public final void writeTimestamp(Date val, DataOutput dos) throws IOException {
+        dos.writeLong(val.getTime());
+    }
+
+    public final void writeUbyte(Short val, DataOutput dos) throws IOException {
+        dos.write(val);
+    }
+
+    public final void writeUint(Long val, DataOutput dos) throws IOException {
+        dos.writeInt((int) val.longValue());
+    }
+
+    public final void writeUlong(BigInteger val, DataOutput dos) throws IOException {
+        byte[] b = val.toByteArray();
+        if (b.length > 8) {
+            for (int i = 0; i < b.length - 8; i++) {
+                if (b[i] > 0) {
+                    throw new UnsupportedEncodingException("Unsigned long too large");
+                }
+            }
+        }
+        dos.write(b, b.length - 8, 8);
+    }
+
+    public final void writeUshort(Integer val, DataOutput dos) throws IOException {
+        dos.writeShort((short) val.intValue());
+    }
+
+    public final void writeUuid(UUID val, DataOutput dos) throws IOException {
+        dos.writeLong(val.getMostSignificantBits());
+        dos.writeLong(val.getLeastSignificantBits());
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/DescribedTypeMarshaller.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/DescribedTypeMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/DescribedTypeMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/DescribedTypeMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,28 @@
+/**
+ * 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 org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.amqp.protocol.marshaller.v1_0_0.Encoder.DescribedBuffer;
+
+
+import org.apache.activemq.amqp.protocol.types.AmqpType;
+
+public interface DescribedTypeMarshaller<D extends AmqpType<?, ?>> {
+    
+    public D decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer buffer) throws AmqpEncodingError;
+}



Mime
View raw message