unicorn commit: ~ change type of mapOfCallParameter to an ArrayList to allow several parameters with the same name (keys were useless here)

changeset:   1480:64aa677ff0e8
tag:         tip
user:        Thomas Gambet <tgambet@w3.org>
date:        Wed Sep 08 15:55:10 2010 -0400
files:       src/org/w3c/unicorn/UnicornCall.java src/org/w3c/unicorn/contract/CallMethod.java src/org/w3c/unicorn/contract/WADLUnmarshallerXPath.java
description:
~ change type of mapOfCallParameter to an ArrayList to allow several parameters with the same name (keys were useless here)


diff -r 3703fcba4aeb -r 64aa677ff0e8 src/org/w3c/unicorn/UnicornCall.java
--- a/src/org/w3c/unicorn/UnicornCall.java	Tue Sep 07 13:06:32 2010 -0400
+++ b/src/org/w3c/unicorn/UnicornCall.java	Wed Sep 08 15:55:10 2010 -0400
@@ -98,7 +98,7 @@
 		logger.debug("Map of string parameter : " + mapOfStringParameter + ".");
 		
 		MimeType aMimeType = inputParameter.getMimeType();
-		if (!aTask.getSupportedMimeTypes().contains(aMimeType.toString()))
+		if (aMimeType != null && !aTask.getSupportedMimeTypes().contains(aMimeType.toString()))
 			throw new UnicornException(Message.ERROR, "$message_unsupported_mime_type", null, aMimeType.toString());
 		
 		doNode(inputParameter, aTask.getTree());
@@ -212,8 +212,8 @@
 			aRequestList.addRequest(aRequest, aObserver.getID());
 
 			// Add fixed parameter
-			for (final CallParameter aCallParameter : aObserver.getCallMethod(
-					aInputMethod.getMethod()).getMapOfCallParameter().values()) {
+			for (final CallParameter aCallParameter : aObserver.getCallMethod(aInputMethod.getMethod())
+					.getListOfCallParameter()) {
 				if (aCallParameter.isRequired() && aCallParameter.isFixed()) {
 					aRequest.addParameter(aCallParameter.getName(),
 							aCallParameter.getFixed());
diff -r 3703fcba4aeb -r 64aa677ff0e8 src/org/w3c/unicorn/contract/CallMethod.java
--- a/src/org/w3c/unicorn/contract/CallMethod.java	Tue Sep 07 13:06:32 2010 -0400
+++ b/src/org/w3c/unicorn/contract/CallMethod.java	Wed Sep 08 15:55:10 2010 -0400
@@ -4,7 +4,7 @@
 package org.w3c.unicorn.contract;
 
 import java.net.URL;
-import java.util.Map;
+import java.util.ArrayList;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -44,8 +44,8 @@
 	/**
 	 * whether the call is sent or not
 	 */
-	private Map<String, CallParameter> mapOfCallParameter;
-
+	ArrayList<CallParameter> callParameters;
+	
 	/**
 	 * Set the parameter for the object call
 	 * 
@@ -62,16 +62,16 @@
 	 */
 	public CallMethod(final URL aURL, final boolean bPost, final String sName,
 			final String sID,
-			final Map<String, CallParameter> mapOfCallParameter) {
+			final ArrayList<CallParameter> callParameters) {
 		logger.trace("Constructor\n" +
 				     "URL : " + aURL + ".\n" +
 				     "Post : " + bPost + ".\n" +
 				     "Name : " + sName + ".\n" +
 				     "ID : " + sID + ".\n" +
-				     "Map of call parameter : " + mapOfCallParameter + ".");
+				     "Map of call parameter : " + callParameters + ".");
 
 		this.aURL = aURL;
-		this.mapOfCallParameter = mapOfCallParameter;
+		this.callParameters = callParameters;
 		this.bPost = bPost;
 		this.sName = sName;
 		this.sID = sID;
@@ -82,8 +82,8 @@
 	 * 
 	 * @return Returns the parameters.
 	 */
-	public Map<String, CallParameter> getMapOfCallParameter() {
-		return this.mapOfCallParameter;
+	public ArrayList<CallParameter> getListOfCallParameter() {
+		return this.callParameters;
 	}
 
 	/**
@@ -93,7 +93,7 @@
 	 *            a parameter to add
 	 */
 	public void addParameter(final CallParameter aCallParameter) {
-		this.mapOfCallParameter.put(aCallParameter.getName(), aCallParameter);
+		this.callParameters.add(aCallParameter);
 	}
 
 	/**
@@ -104,7 +104,10 @@
 	 * @return the Call parameter researched
 	 */
 	public CallParameter getCallParameterByName(final String sName) {
-		return this.mapOfCallParameter.get(sName);
+		for (CallParameter param : callParameters)
+			if (param.getName().equals(sName))
+				return param;
+		return null;
 	}
 
 	/**
@@ -159,7 +162,7 @@
 		aStringBuffer.append("post=").append(this.bPost);
 		aStringBuffer.append(sVariableSeparator);
 		aStringBuffer.append("parameters=\n");
-		aStringBuffer.append(this.mapOfCallParameter)
+		aStringBuffer.append(this.callParameters)
 				.append(sVariableSeparator);
 
 		return aStringBuffer.toString();
diff -r 3703fcba4aeb -r 64aa677ff0e8 src/org/w3c/unicorn/contract/WADLUnmarshallerXPath.java
--- a/src/org/w3c/unicorn/contract/WADLUnmarshallerXPath.java	Tue Sep 07 13:06:32 2010 -0400
+++ b/src/org/w3c/unicorn/contract/WADLUnmarshallerXPath.java	Wed Sep 08 15:55:10 2010 -0400
@@ -267,8 +267,7 @@
 		for (int i = 0; i < aNodeListMethod.getLength(); i++) {
 			final Node aNodeMethod = aNodeListMethod.item(i);
 
-			final Map<String, CallParameter> mapOfCallParameter;
-			mapOfCallParameter = new LinkedHashMap<String, CallParameter>();
+			ArrayList<CallParameter> callParameters = new ArrayList<CallParameter>();
 
 			// URI of the resource (will be appended to the base URI)
 			final String sResourceURI;
@@ -340,14 +339,13 @@
 							.getAttributes().item(0).getNodeValue());
 				}
 
-				mapOfCallParameter.put(new String(aCallParameter.getName()),
-						aCallParameter);
+				callParameters.add(aCallParameter);
 
 			} // iterate over query_variable list
 
 			final CallMethod aCallMethod = new CallMethod(new URL(sBaseURI
 					+ sResourceURI), bPost, sName, sMethodID,
-					mapOfCallParameter);
+					callParameters);
 			this.listOfCallMethod.add(aCallMethod);
 
 			// fill mapOfInputMethod

Received on Wednesday, 8 September 2010 19:55:34 UTC