summaryrefslogtreecommitdiff
path: root/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java')
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java141
1 files changed, 72 insertions, 69 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
index 2739f7d14b..eb528159c0 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
@@ -20,14 +20,13 @@
*/
package org.apache.qpid.framing;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.DataInput;
-import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.IOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
public class BasicContentHeaderProperties implements CommonContentHeaderProperties
{
//persistent & non-persistent constants, values as per JMS DeliveryMode
@@ -89,7 +88,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti
public int getPropertyListSize()
{
- if(_encodedForm != null && (_headers == null || _headers.isClean()))
+ if(useEncodedForm())
{
return _encodedForm.length;
}
@@ -190,7 +189,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti
public void writePropertyListPayload(DataOutput buffer) throws IOException
{
- if(_encodedForm != null && (_headers == null || !_headers.isClean()))
+ if(useEncodedForm())
{
buffer.write(_encodedForm);
}
@@ -295,85 +294,83 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti
private void decode(ByteArrayDataInput buffer) throws IOException, AMQFrameDecodingException
{
- // ByteBuffer buffer = ByteBuffer.wrap(_encodedForm);
+ int headersOffset = 0;
- int headersOffset = 0;
-
- if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0)
- {
- _contentType = buffer.readAMQShortString();
- headersOffset += EncodingUtils.encodedShortStringLength(_contentType);
- }
+ if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0)
+ {
+ _contentType = buffer.readAMQShortString();
+ headersOffset += EncodingUtils.encodedShortStringLength(_contentType);
+ }
- if ((_propertyFlags & ENCODING_MASK) != 0)
- {
- _encoding = buffer.readAMQShortString();
- headersOffset += EncodingUtils.encodedShortStringLength(_encoding);
- }
+ if ((_propertyFlags & ENCODING_MASK) != 0)
+ {
+ _encoding = buffer.readAMQShortString();
+ headersOffset += EncodingUtils.encodedShortStringLength(_encoding);
+ }
- if ((_propertyFlags & HEADERS_MASK) != 0)
- {
- long length = EncodingUtils.readUnsignedInteger(buffer);
+ if ((_propertyFlags & HEADERS_MASK) != 0)
+ {
+ long length = EncodingUtils.readUnsignedInteger(buffer);
- _headers = new FieldTable(_encodedForm, headersOffset+4, (int)length);
+ _headers = new FieldTable(_encodedForm, headersOffset+4, (int)length);
- buffer.skipBytes((int)length);
- }
+ buffer.skipBytes((int)length);
+ }
- if ((_propertyFlags & DELIVERY_MODE_MASK) != 0)
- {
- _deliveryMode = buffer.readByte();
- }
+ if ((_propertyFlags & DELIVERY_MODE_MASK) != 0)
+ {
+ _deliveryMode = buffer.readByte();
+ }
- if ((_propertyFlags & PRIORITY_MASK) != 0)
- {
- _priority = buffer.readByte();
- }
+ if ((_propertyFlags & PRIORITY_MASK) != 0)
+ {
+ _priority = buffer.readByte();
+ }
- if ((_propertyFlags & CORRELATION_ID_MASK) != 0)
- {
- _correlationId = buffer.readAMQShortString();
- }
+ if ((_propertyFlags & CORRELATION_ID_MASK) != 0)
+ {
+ _correlationId = buffer.readAMQShortString();
+ }
- if ((_propertyFlags & REPLY_TO_MASK) != 0)
- {
- _replyTo = buffer.readAMQShortString();
- }
+ if ((_propertyFlags & REPLY_TO_MASK) != 0)
+ {
+ _replyTo = buffer.readAMQShortString();
+ }
- if ((_propertyFlags & EXPIRATION_MASK) != 0)
- {
- _expiration = EncodingUtils.readLongAsShortString(buffer);
- }
+ if ((_propertyFlags & EXPIRATION_MASK) != 0)
+ {
+ _expiration = EncodingUtils.readLongAsShortString(buffer);
+ }
- if ((_propertyFlags & MESSAGE_ID_MASK) != 0)
- {
- _messageId = buffer.readAMQShortString();
- }
+ if ((_propertyFlags & MESSAGE_ID_MASK) != 0)
+ {
+ _messageId = buffer.readAMQShortString();
+ }
- if ((_propertyFlags & TIMESTAMP_MASK) != 0)
- {
- _timestamp = EncodingUtils.readTimestamp(buffer);
- }
+ if ((_propertyFlags & TIMESTAMP_MASK) != 0)
+ {
+ _timestamp = EncodingUtils.readTimestamp(buffer);
+ }
- if ((_propertyFlags & TYPE_MASK) != 0)
- {
- _type = buffer.readAMQShortString();
- }
+ if ((_propertyFlags & TYPE_MASK) != 0)
+ {
+ _type = buffer.readAMQShortString();
+ }
- if ((_propertyFlags & USER_ID_MASK) != 0)
- {
- _userId = buffer.readAMQShortString();
- }
+ if ((_propertyFlags & USER_ID_MASK) != 0)
+ {
+ _userId = buffer.readAMQShortString();
+ }
- if ((_propertyFlags & APPLICATION_ID_MASK) != 0)
- {
- _appId = buffer.readAMQShortString();
- }
+ if ((_propertyFlags & APPLICATION_ID_MASK) != 0)
+ {
+ _appId = buffer.readAMQShortString();
+ }
- if ((_propertyFlags & CLUSTER_ID_MASK) != 0)
- {
- _clusterId = buffer.readAMQShortString();
- }
+ if ((_propertyFlags & CLUSTER_ID_MASK) != 0)
+ {
+ _clusterId = buffer.readAMQShortString();
+ }
}
@@ -655,4 +652,10 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti
+ _expiration + ",JMSPriority = " + _priority + ",JMSTimestamp = " + _timestamp + ",JMSType = " + _type;
}
+ private boolean useEncodedForm()
+ {
+ return _encodedForm != null && (_headers == null || _headers.isClean());
+ }
+
+
}