You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Daniel Kulp (JIRA)" <ji...@apache.org> on 2010/03/09 03:49:32 UTC
[jira] Assigned: (CXF-2698) REST type conversion to Byte, Integer,
... (non primitives) not working
[ https://issues.apache.org/jira/browse/CXF-2698?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Kulp reassigned CXF-2698:
--------------------------------
Assignee: Daniel Kulp
> REST type conversion to Byte, Integer, ... (non primitives) not working
> -----------------------------------------------------------------------
>
> Key: CXF-2698
> URL: https://issues.apache.org/jira/browse/CXF-2698
> Project: CXF
> Issue Type: Bug
> Components: JAX-WS Runtime
> Affects Versions: 2.2.5
> Environment: using JAXD Databinding, JAX-WS with REST
> Reporter: Dieter Freismuth
> Assignee: Daniel Kulp
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> methods like
> public String sayHi(@WebParam(name="number") Byte number)
> taking java.lang.Number can not be called via REST HTTP GET methods since there is not type conversion from String to Byte.
> This works using primitive types like byte!
> The root cause can be found at the end of URIMappingInterceptor.getParameters(...) method:
>
> if (type != null && type.isPrimitive() && queries.get(key) != null) {
> param = PrimitiveUtils.read(queries.get(key), type);
> } else {
> param = queries.get(key);
> }
> either PrimitiveUtils.read(..) should also work for Integer, Byte,.. types or there should be an extra method like:
> public Object readNullableTypes(String value, Class type) {
> Object ret = value;
> if (Integer.class == type) {
> ret = Integer.valueOf(value);
> }
> if (Byte.class == type) {
> ret = Byte.valueOf(value);
> }
> if (Short.class == type) {
> ret = Short.valueOf(value);
> }
> if (Long.class == type) {
> ret = Long.valueOf(value);
> }
> if (Float.class == type) {
> ret = Float.valueOf(value);
> }
> if (Double.class == type) {
> ret = Double.valueOf(value);
> }
> if (Boolean.class == type) {
> ret = Boolean.valueOf(value);
> }
> if (Character.class == type) {
> ret = value.charAt(0);
> }
> return ret;
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.