You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by du...@apache.org on 2001/05/17 23:08:39 UTC
cvs commit: xml-soap/java/src/org/apache/soap/encoding/soapenc MapSerializer.java
duftler 01/05/17 14:08:38
Modified: java/src/org/apache/soap/encoding/soapenc MapSerializer.java
Log:
Cleaned up formatting.
Revision Changes Path
1.7 +66 -56 xml-soap/java/src/org/apache/soap/encoding/soapenc/MapSerializer.java
Index: MapSerializer.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/MapSerializer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MapSerializer.java 2001/05/11 17:38:12 1.6
+++ MapSerializer.java 2001/05/17 21:08:33 1.7
@@ -87,10 +87,11 @@
XMLJavaMappingRegistry xjmr, SOAPContext ctx)
throws IllegalArgumentException, IOException
{
- if ((src != null) &&
- !(src instanceof Hashtable))
+ if ((src != null) && !(src instanceof Hashtable))
+ {
throw new IllegalArgumentException("Tried to pass a '" +
src.getClass().toString() + "' to MapSerializer");
+ }
if (src == null)
{
@@ -112,20 +113,20 @@
sink.write(StringUtils.lineSeparator);
- Hashtable hash = (Hashtable)src;
-
+ Hashtable hash = (Hashtable)src;
+
for (Enumeration e = hash.keys(); e.hasMoreElements(); )
{
Object key = e.nextElement();
- Object value = hash.get(key);
-
- sink.write("<" + STR_ITEM + ">");
- sink.write(StringUtils.lineSeparator);
-
- // ??? Deal with null keys?
- xjmr.marshall(inScopeEncStyle, key.getClass(), key, STR_KEY,
- sink, nsStack, ctx);
- sink.write(StringUtils.lineSeparator);
+ Object value = hash.get(key);
+
+ sink.write("<" + STR_ITEM + ">");
+ sink.write(StringUtils.lineSeparator);
+
+ // ??? Deal with null keys?
+ xjmr.marshall(inScopeEncStyle, key.getClass(), key, STR_KEY,
+ sink, nsStack, ctx);
+ sink.write(StringUtils.lineSeparator);
if (value == null)
{
@@ -141,8 +142,8 @@
}
sink.write(StringUtils.lineSeparator);
- sink.write("</" + STR_ITEM + ">");
- sink.write(StringUtils.lineSeparator);
+ sink.write("</" + STR_ITEM + ">");
+ sink.write(StringUtils.lineSeparator);
}
sink.write("</" + context + '>');
@@ -153,53 +154,62 @@
XMLJavaMappingRegistry xjmr, SOAPContext ctx)
throws IllegalArgumentException
{
- Element root = (Element)src;
- String name = root.getTagName();
+ Element root = (Element)src;
+ String name = root.getTagName();
+
+ if (SoapEncUtils.isNull(root))
+ {
+ return new Bean(Hashtable.class, null);
+ }
+
+ Hashtable hash = new Hashtable();
+ Element tempEl = DOMUtils.getFirstChildElement(root);
- if (SoapEncUtils.isNull(root))
- {
- return new Bean(Hashtable.class, null);
- }
-
- Hashtable hash = new Hashtable();
-
- Element tempEl = DOMUtils.getFirstChildElement(root);
- while (tempEl != null) {
- // got an item
- Element keyEl = DOMUtils.getFirstChildElement(tempEl);
- String tagName = keyEl.getTagName();
-
- if (!tagName.equalsIgnoreCase(STR_KEY))
- throw new IllegalArgumentException("Got <" + tagName +
- "> tag when expecting <" + STR_KEY + ">");
-
- Element valEl = DOMUtils.getNextSiblingElement(keyEl);
- tagName = valEl.getTagName();
- if (!tagName.equalsIgnoreCase("value"))
- throw new IllegalArgumentException("Got <" + tagName +
- "> tag when expecting <" + STR_VALUE + ">");
-
- Bean keyBean = unmarshallEl(inScopeEncStyle, xjmr, keyEl, ctx);
- Bean valBean = unmarshallEl(inScopeEncStyle, xjmr, valEl, ctx);
-
- hash.put(keyBean.value, valBean.value);
-
- tempEl = DOMUtils.getNextSiblingElement(tempEl);
- }
+ while (tempEl != null) {
+ // got an item
+ Element keyEl = DOMUtils.getFirstChildElement(tempEl);
+ String tagName = keyEl.getTagName();
- return new Bean(Hashtable.class, hash);
+ if (!tagName.equalsIgnoreCase(STR_KEY))
+ {
+ throw new IllegalArgumentException("Got <" + tagName +
+ "> tag when expecting <" +
+ STR_KEY + ">");
+ }
+
+ Element valEl = DOMUtils.getNextSiblingElement(keyEl);
+
+ tagName = valEl.getTagName();
+
+ if (!tagName.equalsIgnoreCase("value"))
+ {
+ throw new IllegalArgumentException("Got <" + tagName +
+ "> tag when expecting <" +
+ STR_VALUE + ">");
+ }
+
+ Bean keyBean = unmarshallEl(inScopeEncStyle, xjmr, keyEl, ctx);
+ Bean valBean = unmarshallEl(inScopeEncStyle, xjmr, valEl, ctx);
+
+ hash.put(keyBean.value, valBean.value);
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ return new Bean(Hashtable.class, hash);
}
private Bean unmarshallEl(String inScopeEncStyle,
XMLJavaMappingRegistry xjmr,
- Element targetEl, SOAPContext ctx) {
- String declEncStyle = DOMUtils.getAttributeNS(targetEl,
- Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE);
- String actualEncStyle = declEncStyle != null
- ? declEncStyle
- : inScopeEncStyle;
- QName declItemType = SoapEncUtils.getTypeQName(targetEl);
+ Element targetEl, SOAPContext ctx)
+ {
+ String declEncStyle = DOMUtils.getAttributeNS(targetEl,
+ Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE);
+ String actualEncStyle = (declEncStyle != null)
+ ? declEncStyle
+ : inScopeEncStyle;
+ QName declItemType = SoapEncUtils.getTypeQName(targetEl);
- return xjmr.unmarshall(actualEncStyle, declItemType, targetEl, ctx);
+ return xjmr.unmarshall(actualEncStyle, declItemType, targetEl, ctx);
}
}