summaryrefslogtreecommitdiff
path: root/java/common
diff options
context:
space:
mode:
authorArnaud Simon <arnaudsimon@apache.org>2008-09-29 12:02:54 +0000
committerArnaud Simon <arnaudsimon@apache.org>2008-09-29 12:02:54 +0000
commit32c96c8a723712b74a3b7b2331cc3b1b75d6cc3e (patch)
tree8a85f9d9ea3b0a0ac617d89e884077708b8983b4 /java/common
parent5d140890605743357347a0c0326ed4cf78117d8d (diff)
downloadqpid-python-32c96c8a723712b74a3b7b2331cc3b1b75d6cc3e.tar.gz
qpid-1284: Qman on behalf Andrea
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@700077 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common')
-rw-r--r--java/common/src/main/java/org/apache/qpid/transport/codec/ManagementDecoder.java109
-rw-r--r--java/common/src/main/java/org/apache/qpid/transport/codec/ManagementEncoder.java86
2 files changed, 195 insertions, 0 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementDecoder.java b/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementDecoder.java
new file mode 100644
index 0000000000..1e9fdc5e3e
--- /dev/null
+++ b/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementDecoder.java
@@ -0,0 +1,109 @@
+package org.apache.qpid.transport.codec;
+
+import java.nio.ByteBuffer;
+import java.util.Map;
+import java.util.UUID;
+
+
+/*
+ * Extends BBDecoder to add some additional methods.
+ *
+ * FIXME (Gazza) : I don't like very much this class...this code should be part of BBDecoder
+ */
+public class ManagementDecoder
+{
+ private BBDecoder _decoder;
+ private ByteBuffer _buffer;
+
+ public void init(ByteBuffer buffer)
+ {
+ this._buffer = buffer;
+ this._decoder = new BBDecoder();
+ _decoder.init(_buffer);
+ }
+
+ public byte[] readReaminingBytes ()
+ {
+ byte[] result = new byte[_buffer.limit() - _buffer.position()];
+ _decoder.get(result);
+ return result;
+ }
+
+ public byte[] readBin128() {
+ byte[] result = new byte[16];
+ _decoder.get(result);
+ return result;
+ }
+
+ public byte[] readBytes (int howMany)
+ {
+ byte [] result = new byte[howMany];
+ _decoder.get(result);
+ return result;
+ }
+
+ public long readDatetime ()
+ {
+ return _decoder.readDatetime();
+ }
+
+ public Map<String, Object> readMap ()
+ {
+ return _decoder.readMap();
+ }
+
+ public int readSequenceNo ()
+ {
+ return _decoder.readSequenceNo();
+ }
+
+ public String readStr16 ()
+ {
+ return _decoder.readStr16();
+ }
+
+ public String readStr8 ()
+ {
+ return _decoder.readStr8();
+ }
+
+ public int readUint16 ()
+ {
+ return _decoder.readUint16();
+ }
+
+ public long readUint32 ()
+ {
+ return _decoder.readUint32();
+ }
+
+ public long readUint64 ()
+ {
+ return _decoder.readUint64();
+ }
+
+ public short readUint8 ()
+ {
+ return _decoder.readUint8();
+ }
+
+ public UUID readUuid ()
+ {
+ return _decoder.readUuid();
+ }
+
+ public byte[] readVbin16 ()
+ {
+ return _decoder.readVbin16();
+ }
+
+ public byte[] readVbin32 ()
+ {
+ return _decoder.readVbin32();
+ }
+
+ public byte[] readVbin8 ()
+ {
+ return _decoder.readVbin8();
+ }
+} \ No newline at end of file
diff --git a/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementEncoder.java b/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementEncoder.java
new file mode 100644
index 0000000000..3dc4fe9ae3
--- /dev/null
+++ b/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementEncoder.java
@@ -0,0 +1,86 @@
+package org.apache.qpid.transport.codec;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.transport.codec.AbstractEncoder;
+
+/*
+ * @author rahulapi@gmailcom
+ *
+ * Management Encoder extends the basic java encoer (AbastractEncoder)
+ * its a java encoder we use to encode the incoming messages
+ * (encode the fields of the message)
+ *
+ * TODO (Gazza) : I don't like very much this class...this code should be part of BBDecoder
+ */
+public class ManagementEncoder extends AbstractEncoder{
+
+
+ public ByteBuffer _out=null;
+
+ public ManagementEncoder(ByteBuffer out)
+ {
+
+ _out = out;
+ }
+
+ protected void doPut(byte b)
+ {
+ _out.put(b);
+ }
+
+ protected void doPut(ByteBuffer src)
+ {
+ _out.put(src);
+ }
+
+ public void writeBin128(byte[] s)
+ {
+ if(s==null)
+ {
+ s=new byte[16];
+
+ }else if(s.length!=16){
+ throw new IllegalArgumentException(""+s);
+ }
+ put(s);
+ }
+
+ @Override
+ protected int beginSize16() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ protected int beginSize32() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ protected int beginSize8() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ protected void endSize16(int pos) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void endSize32(int pos) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void endSize8(int pos) {
+ // TODO Auto-generated method stub
+
+ }
+
+} \ No newline at end of file