cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Liu, Jervis" <j...@iona.com>
Subject RE: svn commit: r599368 - in /incubator/cxf/trunk:rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/systests/src/test/java/org/apache/cxf/systest/jaxrs/
Date Fri, 30 Nov 2007 06:32:20 GMT


> -----Original Message-----
> From: Glen Mazza [mailto:glen.mazza@verizon.net]
> Sent: 2007年11月29日 19:56
> To: cxf-dev@incubator.apache.org
> Subject: Re: svn commit: r599368 - in
> /incubator/cxf/trunk:rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/
> interceptor/systests/src/test/java/org/apache/cxf/systest/jaxrs/
> 
> Am Donnerstag, den 29.11.2007, 10:35 +0000 schrieb jliu@apache.org:
> > 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/i
> nterceptor/JAXRSDispatchInterceptor.java
> >
> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/Bo
> okStore.java
> >
> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAX
> RSClientServerBookTest.java
> >
> > Modified:
> incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/i
> nterceptor/JAXRSDispatchInterceptor.java
> > URL:
> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/ma
> in/java/org/apache/cxf/jaxrs/interceptor/JAXRSDispatchInterceptor.java?re
> v=599368&r1=599367&r2=599368&view=diff
> >
> ==============================================================
> ================
> > ---
> incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/i
> nterceptor/JAXRSDispatchInterceptor.java (original)
> > +++
> incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/i
> nterceptor/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.
> 

No, this piece of code is used to allow passing int or other primitive types instead of String
from URL. In the case of Zip codes you raised, users should not use int, they should always
use String as input parameters to retain the leading zero.

Thanks,
Jervis

> Regards,
> Glen

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
Mime
View raw message