Author: cmacnaug
Date: Sat Feb 6 21:46:41 2010
New Revision: 907314
URL: http://svn.apache.org/viewvc?rev=907314&view=rev
Log:
Miscellaneous updates ... not yet functional
Added:
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/AmqpEncodingError.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/AmqpVersion.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/Encoded.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/Encoding.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/UnexpectedTypeException.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/BaseEncoder.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/DescribedTypeMarshaller.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/Encoder.java
Removed:
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/AmqpMarshaller.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/main/java/org/apache/activemq/amqp/generator/AmqpMarshallerGen.java
Modified:
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/BitUtils.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/types/AmqpType.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/main/java/org/apache/activemq/amqp/generator/AmqpClass.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/main/java/org/apache/activemq/amqp/generator/Generator.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/main/java/org/apache/activemq/amqp/generator/Main.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/main/java/org/apache/activemq/amqp/generator/TypeRegistry.java
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/main/java/org/apache/activemq/amqp/generator/Utils.java
Modified:
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/BitUtils.java
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/BitUtils.java?rev=907314&r1=907313&r2=907314&view=diff
==============================================================================
---
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/BitUtils.java
(original)
+++
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/BitUtils.java
Sat Feb 6 21:46:41 2010
@@ -16,48 +16,102 @@
*/
package org.apache.activemq.amqp.generator.handcoded;
-public class BitUtils {
+import java.math.BigInteger;
+public class BitUtils {
+
+ public static final void setUByte(final byte[] target, final int offset,
final short value) {
+ target[offset + 0] = (byte) (0xff & target[offset]);
+ }
+
+ public static final short getUByte(final byte[] source, final int offset) {
+ return (short) (0xFFFF & source[offset]);
+ }
+
+ public static final void setByte(final byte[] target, final int offset,
final byte value) {
+ target[offset + 0] = value;
+ }
+
+ public static final short getByte(final byte[] source, final int offset) {
+ return source[offset];
+ }
+
public static final void setUShort(final byte[] target, final int offset,
final long value) {
- target[offset + 0] = (byte) ((value >> 1) & 0xff);
+ target[offset + 0] = (byte) ((value >> 8) & 0xff);
target[offset + 1] = (byte) ((value >> 0) & 0xff);
}
- public static final int getUShort(final byte[] target, final int offset) {
- return target[offset + 0] << 1 & 0xff | target[offset + 1];
+ public static final int getUShort(final byte[] source, final int offset) {
+ return source[offset + 0] << 8 & 0xff | source[offset + 1];
}
public static final void setShort(final byte[] target, final int offset,
final short value) {
- target[offset + 0] = (byte) ((value >> 1) & 0xff);
+ target[offset + 0] = (byte) ((value >> 8) & 0xff);
target[offset + 1] = (byte) ((value >> 0) & 0xff);
}
- public static final short getShort(final byte[] target, final int offset) {
- return (short) (target[offset + 0] << 1 & 0xff | target[offset + 1]);
+ public static final short getShort(final byte[] source, final int offset) {
+ return (short) (source[offset + 0] << 8 & 0xff | source[offset + 1]);
}
public static final void setUInt(final byte[] target, final int offset,
final long value) {
assert value < Integer.MAX_VALUE * 2 + 1;
- target[offset + 0] = (byte) (value >> 3 & 0xff);
- target[offset + 1] = (byte) (value >> 2 & 0xff);
- target[offset + 2] = (byte) (value >> 1 & 0xff);
+ target[offset + 0] = (byte) (value >> 24 & 0xff);
+ target[offset + 1] = (byte) (value >> 16 & 0xff);
+ target[offset + 2] = (byte) (value >> 8 & 0xff);
target[offset + 3] = (byte) (value >> 0 & 0xff);
}
- public static final long getUInt(final byte[] target, final int offset) {
- return target[offset + 0] << 3 | target[offset + 1] << 2 |
target[offset + 2] << 1 | target[offset + 3];
+ public static final long getUInt(final byte[] source, final int offset) {
+ return source[offset + 0] << 24 | source[offset + 1] << 16 |
source[offset + 2] << 8 | source[offset + 3];
}
public static final void setInt(final byte[] target, final int offset,
final int value) {
assert value < Integer.MAX_VALUE * 2 + 1;
- target[offset + 0] = (byte) (value >> 3 & 0xff);
- target[offset + 1] = (byte) (value >> 2 & 0xff);
- target[offset + 2] = (byte) (value >> 1 & 0xff);
+ target[offset + 0] = (byte) (value >> 24 & 0xff);
+ target[offset + 1] = (byte) (value >> 16 & 0xff);
+ target[offset + 2] = (byte) (value >> 8 & 0xff);
target[offset + 3] = (byte) (value >> 0 & 0xff);
}
- public static final int getInt(final byte[] target, final int offset) {
- return target[offset + 0] << 3 | target[offset + 1] << 2 |
target[offset + 2] << 1 | target[offset + 3];
+ public static final int getInt(final byte[] source, final int offset) {
+ return source[offset + 0] << 3 | source[offset + 1] << 2 |
source[offset + 2] << 1 | source[offset + 3];
+ }
+
+ public static final void setLong(final byte[] target, final int offset,
final long value) {
+ assert value < Integer.MAX_VALUE * 2 + 1;
+ target[offset + 0] = (byte) (value >> 56 & 0xff);
+ target[offset + 1] = (byte) (value >> 48 & 0xff);
+ target[offset + 2] = (byte) (value >> 40 & 0xff);
+ target[offset + 3] = (byte) (value >> 32 & 0xff);
+ target[offset + 4] = (byte) (value >> 24 & 0xff);
+ target[offset + 5] = (byte) (value >> 12 & 0xff);
+ target[offset + 6] = (byte) (value >> 8 & 0xff);
+ target[offset + 7] = (byte) (value >> 0 & 0xff);
}
+ public static final long getLong(final byte[] source, final int offset) {
+ long rc =
+ (int) source[offset + 0] << 56 |
+ (int) source[offset + 1] << 48 |
+ (int) source[offset + 2] << 40 |
+ (int) source[offset + 3] << 32 |
+ (int) source[offset + 4] << 24 |
+ (int) source[offset + 5] << 16 |
+ (int) source[offset + 6] << 8 |
+ (int) source[offset + 7];
+
+ return rc;
+ }
+
+ public static final BigInteger getULong(final byte[] source, final int
offset) {
+ byte [] bi = new byte [9];
+ System.arraycopy(source, offset, bi, 1, 8);
+ return new BigInteger(bi);
+ }
+
+ public static final void setULong(final byte[] target, final int offset,
final BigInteger value) {
+ byte [] b = value.toByteArray();
+ System.arraycopy(b, b.length - 8, target, offset, 8);
+ }
}
Added:
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/AmqpEncodingError.java
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/AmqpEncodingError.java?rev=907314&view=auto
==============================================================================
---
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/AmqpEncodingError.java
(added)
+++
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/AmqpEncodingError.java
Sat Feb 6 21:46:41 2010
@@ -0,0 +1,31 @@
+/**
+ * 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.generator.handcoded.marshaller;
+
+import java.io.IOException;
+
+public class AmqpEncodingError extends Error {
+
+ public AmqpEncodingError(String msg) {
+ super(msg);
+ }
+
+ public AmqpEncodingError(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+}
Added:
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/AmqpVersion.java
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/AmqpVersion.java?rev=907314&view=auto
==============================================================================
---
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/AmqpVersion.java
(added)
+++
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/AmqpVersion.java
Sat Feb 6 21:46:41 2010
@@ -0,0 +1,70 @@
+/**
+ * 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.generator.handcoded.marshaller;
+
+import org.apache.activemq.amqp.generator.handcoded.BitUtils;
+
+public class AmqpVersion {
+
+ private static final short PROTOCOL_ID = 0;
+ public static final byte[] MAGIC = new byte[] { 'A', 'M', 'Q', 'P',
PROTOCOL_ID };
+
+ private final short major;
+ private final short minor;
+ private final short revision;
+
+ private final int hashCode;
+
+ public AmqpVersion(short major, short minor, short revision) {
+ this.major = major;
+ this.minor = minor;
+ this.revision = revision;
+ this.hashCode = BitUtils.getInt(new byte[] { PROTOCOL_ID, (byte)
(major & 0xFF), (byte) (minor & 0xFF), (byte) (revision & 0xFF) }, 0);
+ }
+
+ public short getProtocolId() {
+ return PROTOCOL_ID;
+ }
+
+ public short getMajor() {
+ return major;
+ }
+
+ public short getMinor() {
+ return minor;
+ }
+
+ public short getRevision() {
+ return revision;
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+
+ public boolean equals(Object o) {
+ if (o.hashCode() != hashCode) {
+ return false;
+ } else {
+ return o instanceof AmqpVersion;
+ }
+ }
+
+ public boolean equals(AmqpVersion version) {
+ return version.hashCode == hashCode;
+ }
+}
Added:
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/Encoded.java
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/Encoded.java?rev=907314&view=auto
==============================================================================
---
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/Encoded.java
(added)
+++
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/Encoded.java
Sat Feb 6 21:46:41 2010
@@ -0,0 +1,45 @@
+/**
+ * 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.generator.handcoded.marshaller;
+
+import java.io.DataOutput;
+import java.io.DataInput;
+import java.io.IOException;
+
+import org.apache.activemq.amqp.protocol.marshaller.AmqpEncodingError;
+import org.apache.activemq.util.buffer.Buffer;
+
+public interface Encoded<E> extends Encoding {
+
+ public int getEncodedSize() throws AmqpEncodingError;
+
+ public int getDataSize() throws AmqpEncodingError;
+
+ public int getDataCount() throws AmqpEncodingError;
+
+ public E getValue() throws AmqpEncodingError;
+
+ public Buffer getBuffer() throws AmqpEncodingError;
+
+ public void encode(Buffer target, int offset) throws AmqpEncodingError;
+
+ public void marshal(DataOutput out) throws IOException;
+
+ public void marshalData(DataOutput out) throws IOException;
+
+ public void marshalConstructor(DataOutput out) throws IOException;
+}
Added:
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/Encoding.java
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/Encoding.java?rev=907314&view=auto
==============================================================================
---
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/Encoding.java
(added)
+++
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/Encoding.java
Sat Feb 6 21:46:41 2010
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * his work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.amqp.generator.handcoded.marshaller;
+
+public interface Encoding {
+
+ public AmqpVersion getEncodingVersion();
+
+ public byte getEncodingFormatCode();
+}
Added:
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/UnexpectedTypeException.java
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/UnexpectedTypeException.java?rev=907314&view=auto
==============================================================================
---
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/UnexpectedTypeException.java
(added)
+++
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/UnexpectedTypeException.java
Sat Feb 6 21:46:41 2010
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with his
work
+ * for additional information regarding copyright ownership. The ASF licenses
+ * this file to You under the Apache License, Version 2.0 (the "License"); you
+ * may not use this file except in compliance with the License. You may obtain
a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package org.apache.activemq.amqp.generator.handcoded.marshaller;
+
+public class UnexpectedTypeException extends AmqpEncodingError {
+
+ private static final long serialVersionUID = 4306936382810257248L;
+
+ public UnexpectedTypeException(String msg) {
+ super(msg);
+ }
+}
Added:
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/BaseEncoder.java
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/BaseEncoder.java?rev=907314&view=auto
==============================================================================
---
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/BaseEncoder.java
(added)
+++
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/BaseEncoder.java
Sat Feb 6 21:46:41 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.generator.handcoded.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.generator.handcoded.marshaller.v1_0_0.AmqpStringMarshaller.STRING_ENCODING;
+import
org.apache.activemq.amqp.generator.handcoded.marshaller.v1_0_0.AmqpSymbolMarshaller.SYMBOL_ENCODING;
+import org.apache.activemq.amqp.generator.handcoded.BitUtils;
+import
org.apache.activemq.amqp.generator.handcoded.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());
+ }
+}
\ No newline at end of file
Added:
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/DescribedTypeMarshaller.java
URL:
http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/DescribedTypeMarshaller.java?rev=907314&view=auto
==============================================================================
---
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/DescribedTypeMarshaller.java
(added)
+++
activemq/sandbox/activemq-apollo-actor/activemq-amqp-generator/src/handcoded/org/apache/activemq/amqp/generator/handcoded/marshaller/v1_0_0/DescribedTypeMarshaller.java
Sat Feb 6 21:46:41 2010
@@ -0,0 +1,30 @@
+/**
+ * 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.generator.handcoded.marshaller.v1_0_0;
+
+import java.io.DataInput;
+import java.io.IOException;
+import
org.apache.activemq.amqp.generator.handcoded.marshaller.AmqpEncodingError;
+import
org.apache.activemq.amqp.generator.handcoded.marshaller.v1_0_0.Encoder.DescribedBuffer;
+
+
+import org.apache.activemq.amqp.generator.handcoded.types.AmqpType;
+
+public interface DescribedTypeMarshaller<D extends AmqpType<?>> {
+
+ public D decodeDescribedType(AmqpType<?> descriptor, DescribedBuffer
buffer) throws AmqpEncodingError;
+}