openamf/src/java/org/openamf/invoker RankedMethod.java,1.6,1.7

[email protected]
Newsgroups gmane.comp.java.openamf.cvs
Message-ID <[email protected]>
Update of /cvsroot/openamf/openamf/src/java/org/openamf/invoker
In directory sc8-pr-cvs1:/tmp/cvs-serv22519/src/java/org/openamf/invoker

Modified Files:
	RankedMethod.java 
Log Message:
fixed bug with native types

Index: RankedMethod.java
===================================================================
RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/RankedMethod.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** RankedMethod.java	6 May 2003 03:54:16 -0000	1.6
--- RankedMethod.java	7 May 2003 17:40:18 -0000	1.7
***************
*** 112,121 ****
  			Object parameter = parameters.get(i);
  			
! 			boolean origTypesMatch = parameterType.isInstance(parameter);
  
  			Object decodedObject = decodeParameter(parameter, parameterType);
! 			log.debug("parameter class: " + decodedObject.getClass().getName());
! 			log.debug("expected class: " + parameterType.getName());
! 			if (parameterType.isInstance(decodedObject)) {
  				log.debug("types match");
  				if (origTypesMatch) {
--- 112,119 ----
  			Object parameter = parameters.get(i);
  			
! 			boolean origTypesMatch = typesMatch(parameterType, parameter);
  
  			Object decodedObject = decodeParameter(parameter, parameterType);
! 			if (decodedObject != null && typesMatch(parameterType, decodedObject)) {
  				log.debug("types match");
  				if (origTypesMatch) {
***************
*** 138,141 ****
--- 136,170 ----
  
  		return rank;
+ 	}
+ 	
+ 	private boolean typesMatch(Class parameterType, Object parameter) {
+ 		
+ 		log.debug("expected class: " + parameterType.getName());
+ 		log.debug("parameter class: " + parameter.getClass().getName());
+ 		
+ 		boolean typesMatch = parameterType.isInstance(parameter);
+ 		
+ 		if (!typesMatch) {
+ 			if (parameterType.equals(Byte.TYPE) && parameter instanceof Byte) {
+ 				typesMatch = true;
+ 			}
+ 			if (parameterType.equals(Short.TYPE) && parameter instanceof Short) {
+ 				typesMatch = true;
+ 			}
+ 			if (parameterType.equals(Integer.TYPE) && parameter instanceof Integer) {
+ 				typesMatch = true;
+ 			}
+ 			if (parameterType.equals(Long.TYPE) && parameter instanceof Long) {
+ 				typesMatch = true;
+ 			}
+ 			if (parameterType.equals(Float.TYPE) && parameter instanceof Float) {
+ 				typesMatch = true;
+ 			}
+ 			if (parameterType.equals(Double.TYPE) && parameter instanceof Double) {
+ 				typesMatch = true;
+ 			}
+ 		}
+ 		
+ 		return typesMatch;
  	}
  




-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.