AMQMethodBody.java
01 /*
02  *
03  * Licensed to the Apache Software Foundation (ASF) under one
04  * or more contributor license agreements.  See the NOTICE file
05  * distributed with this work for additional information
06  * regarding copyright ownership.  The ASF licenses this file
07  * to you under the Apache License, Version 2.0 (the
08  * "License"); you may not use this file except in compliance
09  * with the License.  You may obtain a copy of the License at
10  
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  */
21 package org.apache.qpid.framing;
22 
23 import org.apache.mina.common.ByteBuffer;
24 import org.apache.qpid.AMQChannelException;
25 import org.apache.qpid.AMQConnectionException;
26 import org.apache.qpid.AMQException;
27 import org.apache.qpid.protocol.AMQConstant;
28 
29 public interface AMQMethodBody extends AMQBody
30 {
31     public static final byte TYPE = 1;
32 
33     /** AMQP version */
34     public byte getMajor();
35 
36     public byte getMinor();
37 
38 
39 
40     /** @return unsigned short */
41     public int getClazz();
42 
43     /** @return unsigned short */
44     public int getMethod();
45 
46     public void writeMethodPayload(ByteBuffer buffer);
47 
48 
49     public int getSize();
50 
51     public void writePayload(ByteBuffer buffer);
52 
53     //public abstract void populateMethodBodyFromBuffer(ByteBuffer buffer) throws AMQFrameDecodingException;
54 
55     //public void populateFromBuffer(ByteBuffer buffer, long size) throws AMQFrameDecodingException;
56 
57     public AMQFrame generateFrame(int channelId);
58 
59     public String toString();
60 
61 
62 
63     /**
64      * Convenience Method to create a channel not found exception
65      *
66      @param channelId The channel id that is not found
67      *
68      @return new AMQChannelException
69      */
70     public AMQChannelException getChannelNotFoundException(int channelId);
71 
72     public AMQChannelException getChannelException(AMQConstant code, String message);
73 
74     public AMQChannelException getChannelException(AMQConstant code, String message, Throwable cause);
75 
76     public AMQConnectionException getConnectionException(AMQConstant code, String message);
77 
78 
79     public AMQConnectionException getConnectionException(AMQConstant code, String message, Throwable cause);
80 
81 
82     public boolean execute(MethodDispatcher methodDispatcher, int channelIdthrows AMQException;
83 }