diff options
Diffstat (limited to 'java/common/src')
| -rw-r--r-- | java/common/src/main/java/org/apache/qpid/framing/Content.java | 15 |
1 files changed, 14 insertions, 1 deletions
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; } |
