activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmacn...@apache.org
Subject svn commit: r908857 [6/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/AmqpSaslResponseMarshaller.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/AmqpSaslResponseMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslResponseMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSaslResponseMarshaller.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.AmqpBinary;
+import org.apache.activemq.amqp.protocol.types.AmqpMap;
+import org.apache.activemq.amqp.protocol.types.AmqpSaslResponse;
+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 AmqpSaslResponseMarshaller implements DescribedTypeMarshaller<AmqpSaslResponse>{
+
+    static final AmqpSaslResponseMarshaller SINGLETON = new AmqpSaslResponseMarshaller();
+    private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+    public static final String SYMBOLIC_ID = "amqp:sasl-response:list";
+    //Format code: 0x00000001:0x00000704:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 1796;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294969092L)
+    //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) 0x07, (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 AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(in));
+            }
+            case 1: {
+                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 AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+            }
+            case 1: {
+                return AmqpBinary.AmqpBinaryBuffer.create(AmqpBinaryMarshaller.createEncoded(buffer));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.decodeType(buffer);
+            }
+            }
+        }
+    };
+
+    public static class AmqpSaslResponseEncoded extends DescribedEncoded<IAmqpList> {
+
+        public AmqpSaslResponseEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpSaslResponseEncoded(AmqpSaslResponse 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(AmqpSaslResponse value) throws AmqpEncodingError {
+        return new AmqpSaslResponseEncoded(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 AmqpSaslResponseEncoded(db);
+    }
+
+    public final AmqpSaslResponse.AmqpSaslResponseBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpSaslResponse.AmqpSaslResponseBuffer.create(new AmqpSaslResponseEncoded(encoded));
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSessionErrorMarshaller.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/AmqpSessionErrorMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSessionErrorMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSessionErrorMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,170 @@
+/**
+ * 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.AmqpMap;
+import org.apache.activemq.amqp.protocol.types.AmqpSequenceNo;
+import org.apache.activemq.amqp.protocol.types.AmqpSessionError;
+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.AmqpUbyte;
+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 AmqpSessionErrorMarshaller implements DescribedTypeMarshaller<AmqpSessionError>{
+
+    static final AmqpSessionErrorMarshaller SINGLETON = new AmqpSessionErrorMarshaller();
+    private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+    public static final String SYMBOLIC_ID = "amqp:session-error:list";
+    //Format code: 0x00000001:0x00000102:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 258;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294967554L)
+    //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) 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 AmqpUshort.AmqpUshortBuffer.create(AmqpUshortMarshaller.createEncoded(in));
+            }
+            case 1: {
+                return AmqpSequenceNo.AmqpSequenceNoBuffer.create(AmqpUintMarshaller.createEncoded(in));
+            }
+            case 2: {
+                return AmqpUbyte.AmqpUbyteBuffer.create(AmqpUbyteMarshaller.createEncoded(in));
+            }
+            case 3: {
+                return AmqpUbyte.AmqpUbyteBuffer.create(AmqpUbyteMarshaller.createEncoded(in));
+            }
+            case 4: {
+                return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(in));
+            }
+            case 5: {
+                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 AmqpSequenceNo.AmqpSequenceNoBuffer.create(AmqpUintMarshaller.createEncoded(buffer));
+            }
+            case 2: {
+                return AmqpUbyte.AmqpUbyteBuffer.create(AmqpUbyteMarshaller.createEncoded(buffer));
+            }
+            case 3: {
+                return AmqpUbyte.AmqpUbyteBuffer.create(AmqpUbyteMarshaller.createEncoded(buffer));
+            }
+            case 4: {
+                return AmqpString.AmqpStringBuffer.create(AmqpStringMarshaller.createEncoded(buffer));
+            }
+            case 5: {
+                return AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(buffer));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.decodeType(buffer);
+            }
+            }
+        }
+    };
+
+    public static class AmqpSessionErrorEncoded extends DescribedEncoded<IAmqpList> {
+
+        public AmqpSessionErrorEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpSessionErrorEncoded(AmqpSessionError 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(AmqpSessionError value) throws AmqpEncodingError {
+        return new AmqpSessionErrorEncoded(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 AmqpSessionErrorEncoded(db);
+    }
+
+    public final AmqpSessionError.AmqpSessionErrorBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpSessionError.AmqpSessionErrorBuffer.create(new AmqpSessionErrorEncoded(encoded));
+    }
+}

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

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSourceMarshaller.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/AmqpSourceMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSourceMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSourceMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,193 @@
+/**
+ * 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.AmqpAddress;
+import org.apache.activemq.amqp.protocol.types.AmqpBoolean;
+import org.apache.activemq.amqp.protocol.types.AmqpFilterSet;
+import org.apache.activemq.amqp.protocol.types.AmqpList;
+import org.apache.activemq.amqp.protocol.types.AmqpMap;
+import org.apache.activemq.amqp.protocol.types.AmqpSource;
+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.util.buffer.Buffer;
+
+public class AmqpSourceMarshaller implements DescribedTypeMarshaller<AmqpSource>{
+
+    static final AmqpSourceMarshaller SINGLETON = new AmqpSourceMarshaller();
+    private static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> NULL_ENCODED = new Encoder.NullEncoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>>();
+
+    public static final String SYMBOLIC_ID = "amqp:source:map";
+    //Format code: 0x00000001:0x00009701:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 38657;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4295005953L)
+    //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) 0x97, (byte) 0x01   // DESCRIPTOR ID CODE
+    }), 0);
+
+    //Accessor keys for field mapped fields:
+    private static final AmqpSymbol.AmqpSymbolBuffer ADDRESS_KEY = new AmqpSymbol.AmqpSymbolBean("address").getBuffer(AmqpMarshaller.SINGLETON);
+    private static final AmqpSymbol.AmqpSymbolBuffer CREATE_KEY = new AmqpSymbol.AmqpSymbolBean("create").getBuffer(AmqpMarshaller.SINGLETON);
+    private static final AmqpSymbol.AmqpSymbolBuffer TIMEOUT_KEY = new AmqpSymbol.AmqpSymbolBean("timeout").getBuffer(AmqpMarshaller.SINGLETON);
+    private static final AmqpSymbol.AmqpSymbolBuffer DISTRIBUTION_MODE_KEY = new AmqpSymbol.AmqpSymbolBean("distribution-mode").getBuffer(AmqpMarshaller.SINGLETON);
+    private static final AmqpSymbol.AmqpSymbolBuffer FILTER_KEY = new AmqpSymbol.AmqpSymbolBean("filter").getBuffer(AmqpMarshaller.SINGLETON);
+    private static final AmqpSymbol.AmqpSymbolBuffer MESSAGE_STATES_KEY = new AmqpSymbol.AmqpSymbolBean("message-states").getBuffer(AmqpMarshaller.SINGLETON);
+    private static final AmqpSymbol.AmqpSymbolBuffer ORPHAN_DISPOSITION_KEY = new AmqpSymbol.AmqpSymbolBean("orphan-disposition").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(ADDRESS_KEY.getValue())){
+                map.put(ADDRESS_KEY, AmqpAddress.AmqpAddressBuffer.create(AmqpBinaryMarshaller.createEncoded(encodedValue)));
+            }
+            if (key.getValue().equals(CREATE_KEY.getValue())){
+                map.put(CREATE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(encodedValue)));
+            }
+            if (key.getValue().equals(TIMEOUT_KEY.getValue())){
+                map.put(TIMEOUT_KEY, AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.createEncoded(encodedValue)));
+            }
+            if (key.getValue().equals(DISTRIBUTION_MODE_KEY.getValue())){
+                map.put(DISTRIBUTION_MODE_KEY, AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.createEncoded(encodedValue)));
+            }
+            if (key.getValue().equals(FILTER_KEY.getValue())){
+                map.put(FILTER_KEY, AmqpFilterSet.AmqpFilterSetBuffer.create(AmqpMapMarshaller.createEncoded(encodedValue)));
+            }
+            if (key.getValue().equals(MESSAGE_STATES_KEY.getValue())){
+                map.put(MESSAGE_STATES_KEY, AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(encodedValue)));
+            }
+            if (key.getValue().equals(ORPHAN_DISPOSITION_KEY.getValue())){
+                map.put(ORPHAN_DISPOSITION_KEY, AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.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(ADDRESS_KEY.getValue())){
+                map.put(ADDRESS_KEY, AmqpAddress.AmqpAddressBuffer.create(AmqpBinaryMarshaller.createEncoded(in)));
+            }
+            if (key.getValue().equals(CREATE_KEY.getValue())){
+                map.put(CREATE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in)));
+            }
+            if (key.getValue().equals(TIMEOUT_KEY.getValue())){
+                map.put(TIMEOUT_KEY, AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.createEncoded(in)));
+            }
+            if (key.getValue().equals(DISTRIBUTION_MODE_KEY.getValue())){
+                map.put(DISTRIBUTION_MODE_KEY, AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.createEncoded(in)));
+            }
+            if (key.getValue().equals(FILTER_KEY.getValue())){
+                map.put(FILTER_KEY, AmqpFilterSet.AmqpFilterSetBuffer.create(AmqpMapMarshaller.createEncoded(in)));
+            }
+            if (key.getValue().equals(MESSAGE_STATES_KEY.getValue())){
+                map.put(MESSAGE_STATES_KEY, AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(in)));
+            }
+            if (key.getValue().equals(ORPHAN_DISPOSITION_KEY.getValue())){
+                map.put(ORPHAN_DISPOSITION_KEY, AmqpMap.AmqpMapBuffer.create(AmqpMapMarshaller.createEncoded(in)));
+            }
+            else {
+                throw new UnexpectedTypeException("Invalid Key for " + SYMBOLIC_ID + " : " + key);
+            }
+        }
+    };
+
+    public static class AmqpSourceEncoded extends DescribedEncoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> {
+
+        public AmqpSourceEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpSourceEncoded(AmqpSource 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(AmqpSource value) throws AmqpEncodingError {
+        return new AmqpSourceEncoded(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 AmqpSourceEncoded(db);
+    }
+
+    public final AmqpSource.AmqpSourceBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpSource.AmqpSourceBuffer.create(new AmqpSourceEncoded(encoded));
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpStringMarshaller.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/AmqpStringMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpStringMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpStringMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,308 @@
+/**
+ * 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.String;
+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.AmqpString;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpStringMarshaller {
+
+    private static final Encoder ENCODER = Encoder.SINGLETON;
+    private static final Encoded<String> NULL_ENCODED = new Encoder.NullEncoded<String>();
+
+    public static final byte STR8_UTF8_FORMAT_CODE = (byte) 0xa1;
+    public static final byte STR8_UTF16_FORMAT_CODE = (byte) 0xa2;
+    public static final byte STR32_UTF8_FORMAT_CODE = (byte) 0xb1;
+    public static final byte STR32_UTF16_FORMAT_CODE = (byte) 0xb2;
+
+    public static enum STRING_ENCODING implements Encoding{
+        STR8_UTF8 (STR8_UTF8_FORMAT_CODE), // up to 2^8 - 1 octets worth of UTF-8 unicode
+        STR8_UTF16 (STR8_UTF16_FORMAT_CODE), // up to 2^8 - 1 octets worth of UTF-16 unicode
+        STR32_UTF8 (STR32_UTF8_FORMAT_CODE), // up to 2^32 - 1 octets worth of UTF-8 unicode
+        STR32_UTF16 (STR32_UTF16_FORMAT_CODE); // up to 2^32 - 1 octets worth of UTF-16 unicode
+
+        public final byte FORMAT_CODE;
+        public final FormatSubCategory CATEGORY;
+
+        STRING_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 STRING_ENCODING getEncoding(byte formatCode) throws UnexpectedTypeException {
+            switch(formatCode) {
+            case STR8_UTF8_FORMAT_CODE: {
+                return STR8_UTF8;
+            }
+            case STR8_UTF16_FORMAT_CODE: {
+                return STR8_UTF16;
+            }
+            case STR32_UTF8_FORMAT_CODE: {
+                return STR32_UTF8;
+            }
+            case STR32_UTF16_FORMAT_CODE: {
+                return STR32_UTF16;
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for String: " + formatCode);
+            }
+            }
+        }
+
+        static final AmqpStringEncoded createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+            switch(buffer.getEncodingFormatCode()) {
+            case STR8_UTF8_FORMAT_CODE: {
+                return new AmqpStringStr8Utf8Encoded(buffer);
+            }
+            case STR8_UTF16_FORMAT_CODE: {
+                return new AmqpStringStr8Utf16Encoded(buffer);
+            }
+            case STR32_UTF8_FORMAT_CODE: {
+                return new AmqpStringStr32Utf8Encoded(buffer);
+            }
+            case STR32_UTF16_FORMAT_CODE: {
+                return new AmqpStringStr32Utf16Encoded(buffer);
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for String: " + buffer.getEncodingFormatCode());
+            }
+            }
+        }
+        static final AmqpStringEncoded createEncoded(byte formatCode, String value) throws AmqpEncodingError {
+            switch(formatCode) {
+            case STR8_UTF8_FORMAT_CODE: {
+                return new AmqpStringStr8Utf8Encoded(value);
+            }
+            case STR8_UTF16_FORMAT_CODE: {
+                return new AmqpStringStr8Utf16Encoded(value);
+            }
+            case STR32_UTF8_FORMAT_CODE: {
+                return new AmqpStringStr32Utf8Encoded(value);
+            }
+            case STR32_UTF16_FORMAT_CODE: {
+                return new AmqpStringStr32Utf16Encoded(value);
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for String: " + formatCode);
+            }
+            }
+        }
+    }
+    public static abstract class AmqpStringEncoded extends AbstractEncoded <String> {
+        public AmqpStringEncoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpStringEncoded(byte formatCode, String value) throws AmqpEncodingError {
+            super(formatCode, value);
+        }
+    }
+
+    /**
+     * up to 2^8 - 1 octets worth of UTF-8 unicode
+     */
+    private static class AmqpStringStr8Utf8Encoded extends AmqpStringEncoded {
+
+        private final STRING_ENCODING encoding = STRING_ENCODING.STR8_UTF8;
+        public AmqpStringStr8Utf8Encoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpStringStr8Utf8Encoded(String value) throws AmqpEncodingError {
+            super(STRING_ENCODING.STR8_UTF8.FORMAT_CODE, value);
+        }
+
+        protected final int computeDataSize() throws AmqpEncodingError {
+            return ENCODER.getEncodedSizeOfString(value, encoding);
+        }
+
+        public final void encode(String value, Buffer encoded, int offset) throws AmqpEncodingError {
+            ENCODER.encodeStringStr8Utf8(value, encoded, offset);
+        }
+
+        public final String decode(EncodedBuffer encoded) throws AmqpEncodingError {
+            return ENCODER.decodeStringStr8Utf8(encoded.getBuffer(), encoded.getDataOffset(), encoded.getDataSize());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeStringStr8Utf8(value, out);
+        }
+
+        public final String unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readStringStr8Utf8(getDataSize(), in);
+        }
+    }
+
+    /**
+     * up to 2^8 - 1 octets worth of UTF-16 unicode
+     */
+    private static class AmqpStringStr8Utf16Encoded extends AmqpStringEncoded {
+
+        private final STRING_ENCODING encoding = STRING_ENCODING.STR8_UTF16;
+        public AmqpStringStr8Utf16Encoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpStringStr8Utf16Encoded(String value) throws AmqpEncodingError {
+            super(STRING_ENCODING.STR8_UTF16.FORMAT_CODE, value);
+        }
+
+        protected final int computeDataSize() throws AmqpEncodingError {
+            return ENCODER.getEncodedSizeOfString(value, encoding);
+        }
+
+        public final void encode(String value, Buffer encoded, int offset) throws AmqpEncodingError {
+            ENCODER.encodeStringStr8Utf16(value, encoded, offset);
+        }
+
+        public final String decode(EncodedBuffer encoded) throws AmqpEncodingError {
+            return ENCODER.decodeStringStr8Utf16(encoded.getBuffer(), encoded.getDataOffset(), encoded.getDataSize());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeStringStr8Utf16(value, out);
+        }
+
+        public final String unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readStringStr8Utf16(getDataSize(), in);
+        }
+    }
+
+    /**
+     * up to 2^32 - 1 octets worth of UTF-8 unicode
+     */
+    private static class AmqpStringStr32Utf8Encoded extends AmqpStringEncoded {
+
+        private final STRING_ENCODING encoding = STRING_ENCODING.STR32_UTF8;
+        public AmqpStringStr32Utf8Encoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpStringStr32Utf8Encoded(String value) throws AmqpEncodingError {
+            super(STRING_ENCODING.STR32_UTF8.FORMAT_CODE, value);
+        }
+
+        protected final int computeDataSize() throws AmqpEncodingError {
+            return ENCODER.getEncodedSizeOfString(value, encoding);
+        }
+
+        public final void encode(String value, Buffer encoded, int offset) throws AmqpEncodingError {
+            ENCODER.encodeStringStr32Utf8(value, encoded, offset);
+        }
+
+        public final String decode(EncodedBuffer encoded) throws AmqpEncodingError {
+            return ENCODER.decodeStringStr32Utf8(encoded.getBuffer(), encoded.getDataOffset(), encoded.getDataSize());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeStringStr32Utf8(value, out);
+        }
+
+        public final String unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readStringStr32Utf8(getDataSize(), in);
+        }
+    }
+
+    /**
+     * up to 2^32 - 1 octets worth of UTF-16 unicode
+     */
+    private static class AmqpStringStr32Utf16Encoded extends AmqpStringEncoded {
+
+        private final STRING_ENCODING encoding = STRING_ENCODING.STR32_UTF16;
+        public AmqpStringStr32Utf16Encoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpStringStr32Utf16Encoded(String value) throws AmqpEncodingError {
+            super(STRING_ENCODING.STR32_UTF16.FORMAT_CODE, value);
+        }
+
+        protected final int computeDataSize() throws AmqpEncodingError {
+            return ENCODER.getEncodedSizeOfString(value, encoding);
+        }
+
+        public final void encode(String value, Buffer encoded, int offset) throws AmqpEncodingError {
+            ENCODER.encodeStringStr32Utf16(value, encoded, offset);
+        }
+
+        public final String decode(EncodedBuffer encoded) throws AmqpEncodingError {
+            return ENCODER.decodeStringStr32Utf16(encoded.getBuffer(), encoded.getDataOffset(), encoded.getDataSize());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeStringStr32Utf16(value, out);
+        }
+
+        public final String unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readStringStr32Utf16(getDataSize(), in);
+        }
+    }
+
+
+    private static final STRING_ENCODING chooseEncoding(AmqpString val) throws AmqpEncodingError {
+        return Encoder.chooseStringEncoding(val.getValue());
+    }
+
+    private static final STRING_ENCODING chooseEncoding(String val) throws AmqpEncodingError {
+        return Encoder.chooseStringEncoding(val);
+    }
+
+    static final Encoded<String> encode(AmqpString data) throws AmqpEncodingError {
+        if(data == null) {
+            return NULL_ENCODED;
+        }
+        return STRING_ENCODING.createEncoded(chooseEncoding(data).FORMAT_CODE, data.getValue());
+    }
+
+    static final Encoded<String> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<String> createEncoded(String val) throws AmqpEncodingError {
+        return STRING_ENCODING.createEncoded(chooseEncoding(val).FORMAT_CODE, val);
+    }
+
+    static final Encoded<String> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<String> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        if(buffer.getEncodingFormatCode() == AmqpNullMarshaller.FORMAT_CODE) {
+            return NULL_ENCODED;
+        }
+        return STRING_ENCODING.createEncoded(buffer);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSymbolMarshaller.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/AmqpSymbolMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSymbolMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpSymbolMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,216 @@
+/**
+ * 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.String;
+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.AmqpSymbol;
+import org.apache.activemq.util.buffer.Buffer;
+
+public class AmqpSymbolMarshaller {
+
+    private static final Encoder ENCODER = Encoder.SINGLETON;
+    private static final Encoded<String> NULL_ENCODED = new Encoder.NullEncoded<String>();
+
+    public static final byte SYM8_FORMAT_CODE = (byte) 0xa3;
+    public static final byte SYM32_FORMAT_CODE = (byte) 0xb3;
+
+    public static enum SYMBOL_ENCODING implements Encoding{
+        SYM8 (SYM8_FORMAT_CODE), // up to 2^8 - 1 seven bit ASCII characters representing a symbolic value
+        SYM32 (SYM32_FORMAT_CODE); // up to 2^32 - 1 seven bit ASCII characters representing a symbolic value
+
+        public final byte FORMAT_CODE;
+        public final FormatSubCategory CATEGORY;
+
+        SYMBOL_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 SYMBOL_ENCODING getEncoding(byte formatCode) throws UnexpectedTypeException {
+            switch(formatCode) {
+            case SYM8_FORMAT_CODE: {
+                return SYM8;
+            }
+            case SYM32_FORMAT_CODE: {
+                return SYM32;
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for Symbol: " + formatCode);
+            }
+            }
+        }
+
+        static final AmqpSymbolEncoded createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+            switch(buffer.getEncodingFormatCode()) {
+            case SYM8_FORMAT_CODE: {
+                return new AmqpSymbolSym8Encoded(buffer);
+            }
+            case SYM32_FORMAT_CODE: {
+                return new AmqpSymbolSym32Encoded(buffer);
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for Symbol: " + buffer.getEncodingFormatCode());
+            }
+            }
+        }
+        static final AmqpSymbolEncoded createEncoded(byte formatCode, String value) throws AmqpEncodingError {
+            switch(formatCode) {
+            case SYM8_FORMAT_CODE: {
+                return new AmqpSymbolSym8Encoded(value);
+            }
+            case SYM32_FORMAT_CODE: {
+                return new AmqpSymbolSym32Encoded(value);
+            }
+            default: {
+                throw new UnexpectedTypeException("Unexpected format code for Symbol: " + formatCode);
+            }
+            }
+        }
+    }
+    public static abstract class AmqpSymbolEncoded extends AbstractEncoded <String> {
+        public AmqpSymbolEncoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpSymbolEncoded(byte formatCode, String value) throws AmqpEncodingError {
+            super(formatCode, value);
+        }
+    }
+
+    /**
+     * up to 2^8 - 1 seven bit ASCII characters representing a symbolic value
+     */
+    private static class AmqpSymbolSym8Encoded extends AmqpSymbolEncoded {
+
+        private final SYMBOL_ENCODING encoding = SYMBOL_ENCODING.SYM8;
+        public AmqpSymbolSym8Encoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpSymbolSym8Encoded(String value) throws AmqpEncodingError {
+            super(SYMBOL_ENCODING.SYM8.FORMAT_CODE, value);
+        }
+
+        protected final int computeDataSize() throws AmqpEncodingError {
+            return ENCODER.getEncodedSizeOfSymbol(value, encoding);
+        }
+
+        public final void encode(String value, Buffer encoded, int offset) throws AmqpEncodingError {
+            ENCODER.encodeSymbolSym8(value, encoded, offset);
+        }
+
+        public final String decode(EncodedBuffer encoded) throws AmqpEncodingError {
+            return ENCODER.decodeSymbolSym8(encoded.getBuffer(), encoded.getDataOffset(), encoded.getDataSize());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeSymbolSym8(value, out);
+        }
+
+        public final String unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readSymbolSym8(getDataSize(), in);
+        }
+    }
+
+    /**
+     * up to 2^32 - 1 seven bit ASCII characters representing a symbolic value
+     */
+    private static class AmqpSymbolSym32Encoded extends AmqpSymbolEncoded {
+
+        private final SYMBOL_ENCODING encoding = SYMBOL_ENCODING.SYM32;
+        public AmqpSymbolSym32Encoded(EncodedBuffer encoded) {
+            super(encoded);
+        }
+
+        public AmqpSymbolSym32Encoded(String value) throws AmqpEncodingError {
+            super(SYMBOL_ENCODING.SYM32.FORMAT_CODE, value);
+        }
+
+        protected final int computeDataSize() throws AmqpEncodingError {
+            return ENCODER.getEncodedSizeOfSymbol(value, encoding);
+        }
+
+        public final void encode(String value, Buffer encoded, int offset) throws AmqpEncodingError {
+            ENCODER.encodeSymbolSym32(value, encoded, offset);
+        }
+
+        public final String decode(EncodedBuffer encoded) throws AmqpEncodingError {
+            return ENCODER.decodeSymbolSym32(encoded.getBuffer(), encoded.getDataOffset(), encoded.getDataSize());
+        }
+
+        public final void marshalData(DataOutput out) throws IOException {
+            ENCODER.writeSymbolSym32(value, out);
+        }
+
+        public final String unmarshalData(DataInput in) throws IOException {
+            return ENCODER.readSymbolSym32(getDataSize(), in);
+        }
+    }
+
+
+    private static final SYMBOL_ENCODING chooseEncoding(AmqpSymbol val) throws AmqpEncodingError {
+        return Encoder.chooseSymbolEncoding(val.getValue());
+    }
+
+    private static final SYMBOL_ENCODING chooseEncoding(String val) throws AmqpEncodingError {
+        return Encoder.chooseSymbolEncoding(val);
+    }
+
+    static final Encoded<String> encode(AmqpSymbol data) throws AmqpEncodingError {
+        if(data == null) {
+            return NULL_ENCODED;
+        }
+        return SYMBOL_ENCODING.createEncoded(chooseEncoding(data).FORMAT_CODE, data.getValue());
+    }
+
+    static final Encoded<String> createEncoded(Buffer source, int offset) throws AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(source, offset));
+    }
+
+    static final Encoded<String> createEncoded(String val) throws AmqpEncodingError {
+        return SYMBOL_ENCODING.createEncoded(chooseEncoding(val).FORMAT_CODE, val);
+    }
+
+    static final Encoded<String> createEncoded(DataInput in) throws IOException, AmqpEncodingError {
+        return createEncoded(FormatCategory.createBuffer(in.readByte(), in));
+    }
+
+    static final Encoded<String> createEncoded(EncodedBuffer buffer) throws AmqpEncodingError {
+        if(buffer.getEncodingFormatCode() == AmqpNullMarshaller.FORMAT_CODE) {
+            return NULL_ENCODED;
+        }
+        return SYMBOL_ENCODING.createEncoded(buffer);
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpTargetMarshaller.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/AmqpTargetMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpTargetMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpTargetMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,162 @@
+/**
+ * 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.AmqpAddress;
+import org.apache.activemq.amqp.protocol.types.AmqpBoolean;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpTarget;
+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.util.buffer.Buffer;
+
+public class AmqpTargetMarshaller implements DescribedTypeMarshaller<AmqpTarget>{
+
+    static final AmqpTargetMarshaller SINGLETON = new AmqpTargetMarshaller();
+    private static final Encoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> NULL_ENCODED = new Encoder.NullEncoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>>();
+
+    public static final String SYMBOLIC_ID = "amqp:target:map";
+    //Format code: 0x00000001:0x00009702:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 38658;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4295005954L)
+    //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) 0x97, (byte) 0x02   // DESCRIPTOR ID CODE
+    }), 0);
+
+    //Accessor keys for field mapped fields:
+    private static final AmqpSymbol.AmqpSymbolBuffer ADDRESS_KEY = new AmqpSymbol.AmqpSymbolBean("address").getBuffer(AmqpMarshaller.SINGLETON);
+    private static final AmqpSymbol.AmqpSymbolBuffer CREATE_KEY = new AmqpSymbol.AmqpSymbolBean("create").getBuffer(AmqpMarshaller.SINGLETON);
+    private static final AmqpSymbol.AmqpSymbolBuffer TIMEOUT_KEY = new AmqpSymbol.AmqpSymbolBean("timeout").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(ADDRESS_KEY.getValue())){
+                map.put(ADDRESS_KEY, AmqpAddress.AmqpAddressBuffer.create(AmqpBinaryMarshaller.createEncoded(encodedValue)));
+            }
+            if (key.getValue().equals(CREATE_KEY.getValue())){
+                map.put(CREATE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(encodedValue)));
+            }
+            if (key.getValue().equals(TIMEOUT_KEY.getValue())){
+                map.put(TIMEOUT_KEY, AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.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(ADDRESS_KEY.getValue())){
+                map.put(ADDRESS_KEY, AmqpAddress.AmqpAddressBuffer.create(AmqpBinaryMarshaller.createEncoded(in)));
+            }
+            if (key.getValue().equals(CREATE_KEY.getValue())){
+                map.put(CREATE_KEY, AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in)));
+            }
+            if (key.getValue().equals(TIMEOUT_KEY.getValue())){
+                map.put(TIMEOUT_KEY, AmqpUint.AmqpUintBuffer.create(AmqpUintMarshaller.createEncoded(in)));
+            }
+            else {
+                throw new UnexpectedTypeException("Invalid Key for " + SYMBOLIC_ID + " : " + key);
+            }
+        }
+    };
+
+    public static class AmqpTargetEncoded extends DescribedEncoded<HashMap<AmqpType<?,?>, AmqpType<?,?>>> {
+
+        public AmqpTargetEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpTargetEncoded(AmqpTarget 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(AmqpTarget value) throws AmqpEncodingError {
+        return new AmqpTargetEncoded(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 AmqpTargetEncoded(db);
+    }
+
+    public final AmqpTarget.AmqpTargetBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpTarget.AmqpTargetBuffer.create(new AmqpTargetEncoded(encoded));
+    }
+}

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

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpTransferMarshaller.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/AmqpTransferMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpTransferMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpTransferMarshaller.java Thu Feb 11 07:04:21 2010
@@ -0,0 +1,170 @@
+/**
+ * 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.AmqpDeliveryTag;
+import org.apache.activemq.amqp.protocol.types.AmqpHandle;
+import org.apache.activemq.amqp.protocol.types.AmqpList;
+import org.apache.activemq.amqp.protocol.types.AmqpOptions;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpTransfer;
+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 AmqpTransferMarshaller implements DescribedTypeMarshaller<AmqpTransfer>{
+
+    static final AmqpTransferMarshaller SINGLETON = new AmqpTransferMarshaller();
+    private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+    public static final String SYMBOLIC_ID = "amqp:transfer:list";
+    //Format code: 0x00000001:0x00000309:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 777;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294968073L)
+    //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) 0x09   // 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));
+            }
+            case 3: {
+                return AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in));
+            }
+            case 4: {
+                return AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in));
+            }
+            case 5: {
+                return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.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));
+            }
+            case 3: {
+                return AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(buffer));
+            }
+            case 4: {
+                return AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(buffer));
+            }
+            case 5: {
+                return AmqpList.AmqpListBuffer.create(AmqpListMarshaller.createEncoded(buffer));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.decodeType(buffer);
+            }
+            }
+        }
+    };
+
+    public static class AmqpTransferEncoded extends DescribedEncoded<IAmqpList> {
+
+        public AmqpTransferEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpTransferEncoded(AmqpTransfer 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(AmqpTransfer value) throws AmqpEncodingError {
+        return new AmqpTransferEncoded(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 AmqpTransferEncoded(db);
+    }
+
+    public final AmqpTransfer.AmqpTransferBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpTransfer.AmqpTransferBuffer.create(new AmqpTransferEncoded(encoded));
+    }
+}

Added: activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpTxnMarshaller.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/AmqpTxnMarshaller.java?rev=908857&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpTxnMarshaller.java (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-amqp/src/main/java/org/apache/activemq/amqp/protocol/marshaller/v1_0_0/AmqpTxnMarshaller.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.AmqpBoolean;
+import org.apache.activemq.amqp.protocol.types.AmqpOptions;
+import org.apache.activemq.amqp.protocol.types.AmqpSymbol;
+import org.apache.activemq.amqp.protocol.types.AmqpTxn;
+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 AmqpTxnMarshaller implements DescribedTypeMarshaller<AmqpTxn>{
+
+    static final AmqpTxnMarshaller SINGLETON = new AmqpTxnMarshaller();
+    private static final Encoded<IAmqpList> NULL_ENCODED = new Encoder.NullEncoded<IAmqpList>();
+
+    public static final String SYMBOLIC_ID = "amqp:txn:list";
+    //Format code: 0x00000001:0x00000303:
+    public static final long CATEGORY = 1;
+    public static final long DESCRIPTOR_ID = 771;
+    public static final long NUMERIC_ID = CATEGORY << 32 | DESCRIPTOR_ID; //(4294968067L)
+    //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) 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 AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(in));
+            }
+            case 2: {
+                return AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.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 AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(buffer));
+            }
+            case 2: {
+                return AmqpBoolean.AmqpBooleanBuffer.create(AmqpBooleanMarshaller.createEncoded(buffer));
+            }
+            default: {
+                return AmqpMarshaller.SINGLETON.decodeType(buffer);
+            }
+            }
+        }
+    };
+
+    public static class AmqpTxnEncoded extends DescribedEncoded<IAmqpList> {
+
+        public AmqpTxnEncoded(DescribedBuffer buffer) {
+            super(buffer);
+        }
+
+        public AmqpTxnEncoded(AmqpTxn 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(AmqpTxn value) throws AmqpEncodingError {
+        return new AmqpTxnEncoded(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 AmqpTxnEncoded(db);
+    }
+
+    public final AmqpTxn.AmqpTxnBuffer decodeDescribedType(AmqpType<?, ?> descriptor, DescribedBuffer encoded) throws AmqpEncodingError {
+        return AmqpTxn.AmqpTxnBuffer.create(new AmqpTxnEncoded(encoded));
+    }
+}



Mime
View raw message