Message.java
001 package org.apache.qpid.api;
002 
003 import java.io.IOException;
004 import java.nio.ByteBuffer;
005 
006 import org.apache.qpid.transport.MessageProperties;
007 import org.apache.qpid.transport.DeliveryProperties;
008 import org.apache.qpid.transport.Header;
009 
010 /*
011  * Licensed to the Apache Software Foundation (ASF) under one
012  * or more contributor license agreements.  See the NOTICE file
013  * distributed with this work for additional information
014  * regarding copyright ownership.  The ASF licenses this file
015  * to you under the Apache License, Version 2.0 (the
016  * "License"); you may not use this file except in compliance
017  * with the License.  You may obtain a copy of the License at
018  *
019  *   http://www.apache.org/licenses/LICENSE-2.0
020  *
021  * Unless required by applicable law or agreed to in writing,
022  * software distributed under the License is distributed on an
023  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
024  * KIND, either express or implied.  See the License for the
025  * specific language governing permissions and limitations
026  * under the License.
027  */
028 
029 public interface Message
030 {
031     public Header getHeader();
032 
033     public void setHeader(Header header);
034 
035     public MessageProperties getMessageProperties();
036 
037   public DeliveryProperties getDeliveryProperties();
038 
039   /**
040    * This will abstract the underlying message data.
041    * The Message implementation may not hold all message
042    * data in memory (especially in the case of large messages)
043    *
044    * The appendData function might write data to
045    <ul>
046    <li> Memory (Ex: ByteBuffer)
047    <li> To Disk
048    <li> To Socket (Stream)
049    </ul>
050    @param src - the data to append
051    */
052   public void appendData(byte[] srcthrows IOException;
053 
054 
055     /**
056      * This will abstract the underlying message data.
057      * The Message implementation may not hold all message
058      * data in memory (especially in the case of large messages)
059      *
060      * The appendData function might write data to
061      <ul>
062      <li> Memory (Ex: ByteBuffer)
063      <li> To Disk
064      <li> To Socket (Stream)
065      </ul>
066      @param src - the data to append
067      */
068     public void appendData(ByteBuffer srcthrows IOException;
069 
070   /**
071    * This will abstract the underlying message data.
072    * The Message implementation may not hold all message
073    * data in memory (especially in the case of large messages)
074    *
075    * The read function might copy data from
076    <ul>
077    <li> From memory (Ex: ByteBuffer)
078    <li> From Disk
079    <li> From Socket as and when it gets streamed
080    </ul>
081    @param target  The target byte[] which the data gets copied to
082    */
083     public void readData(byte[] targetthrows IOException;
084 
085     /**
086      * * This will abstract the underlying message data.
087      * The Message implementation may not hold all message
088      * data in memory (especially in the case of large messages)
089      *
090      * The read function might copy data from
091      <ul>
092      <li> From memory (Ex: ByteBuffer)
093      <li> From Disk
094      <li> From Socket as and when it gets streamed
095      </ul>
096      *
097      @return A ByteBuffer containing data
098      @throws IOException
099      */
100     public ByteBuffer readData() throws IOException;
101 
102     /**
103      * This should clear the body of the message.
104      */
105     public void clearData();
106 
107     /**
108      * The provides access to the command Id assigned to the
109      * message transfer.
110      * This id is useful when you do
111      <ul>
112      <li>For message acquiring - If the transfer happend in no-acquire mode
113      *     you could use this id to accquire it.
114      <li>For releasing a message. You can use this id to release an acquired
115      *     message
116      <li>For Acknowledging a message - You need to pass this ID, in order to
117      *     acknowledge the message
118      <li>For Rejecting a message - You need to pass this ID, in order to reject
119      *     the message.
120      </ul>
121      *
122      @return the message transfer id.
123      */
124     public int getMessageTransferId();
125 
126 }