[jboss-svn-commits] JBL Code SVN: r12436 - labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Jun 9 15:13:55 EDT 2007


Author: mark.little at jboss.com
Date: 2007-06-09 15:13:55 -0400 (Sat, 09 Jun 2007)
New Revision: 12436

Modified:
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
Log:
http://jira.jboss.com/jira/browse/JBESB-612

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java	2007-06-09 19:13:39 UTC (rev 12435)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java	2007-06-09 19:13:55 UTC (rev 12436)
@@ -35,150 +35,149 @@
 
 public class BodyImpl implements Body, java.io.Serializable
 {
-	private static final long serialVersionUID = 0x0;
-	
-	public BodyImpl ()
+    private static final long serialVersionUID = 0x0;
+
+    public BodyImpl()
+    {
+	_content = null;
+	_objects = new Hashtable<String, Serializable>();
+    }
+
+    public void setByteArray (byte[] content)
+    {
+	_content = content;
+    }
+
+    public byte[] getByteArray ()
+    {
+	return _content;
+    }
+
+    public void setContents (byte[] content)
+    {
+	setByteArray(content);
+    }
+
+    public byte[] getContents ()
+    {
+	return getByteArray();
+    }
+
+    public void add (Object value)
+    {
+	add(Body.DEFAULT_LOCATION, value);
+    }
+
+    public void add (String name, Object value)
+    {
+	AssertArgument.isNotNull(value, "value");
+	AssertArgument.isNotNull(name, "name");
+
+	if (value instanceof Serializable)
 	{
-		_content = null;
-		_objects = new Hashtable<String, Serializable>();
+	    synchronized (_objects)
+	    {
+		_objects.put(name, (Serializable) value);
+	    }
 	}
+	else
+	    throw new IllegalArgumentException("Object must be Serializable.");
+    }
+
+    public Object get ()
+    {
+	return get(Body.DEFAULT_LOCATION);
+    }
+
+    public Object get (String name)
+    {
+	AssertArgument.isNotNull(name, "name");
 	
-	public void setByteArray (byte[] content)
+	synchronized (_objects)
 	{
-		_content = content;
+	    return _objects.get(name);
 	}
+    }
 
-	public byte[] getByteArray ()
+    public String[] getNames ()
+    {
+	Set<String> keys = _objects.keySet();
+
+	if (keys != null)
 	{
-		return _content;
+	    String[] toReturn = new String[keys.size()];
+
+	    return keys.toArray(toReturn);
 	}
-	
-	public void setContents (byte[] content)
+	else
+	    return null;
+    }
+
+    public Object remove (String name)
+    {
+	synchronized (_objects)
 	{
-		setByteArray(content);
+	    return _objects.remove(name);
 	}
+    }
 
-	public byte[] getContents ()
+    public void replace (Body b)
+    {
+	if (b == null)
+	    throw new IllegalArgumentException();
+
+	setByteArray(b.getByteArray());
+
+	_objects = ((BodyImpl) b)._objects;
+    }
+
+    public void merge (Body b)
+    {
+	if (b == null)
+	    throw new IllegalArgumentException();
+
+	byte[] toAdd = b.getByteArray();
+
+	if ((toAdd != null) && (toAdd.length > 0))
 	{
-		return getByteArray();
+	    if ((_content == null) || (_content.length == 0))
+	    {
+		_content = toAdd;
+	    }
+	    else
+	    {
+		int newSize = _content.length + toAdd.length;
+		byte[] buffer = new byte[newSize];
+
+		System.arraycopy(_content, 0, buffer, 0, _content.length);
+		System.arraycopy(toAdd, 0, buffer, _content.length,
+			toAdd.length);
+
+		_content = buffer;
+	    }
 	}
-	
-	public void add (Object value)
+    }
+
+    public String toString ()
+    {
+	String toReturn = "body: [ ";
+
+	if (_content != null)
+	    toReturn += "byte[]: " + Util.format(new String(_content));
+
+	if (_objects != null)
 	{
-		add(Body.DEFAULT_LOCATION, value);
-	}
-	
-	public void add (String name, Object value)
-	{
-        AssertArgument.isNotNull(value, "value");
-        if (name == null) {
-			name = Body.DEFAULT_LOCATION;
-        }
+	    if (_content != null)
+		toReturn += ", ";
 
-        if (value instanceof Serializable)
-		{
-			synchronized (_objects)
-			{
-				_objects.put(name, (Serializable) value);
-			}
-		}
-		else
-			throw new IllegalArgumentException("Object must be Serializable.");
+	    toReturn += "objects: " + _objects.toString();
 	}
-	
-	public Object get ()
-	{
-		return get(Body.DEFAULT_LOCATION);
-	}
-	
-	public Object get (String name)
-	{
-        if (name == null) {
-			name = Body.DEFAULT_LOCATION;
-        }
-		synchronized (_objects)
-		{
-			return _objects.get(name);
-		}
-	}
-	
-	public String[] getNames ()
-	{
-		Set<String> keys = _objects.keySet();
-		
-		if (keys != null)
-		{
-			String[] toReturn = new String[keys.size()];
-		
-			return keys.toArray(toReturn);
-		}
-		else
-			return null;
-	}
-	
-	public Object remove (String name)
-	{
-		synchronized (_objects)
-		{
-			return _objects.remove(name);
-		}
-	}
-	
-	public void replace (Body b)
-	{
-		if (b == null)
-			throw new IllegalArgumentException();
-		
-		setByteArray(b.getByteArray());
-		
-		_objects = ((BodyImpl) b)._objects;
-	}
-	
-	public void merge (Body b)
-	{
-		if (b == null)
-			throw new IllegalArgumentException();
-		
-		byte[] toAdd = b.getByteArray();
-		
-		if ((toAdd != null) && (toAdd.length > 0))
-		{
-			if ((_content == null) || (_content.length == 0))
-			{
-				_content = toAdd;
-			}
-			else
-			{
-				int newSize = _content.length + toAdd.length;
-				byte[] buffer = new byte[newSize];
-				
-				System.arraycopy(_content, 0, buffer, 0, _content.length);
-				System.arraycopy(toAdd, 0, buffer, _content.length, toAdd.length);
-				
-				_content = buffer;
-			}
-		}
-	}
-	
-	public String toString ()
-	{
-		String toReturn = "body: [ ";
-		
-		if (_content != null)
-			toReturn += "byte[]: "+Util.format(new String(_content));
-		
-		if (_objects != null)
-		{
-			if (_content != null)
-				toReturn += ", ";
-			
-			toReturn += "objects: "+_objects.toString();
-		}
-		
-		return toReturn+" ]";
-	}
-	
-	private byte[] _content;
-	private Hashtable<String, Serializable> _objects;
-	
+
+	return toReturn + " ]";
+    }
+
+    private byte[] _content;
+
+    private Hashtable<String, Serializable> _objects;
+
 }
\ No newline at end of file




More information about the jboss-svn-commits mailing list