Am Donnerstag, den 29.11.2007, 10:35 +0000 schrieb [EMAIL PROTECTED]: > Author: jliu > Date: Thu Nov 29 02:35:04 2007 > New Revision: 599368 > > URL: http://svn.apache.org/viewvc?rev=599368&view=rev > Log: > CXF-1240. Support parsing java primitive types from URL. > > Modified: > > incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSDispatchInterceptor.java > > incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java > > incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java > > Modified: > incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSDispatchInterceptor.java > URL: > http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSDispatchInterceptor.java?rev=599368&r1=599367&r2=599368&view=diff > ============================================================================== > --- > incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSDispatchInterceptor.java > (original) > +++ > incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSDispatchInterceptor.java > Thu Nov 29 02:35:04 2007 > @@ -37,6 +37,7 @@ > import javax.ws.rs.ext.EntityProvider; > import javax.ws.rs.ext.ProviderFactory; > > +import org.apache.cxf.common.util.PrimitiveUtils; > import org.apache.cxf.jaxrs.JAXRSServiceImpl; > import org.apache.cxf.jaxrs.model.ClassResourceInfo; > import org.apache.cxf.jaxrs.model.OperationResourceInfo; > @@ -200,7 +201,7 @@ > return result; > } > > - private String readFromUriParam(UriParam uriParamAnnotation, > + private Object readFromUriParam(UriParam uriParamAnnotation, > Class<?> parameter, > Type parameterType, > Annotation[] parameterAnnotations, > @@ -212,8 +213,11 @@ > return null; > } > > - String result = values.get(parameterName); > - > + Object result = values.get(parameterName); > + > + if (parameter.isPrimitive()) { > + result = PrimitiveUtils.read((String)result, parameter); > + } > return result;
Just to make sure, this code now allows for returning Integer classes, for example, instead of Strings, correct? What if the parameter has a leading zero? Would that get lost here if we just returned an Integer? For example, some ZIP codes in the United States start with the number "0"--for example, one of Boston's is "02101". If it just returned a 2101 number that would be inaccurate--the leading zero is important here. Regards, Glen
