[jboss-svn-commits] JBL Code SVN: r9368 - labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Feb 6 05:58:47 EST 2007
Author: mark.little at jboss.com
Date: 2007-02-06 05:58:47 -0500 (Tue, 06 Feb 2007)
New Revision: 9368
Modified:
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java
Log:
http://jira.jboss.com/jira/browse/JBESB-383
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java 2007-02-06 09:54:06 UTC (rev 9367)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java 2007-02-06 10:58:47 UTC (rev 9368)
@@ -38,6 +38,12 @@
{
public static final String PROPERTIES_TAG = "Properties";
+ public static final String PROPERTY_TAG = "Property";
+
+ public static final String KEY_TAG = "Key";
+
+ public static final String VALUE_TAG = "Value";
+
public Object getProperty(String name)
{
return _table.get(name);
@@ -62,7 +68,10 @@
return _table.remove(name);
}
- public int size() {return _table.size(); }
+ public int size()
+ {
+ return _table.size();
+ }
public String[] getNames()
{
@@ -89,9 +98,16 @@
boolean bAdd = false;
for (Map.Entry<String, Serializable> oCurr : _table.entrySet())
{
- Element oProp = doc.createElement(oCurr.getKey());
- oProp.appendChild(doc.createCDATASection(Base64.encodeObject(oCurr
- .getValue())));
+ Element oProp = doc.createElement(PROPERTY_TAG);
+ Element keyElement = doc.createElement(KEY_TAG);
+ Element valueElement = doc.createElement(VALUE_TAG);
+
+ keyElement.appendChild(doc.createCDATASection(Base64.encodeBytes(oCurr.getKey().getBytes())));
+ oProp.appendChild(keyElement);
+
+ valueElement.appendChild(doc.createCDATASection(Base64.encodeObject(oCurr.getValue())));
+ oProp.appendChild(valueElement);
+
thisElement.appendChild(oProp);
bAdd = true;
}
@@ -115,22 +131,57 @@
{
_table.clear();
+ /*
+ * There should be only one!
+ */
+
NodeList NL = elem.getElementsByTagName(PROPERTIES_TAG);
+
+ if (NL.getLength() > 1)
+ throw new UnmarshalException("More "+PROPERTIES_TAG+" than we expected!");
+
+ if (NL.getLength() == 1)
+ NL = NL.item(0).getChildNodes();
+
for (int i1 = 0; i1 < NL.getLength(); i1++)
{
Node oCurr = NL.item(i1);
+
if (!(oCurr instanceof Element))
continue;
- NodeList props = oCurr.getChildNodes();
- for (int i2 = 0; i2 < props.getLength(); i2++)
+
+ if (oCurr.getNodeName().equals(PROPERTY_TAG))
{
- Node oProp = props.item(i2);
- if (oProp instanceof Element)
+ NodeList props = oCurr.getChildNodes();
+ String key = null;
+ Object value = null;
+
+ for (int i2 = 0; i2 < props.getLength(); i2++)
{
- CDATASection cdata = (CDATASection) oProp.getFirstChild();
- Object value = Base64.decodeToObject(cdata.getWholeText());
- _table.put(oProp.getNodeName(), (Serializable) value);
+ Node oProp = props.item(i2);
+
+ if (oProp instanceof Element)
+ {
+ if (oProp.getNodeName().equals(VALUE_TAG))
+ {
+ CDATASection cdata = (CDATASection) oProp.getFirstChild();
+ value = Base64.decodeToObject(cdata.getWholeText());
+ }
+ else
+ {
+ if (oProp.getNodeName().equals(KEY_TAG))
+ {
+ CDATASection cdata = (CDATASection) oProp.getFirstChild();
+ key = new String(Base64.decode(cdata.getWholeText()));
+ }
+ }
+ }
}
+
+ if ((key != null) && (value != null))
+ _table.put(key, (Serializable) value);
+ else
+ throw new UnmarshalException("Could not get tuple for "+oCurr.getNodeName());
}
}
}
@@ -143,16 +194,16 @@
@Override
public boolean equals(Object arg)
{
- if (! (arg instanceof Properties))
+ if (!(arg instanceof Properties))
return false;
- Properties other = (Properties)arg;
+ Properties other = (Properties) arg;
if (other.size() != _table.size())
return false;
- for(Map.Entry<String,Serializable>oCurr : _table.entrySet())
- {
+ for (Map.Entry<String, Serializable> oCurr : _table.entrySet())
+ {
Object val = other.getProperty(oCurr.getKey());
- if (null==oCurr.getValue())
- if (null==val)
+ if (null == oCurr.getValue())
+ if (null == val)
continue;
else
return false;
More information about the jboss-svn-commits
mailing list