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 package org.apache.qpid.client.message;
022
023 import javax.jms.JMSException;
024 import javax.jms.StreamMessage;
025
026 import org.apache.mina.common.ByteBuffer;
027 import org.apache.qpid.AMQException;
028 import org.apache.qpid.framing.AMQShortString;
029 import org.apache.qpid.framing.BasicContentHeaderProperties;
030
031 /**
032 * @author Apache Software Foundation
033 */
034 public class JMSStreamMessage extends AbstractBytesTypedMessage implements StreamMessage
035 {
036 public static final String MIME_TYPE="jms/stream-message";
037
038
039
040 /**
041 * This is set when reading a byte array. The readBytes(byte[]) method supports multiple calls to read
042 * a byte array in multiple chunks, hence this is used to track how much is left to be read
043 */
044 private int _byteArrayRemaining = -1;
045
046 public JMSStreamMessage(AMQMessageDelegateFactory delegateFactory)
047 {
048 this(delegateFactory,null);
049
050 }
051
052 /**
053 * Construct a stream message with existing data.
054 *
055 * @param delegateFactory
056 * @param data the data that comprises this message. If data is null, you get a 1024 byte buffer that is
057 */
058 JMSStreamMessage(AMQMessageDelegateFactory delegateFactory, ByteBuffer data)
059 {
060
061 super(delegateFactory, data); // this instanties a content header
062 }
063
064 JMSStreamMessage(AMQMessageDelegate delegate, ByteBuffer data) throws AMQException
065 {
066
067 super(delegate, data);
068 }
069
070
071 public void reset()
072 {
073 super.reset();
074 _readableMessage = true;
075 }
076
077 protected String getMimeType()
078 {
079 return MIME_TYPE;
080 }
081
082
083
084 public boolean readBoolean() throws JMSException
085 {
086 return super.readBoolean();
087 }
088
089
090 public byte readByte() throws JMSException
091 {
092 return super.readByte();
093 }
094
095 public short readShort() throws JMSException
096 {
097 return super.readShort();
098 }
099
100 /**
101 * Note that this method reads a unicode character as two bytes from the stream
102 *
103 * @return the character read from the stream
104 * @throws JMSException
105 */
106 public char readChar() throws JMSException
107 {
108 return super.readChar();
109 }
110
111 public int readInt() throws JMSException
112 {
113 return super.readInt();
114 }
115
116 public long readLong() throws JMSException
117 {
118 return super.readLong();
119 }
120
121 public float readFloat() throws JMSException
122 {
123 return super.readFloat();
124 }
125
126 public double readDouble() throws JMSException
127 {
128 return super.readDouble();
129 }
130
131 public String readString() throws JMSException
132 {
133 return super.readString();
134 }
135
136 public int readBytes(byte[] bytes) throws JMSException
137 {
138 return super.readBytes(bytes);
139 }
140
141
142 public Object readObject() throws JMSException
143 {
144 return super.readObject();
145 }
146
147 public void writeBoolean(boolean b) throws JMSException
148 {
149 super.writeBoolean(b);
150 }
151
152 public void writeByte(byte b) throws JMSException
153 {
154 super.writeByte(b);
155 }
156
157 public void writeShort(short i) throws JMSException
158 {
159 super.writeShort(i);
160 }
161
162 public void writeChar(char c) throws JMSException
163 {
164 super.writeChar(c);
165 }
166
167 public void writeInt(int i) throws JMSException
168 {
169 super.writeInt(i);
170 }
171
172 public void writeLong(long l) throws JMSException
173 {
174 super.writeLong(l);
175 }
176
177 public void writeFloat(float v) throws JMSException
178 {
179 super.writeFloat(v);
180 }
181
182 public void writeDouble(double v) throws JMSException
183 {
184 super.writeDouble(v);
185 }
186
187 public void writeString(String string) throws JMSException
188 {
189 super.writeString(string);
190 }
191
192 public void writeBytes(byte[] bytes) throws JMSException
193 {
194 super.writeBytes(bytes);
195 }
196
197 public void writeBytes(byte[] bytes, int offset, int length) throws JMSException
198 {
199 super.writeBytes(bytes,offset,length);
200 }
201
202 public void writeObject(Object object) throws JMSException
203 {
204 super.writeObject(object);
205 }
206 }
|