From 443eca6549dca94d66264d9c7c9c2b7e2760cbd0 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Thu, 4 Jan 2007 22:11:38 +0000 Subject: svn merge -r492717:492730 from the trunk git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@492777 13f79535-47bb-0310-9956-ffa450edef68 --- java/broker/etc/config.xml | 2 +- .../main/java/org/apache/qpid/framing/AMQType.java | 138 +++++++++------------ .../java/org/apache/qpid/framing/AMQTypeMap.java | 7 +- .../java/org/apache/qpid/framing/FieldTable.java | 4 +- 4 files changed, 65 insertions(+), 86 deletions(-) (limited to 'java') diff --git a/java/broker/etc/config.xml b/java/broker/etc/config.xml index 7f3eb129d5..61e0e55138 100644 --- a/java/broker/etc/config.xml +++ b/java/broker/etc/config.xml @@ -69,7 +69,7 @@ org.apache.qpid.server.security.auth.amqplain.AmqPlainInitialiser passwordfile - --> + org.apache.qpid.server.security.auth.plain.PlainInitialiser diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQType.java b/java/common/src/main/java/org/apache/qpid/framing/AMQType.java index 4bce1ca5f0..ad07634554 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQType.java +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQType.java @@ -28,35 +28,39 @@ public enum AMQType //AMQP FieldTable Wire Types - DECIMAL('D') + LONG_STRING('S') { - public int getEncodingSize(Object value) { - // TODO : fixme - throw new UnsupportedOperationException(); + return EncodingUtils.encodedLongStringLength((String) value); } - public Object toNativeValue(Object value) + + public String toNativeValue(Object value) { - // TODO : fixme - throw new UnsupportedOperationException(); + if (value != null) + { + return value.toString(); + } + else + { + throw new NullPointerException("Cannot convert: null to String."); + } } public void writeValueImpl(Object value, ByteBuffer buffer) { - // TODO : fixme - throw new UnsupportedOperationException(); + EncodingUtils.writeLongStringBytes(buffer, (String) value); } public Object readValueFromBuffer(ByteBuffer buffer) { - // TODO : fixme - throw new UnsupportedOperationException(); + return EncodingUtils.readLongString(buffer); } + }, - UNSIGNED_SHORT('S') + INTEGER('I') { public int getEncodingSize(Object value) @@ -65,6 +69,7 @@ public enum AMQType throw new UnsupportedOperationException(); } + public Object toNativeValue(Object value) { // TODO : fixme @@ -82,10 +87,9 @@ public enum AMQType // TODO : fixme throw new UnsupportedOperationException(); } - }, - UNSIGNED_INT('I') + DECIMAL('D') { public int getEncodingSize(Object value) @@ -94,7 +98,6 @@ public enum AMQType throw new UnsupportedOperationException(); } - public Object toNativeValue(Object value) { // TODO : fixme @@ -114,7 +117,7 @@ public enum AMQType } }, - UNSIGNED_LONG('L') + TIMESTAMP('T') { public int getEncodingSize(Object value) @@ -124,7 +127,7 @@ public enum AMQType } - public Long toNativeValue(Object value) + public Object toNativeValue(Object value) { // TODO : fixme throw new UnsupportedOperationException(); @@ -143,9 +146,8 @@ public enum AMQType } }, - EXTTENDED('D') + FIELD_TABLE('F') { - public int getEncodingSize(Object value) { // TODO : fixme @@ -172,35 +174,39 @@ public enum AMQType } }, - TIMESTAMP('T') + VOID('V') { - public int getEncodingSize(Object value) { - // TODO : fixme - throw new UnsupportedOperationException(); + return 0; } public Object toNativeValue(Object value) { - // TODO : fixme - throw new UnsupportedOperationException(); + if (value == null) + { + return null; + } + else + { + throw new NumberFormatException("Cannot convert: " + value + "(" + + value.getClass().getName() + ") to null String."); + } } public void writeValueImpl(Object value, ByteBuffer buffer) { - // TODO : fixme - throw new UnsupportedOperationException(); } public Object readValueFromBuffer(ByteBuffer buffer) { - // TODO : fixme - throw new UnsupportedOperationException(); + return null; } }, + // Extended types + BINARY('x') { public int getEncodingSize(Object value) @@ -299,38 +305,6 @@ public enum AMQType } }, - NULL_STRING('n') - { - - public int getEncodingSize(Object value) - { - return 0; - } - - - public String toNativeValue(Object value) - { - if (value == null) - { - return null; - } - else - { - throw new NumberFormatException("Cannot convert: " + value + "(" + - value.getClass().getName() + ") to null String."); - } - } - - public void writeValueImpl(Object value, ByteBuffer buffer) - { - } - - public Object readValueFromBuffer(ByteBuffer buffer) - { - return null; - } - }, - BOOLEAN('t') { public int getEncodingSize(Object value) @@ -368,77 +342,77 @@ public enum AMQType } }, - BYTE('b') + ASCII_CHARACTER('k') { public int getEncodingSize(Object value) { - return EncodingUtils.encodedByteLength(); + return EncodingUtils.encodedCharLength(); } - public Byte toNativeValue(Object value) + public Character toNativeValue(Object value) { - if (value instanceof Byte) + if (value instanceof Character) { - return (Byte) value; + return (Character) value; } - else if ((value instanceof String) || (value == null)) + else if (value == null) { - return Byte.valueOf((String)value); + throw new NullPointerException("Cannot convert null into char"); } else { throw new NumberFormatException("Cannot convert: " + value + "(" + - value.getClass().getName() + ") to byte."); + value.getClass().getName() + ") to char."); } } public void writeValueImpl(Object value, ByteBuffer buffer) { - EncodingUtils.writeByte(buffer, (Byte) value); + EncodingUtils.writeChar(buffer, (Character) value); } public Object readValueFromBuffer(ByteBuffer buffer) { - return EncodingUtils.readByte(buffer); + return EncodingUtils.readChar(buffer); } + }, - ASCII_CHARACTER('k') + BYTE('b') { public int getEncodingSize(Object value) { - return EncodingUtils.encodedCharLength(); + return EncodingUtils.encodedByteLength(); } - public Character toNativeValue(Object value) + public Byte toNativeValue(Object value) { - if (value instanceof Character) + if (value instanceof Byte) { - return (Character) value; + return (Byte) value; } - else if (value == null) + else if ((value instanceof String) || (value == null)) { - throw new NullPointerException("Cannot convert null into char"); + return Byte.valueOf((String)value); } else { throw new NumberFormatException("Cannot convert: " + value + "(" + - value.getClass().getName() + ") to char."); + value.getClass().getName() + ") to byte."); } } public void writeValueImpl(Object value, ByteBuffer buffer) { - EncodingUtils.writeChar(buffer, (Character) value); + EncodingUtils.writeByte(buffer, (Byte) value); } public Object readValueFromBuffer(ByteBuffer buffer) { - return EncodingUtils.readChar(buffer); + return EncodingUtils.readByte(buffer); } - }, SHORT('s') diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java b/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java index e24fd7efeb..5ac7f8827b 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java @@ -37,7 +37,12 @@ public class AMQTypeMap public static AMQType getType(Byte identifier) { - return _reverseTypeMap.get(identifier); + AMQType result = _reverseTypeMap.get(identifier); + if (result == null) { + throw new IllegalArgumentException + ("no such type code: " + Integer.toHexString(identifier.intValue())); + } + return result; } } diff --git a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java index 4d88009076..3c18683609 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java +++ b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java @@ -257,7 +257,7 @@ public class FieldTable checkPropertyName(string); if (value == null) { - return _properties.put(string, AMQType.NULL_STRING.asTypedValue(null)); + return _properties.put(string, AMQType.VOID.asTypedValue(null)); } else { @@ -344,7 +344,7 @@ public class FieldTable public boolean isNullStringValue(String name) { AMQTypedValue value = _properties.get(name); - return (value != null) && (value.getType() == AMQType.NULL_STRING); + return (value != null) && (value.getType() == AMQType.VOID); } // ***** Methods -- cgit v1.2.1