summaryrefslogtreecommitdiff
path: root/java/java/client/src/org/apache/qpid/client/message/JMSTextMessage.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/java/client/src/org/apache/qpid/client/message/JMSTextMessage.java')
-rw-r--r--java/java/client/src/org/apache/qpid/client/message/JMSTextMessage.java162
1 files changed, 0 insertions, 162 deletions
diff --git a/java/java/client/src/org/apache/qpid/client/message/JMSTextMessage.java b/java/java/client/src/org/apache/qpid/client/message/JMSTextMessage.java
deleted file mode 100644
index 4983f6b623..0000000000
--- a/java/java/client/src/org/apache/qpid/client/message/JMSTextMessage.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.client.message;
-
-import org.apache.qpid.framing.BasicContentHeaderProperties;
-import org.apache.qpid.AMQException;
-import org.apache.mina.common.ByteBuffer;
-
-import javax.jms.JMSException;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.CharacterCodingException;
-
-public class JMSTextMessage extends AbstractJMSMessage implements javax.jms.TextMessage
-{
- private static final String MIME_TYPE = "text/plain";
-
- private String _decodedValue;
-
- JMSTextMessage() throws JMSException
- {
- this(null, null);
- }
-
- JMSTextMessage(ByteBuffer data, String encoding) throws JMSException
- {
- super(data); // this instantiates a content header
- getJmsContentHeaderProperties().setContentType(MIME_TYPE);
- getJmsContentHeaderProperties().setEncoding(encoding);
- }
-
- JMSTextMessage(long deliveryTag, ByteBuffer data, BasicContentHeaderProperties contentHeader)
- throws AMQException
- {
- super(deliveryTag, contentHeader, data);
- contentHeader.setContentType(MIME_TYPE);
- _data = data;
- }
-
- JMSTextMessage(ByteBuffer data) throws JMSException
- {
- this(data, null);
- }
-
- JMSTextMessage(String text) throws JMSException
- {
- super((ByteBuffer)null);
- setText(text);
- }
-
- public void clearBody() throws JMSException
- {
- if (_data != null)
- {
- _data.release();
- }
- _data = null;
- _decodedValue = null;
- }
-
- public String toBodyString() throws JMSException
- {
- return getText();
- }
-
- public void setData(ByteBuffer data)
- {
- _data = data;
- }
-
- public String getMimeType()
- {
- return MIME_TYPE;
- }
-
- public void setText(String string) throws JMSException
- {
- clearBody();
- try
- {
- _data = ByteBuffer.allocate(string.length());
- _data.limit(string.length());
- //_data.sweep();
- _data.setAutoExpand(true);
- if (getJmsContentHeaderProperties().getEncoding() == null)
- {
- _data.put(string.getBytes());
- }
- else
- {
- _data.put(string.getBytes(getJmsContentHeaderProperties().getEncoding()));
- }
- _decodedValue = string;
- }
- catch (UnsupportedEncodingException e)
- {
- // should never occur
- throw new JMSException("Unable to decode string data");
- }
- }
-
- public String getText() throws JMSException
- {
- if (_data == null && _decodedValue == null)
- {
- return null;
- }
- else if (_decodedValue != null)
- {
- return _decodedValue;
- }
- else
- {
- _data.rewind();
- if (getJmsContentHeaderProperties().getEncoding() != null)
- {
- try
- {
- _decodedValue = _data.getString(Charset.forName(getJmsContentHeaderProperties().getEncoding()).newDecoder());
- }
- catch (CharacterCodingException e)
- {
- JMSException je = new JMSException("Could not decode string data: " + e);
- je.setLinkedException(e);
- throw je;
- }
- }
- else
- {
- try
- {
- _decodedValue = _data.getString(Charset.defaultCharset().newDecoder());
- }
- catch (CharacterCodingException e)
- {
- JMSException je = new JMSException("Could not decode string data: " + e);
- je.setLinkedException(e);
- throw je;
- }
- }
- return _decodedValue;
- }
- }
-}