001 /*
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements. See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership. The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License. You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied. See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 *
020 */
021
022 package org.apache.qpid.framing.amqp_0_9;
023
024 import org.apache.qpid.framing.EncodingUtils;
025 import org.apache.qpid.framing.AMQShortString;
026 import org.apache.qpid.framing.FieldTable;
027 import org.apache.qpid.framing.AMQFrameDecodingException;
028 import org.apache.qpid.framing.Content;
029
030 import org.apache.mina.common.ByteBuffer;
031
032 public abstract class AMQMethodBody_0_9 extends org.apache.qpid.framing.AMQMethodBodyImpl
033 {
034
035 public byte getMajor()
036 {
037 return 0;
038 }
039
040 public byte getMinor()
041 {
042 return 9;
043 }
044
045 public int getSize()
046 {
047 return 2 + 2 + getBodySize();
048 }
049
050 public void writePayload(ByteBuffer buffer)
051 {
052 EncodingUtils.writeUnsignedShort(buffer, getClazz());
053 EncodingUtils.writeUnsignedShort(buffer, getMethod());
054 writeMethodPayload(buffer);
055 }
056
057
058 protected byte readByte(ByteBuffer buffer)
059 {
060 return buffer.get();
061 }
062
063 protected AMQShortString readAMQShortString(ByteBuffer buffer)
064 {
065 return EncodingUtils.readAMQShortString(buffer);
066 }
067
068 protected int getSizeOf(AMQShortString string)
069 {
070 return EncodingUtils.encodedShortStringLength(string);
071 }
072
073 protected void writeByte(ByteBuffer buffer, byte b)
074 {
075 buffer.put(b);
076 }
077
078 protected void writeAMQShortString(ByteBuffer buffer, AMQShortString string)
079 {
080 EncodingUtils.writeShortStringBytes(buffer, string);
081 }
082
083 protected int readInt(ByteBuffer buffer)
084 {
085 return buffer.getInt();
086 }
087
088 protected void writeInt(ByteBuffer buffer, int i)
089 {
090 buffer.putInt(i);
091 }
092
093 protected FieldTable readFieldTable(ByteBuffer buffer) throws AMQFrameDecodingException
094 {
095 return EncodingUtils.readFieldTable(buffer);
096 }
097
098 protected int getSizeOf(FieldTable table)
099 {
100 return EncodingUtils.encodedFieldTableLength(table); //To change body of created methods use File | Settings | File Templates.
101 }
102
103 protected void writeFieldTable(ByteBuffer buffer, FieldTable table)
104 {
105 EncodingUtils.writeFieldTableBytes(buffer, table);
106 }
107
108 protected long readLong(ByteBuffer buffer)
109 {
110 return buffer.getLong();
111 }
112
113 protected void writeLong(ByteBuffer buffer, long l)
114 {
115 buffer.putLong(l);
116 }
117
118 protected int getSizeOf(byte[] response)
119 {
120 return (response == null) ? 4 :response.length + 4;
121 }
122
123 protected void writeBytes(ByteBuffer buffer, byte[] data)
124 {
125 EncodingUtils.writeBytes(buffer,data);
126 }
127
128 protected byte[] readBytes(ByteBuffer buffer)
129 {
130 return EncodingUtils.readBytes(buffer);
131 }
132
133 protected short readShort(ByteBuffer buffer)
134 {
135 return EncodingUtils.readShort(buffer);
136 }
137
138 protected void writeShort(ByteBuffer buffer, short s)
139 {
140 EncodingUtils.writeShort(buffer, s);
141 }
142
143 protected Content readContent(ByteBuffer buffer)
144 {
145 return null; //To change body of created methods use File | Settings | File Templates.
146 }
147
148 protected int getSizeOf(Content body)
149 {
150 return 0; //To change body of created methods use File | Settings | File Templates.
151 }
152
153 protected void writeContent(ByteBuffer buffer, Content body)
154 {
155 //To change body of created methods use File | Settings | File Templates.
156 }
157
158 protected byte readBitfield(ByteBuffer buffer)
159 {
160 return readByte(buffer); //To change body of created methods use File | Settings | File Templates.
161 }
162
163 protected int readUnsignedShort(ByteBuffer buffer)
164 {
165 return buffer.getUnsignedShort(); //To change body of created methods use File | Settings | File Templates.
166 }
167
168 protected void writeBitfield(ByteBuffer buffer, byte bitfield0)
169 {
170 buffer.put(bitfield0);
171 }
172
173 protected void writeUnsignedShort(ByteBuffer buffer, int s)
174 {
175 EncodingUtils.writeUnsignedShort(buffer, s);
176 }
177
178 protected long readUnsignedInteger(ByteBuffer buffer)
179 {
180 return buffer.getUnsignedInt();
181 }
182 protected void writeUnsignedInteger(ByteBuffer buffer, long i)
183 {
184 EncodingUtils.writeUnsignedInteger(buffer, i);
185 }
186
187
188 protected short readUnsignedByte(ByteBuffer buffer)
189 {
190 return buffer.getUnsigned();
191 }
192
193 protected void writeUnsignedByte(ByteBuffer buffer, short unsignedByte)
194 {
195 EncodingUtils.writeUnsignedByte(buffer, unsignedByte);
196 }
197
198 protected long readTimestamp(ByteBuffer buffer)
199 {
200 return EncodingUtils.readTimestamp(buffer);
201 }
202
203 protected void writeTimestamp(ByteBuffer buffer, long t)
204 {
205 EncodingUtils.writeTimestamp(buffer, t);
206 }
207
208
209 }
|