From 844e632c013affdfd028704a195a746f6973ebb2 Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Wed, 17 Jan 2007 19:49:40 +0000 Subject: Conversion of client/BasicMessageProducer to new Message class git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@497138 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/qpid/framing/Content.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'java/common/src') diff --git a/java/common/src/main/java/org/apache/qpid/framing/Content.java b/java/common/src/main/java/org/apache/qpid/framing/Content.java index bfc6ad6e87..d1d8c66995 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/Content.java +++ b/java/common/src/main/java/org/apache/qpid/framing/Content.java @@ -24,7 +24,7 @@ import org.apache.mina.common.ByteBuffer; public class Content { - enum ContentTypeEnum + public enum ContentTypeEnum { CONTENT_TYPE_INLINE((byte)0), CONTENT_TYPE_REFERENCE((byte)1); private byte type; @@ -79,6 +79,19 @@ public class Content this.content = content.getBytes(); } + public Content(ContentTypeEnum contentType, ByteBuffer content) + { + if (contentType == ContentTypeEnum.CONTENT_TYPE_REFERENCE) + { + if (content == null) + throw new IllegalArgumentException("Content cannot be null for a ref type."); + if (content.array().length == 0) + throw new IllegalArgumentException("Content cannot be empty for a ref type."); + } + this.contentType = contentType; + this.content = content.array(); + } + // Get functions public ContentTypeEnum getContentType() { return contentType; } -- cgit v1.2.1