Author: davsclaus
Date: Sat May 3 08:48:14 2008
New Revision: 653092
URL: http://svn.apache.org/viewvc?rev=653092&view=rev
Log:
Added hasAttachments() method
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Message.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Message.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Message.java?rev=653092&r1=653091&r2=653092&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Message.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Message.java
Sat May 3 08:48:14 2008
@@ -135,8 +135,9 @@
* Copies the contents of the other message into this message
*/
void copyFrom(Message message);
+
/**
- * returns the attachment specified by the id
+ * Returns the attachment specified by the id
*
* @param id the id under which the attachment is stored
* @return the data handler for this attachment or null
@@ -144,21 +145,21 @@
DataHandler getAttachment(String id);
/**
- * returns a set of attachment names of the message
+ * Returns a set of attachment names of the message
*
* @return a set of attachment names
*/
Set<String> getAttachmentNames();
/**
- * removes the attachment specified by the id
+ * Removes the attachment specified by the id
*
* @param id the id of the attachment to remove
*/
void removeAttachment(String id);
/**
- * adds an attachment to the message using the id
+ * Adds an attachment to the message using the id
*
* @param id the id to store the attachment under
* @param content the data handler for the attachment
@@ -166,7 +167,7 @@
void addAttachment(String id, DataHandler content);
/**
- * returns all attachments of the message
+ * Returns all attachments of the message
*
* @return the attachments in a map or null
*/
@@ -178,4 +179,9 @@
* @param attachments
*/
void setAttachments(Map<String, DataHandler> attachments);
+
+ /**
+ * Returns <tt>true</tt> if this message has any attachments.
+ */
+ boolean hasAttachments();
}
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java?rev=653092&r1=653091&r2=653092&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultMessage.java
Sat May 3 08:48:14 2008
@@ -122,9 +122,6 @@
protected void populateInitialAttachments(Map<String, DataHandler> map) {
}
- /* (non-Javadoc)
- * @see org.apache.camel.Message#addAttachment(java.lang.String,
javax.activation.DataHandler)
- */
public void addAttachment(String id, DataHandler content) {
if (attachments == null) {
attachments = createAttachments();
@@ -132,16 +129,10 @@
attachments.put(id, content);
}
- /* (non-Javadoc)
- * @see org.apache.camel.Message#getAttachment(java.lang.String)
- */
public DataHandler getAttachment(String id) {
return getAttachments().get(id);
}
- /* (non-Javadoc)
- * @see org.apache.camel.Message#getAttachmentNames()
- */
public Set<String> getAttachmentNames() {
if (attachments == null) {
attachments = createAttachments();
@@ -149,18 +140,12 @@
return attachments.keySet();
}
- /* (non-Javadoc)
- * @see org.apache.camel.Message#removeAttachment(java.lang.String)
- */
public void removeAttachment(String id) {
if (attachments != null && attachments.containsKey(id)) {
attachments.remove(id);
}
}
- /* (non-Javadoc)
- * @see org.apache.camel.Message#getAttachments()
- */
public Map<String, DataHandler> getAttachments() {
if (attachments == null) {
attachments = createAttachments();
@@ -168,17 +153,19 @@
return attachments;
}
- /* (non-Javadoc)
- * @see org.apache.camel.Message#setAttachments(java.util.Map)
- */
public void setAttachments(Map<String, DataHandler> attachments) {
this.attachments = attachments;
}
+ public boolean hasAttachments() {
+ return this.attachments != null && this.attachments.size() > 0;
+ }
+
/**
* Returns true if the headers have been mutated in some way
*/
protected boolean hasPopulatedHeaders() {
return headers != null;
}
+
}