Package org.directwebremoting

Examples of org.directwebremoting.ConversionException


            return properties;
        }
        catch (IntrospectionException ex)
        {
            throw new ConversionException(type, ex);
        }
    }
View Full Code Here


    /* (non-Javadoc)
     * @see org.directwebremoting.Converter#convertInbound(java.lang.Class, org.directwebremoting.InboundVariable, org.directwebremoting.InboundContext)
     */
    public Object convertInbound(Class<?> paramType, InboundVariable iv) throws ConversionException
    {
        throw new ConversionException(paramType, "Inbound CDF Document conversion is not supported");
    }
View Full Code Here

        try
        {
            // Using XSLT to convert to a stream. Setup the source
            if (!(data instanceof CdfDocument))
            {
                throw new ConversionException(data.getClass());
            }

            CdfDocument document = (CdfDocument) data;
            String xmlout = JavascriptUtil.escapeJavaScript(document.toXml());

            String script = "dwr.gi._loadXml(\"" + xmlout + "\")";
            OutboundVariable ov = new NonNestedOutboundVariable(script);

            outctx.put(data, ov);

            return ov;
        }
        catch (ConversionException ex)
        {
            throw ex;
        }
        catch (Exception ex)
        {
            throw new ConversionException(data.getClass(), ex);
        }
    }
View Full Code Here

            return null;
        }

        if (paramType != URIResolver.class)
        {
            throw new ConversionException(paramType);
        }

        URIResolver reply = URIResolver.toURIResolver(data.getValue());
        if (reply == null)
        {
            throw new ConversionException(paramType);
        }

        return reply;
    }
View Full Code Here

            {
                return (T) data;
            }
            catch (ClassCastException ex)
            {
                throw new ConversionException(asType, ex);
            }
        }
        else
        {
            return converterManager.convertInbound(asType, rawData);
View Full Code Here

        {
            return field.get(bean);
        }
        catch (Exception ex)
        {
            throw new ConversionException(bean.getClass(), ex);
        }
    }
View Full Code Here

        {
            field.set(bean, value);
        }
        catch (Exception ex)
        {
            throw new ConversionException(bean.getClass(), ex);
        }
    }
View Full Code Here

    /* (non-Javadoc)
     * @see org.directwebremoting.Converter#convertInbound(java.lang.Class, org.directwebremoting.InboundVariable, org.directwebremoting.InboundContext)
     */
    public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException
    {
        throw new ConversionException(paramType, "StringWrappers are not availble during inbound marshalling");
    }
View Full Code Here

        }

        if (!value.startsWith(ProtocolConstants.INBOUND_MAP_START) || !value.endsWith(ProtocolConstants.INBOUND_MAP_END))
        {
            log.warn("Expected object while converting data for " + paramType.getName() + " in " + data.getContext().getCurrentProperty() + ". Passed: " + value);
            throw new ConversionException(paramType, "Data conversion error. See logs for more details.");
        }

        value = value.substring(1, value.length() - 1);

        try
        {
            // Maybe we ought to check that the paramType isn't expecting a more
            // distinct type of Map and attempt to create that?
            Map<Object, Object> map;

            // If paramType is concrete then just use whatever we've got.
            if (!paramType.isInterface() && !Modifier.isAbstract(paramType.getModifiers()))
            {
                // If there is a problem creating the type then we have no way
                // of completing this - they asked for a specific type and we
                // can't create that type. I don't know of a way of finding
                // subclasses that might be instaniable so we accept failure.
                map = (Map<Object, Object>) paramType.newInstance();
            }
            else
            {
                map = new HashMap<Object, Object>();
            }

            // Get the extra type info
            Property parent = data.getContext().getCurrentProperty();

            Property keyProp = parent.createChild(0);
            keyProp = converterManager.checkOverride(keyProp);
            Class<?> keyType = keyProp.getPropertyType();

            Property valProp = parent.createChild(1);
            valProp = converterManager.checkOverride(valProp);
            Class<?> valType = valProp.getPropertyType();

            // We should put the new object into the working map in case it
            // is referenced later nested down in the conversion process.
            data.getContext().addConverted(data, paramType, map);
            InboundContext incx = data.getContext();

            // Loop through the property declarations
            StringTokenizer st = new StringTokenizer(value, ",");
            int size = st.countTokens();
            for (int i = 0; i < size; i++)
            {
                String token = st.nextToken();
                if (token.trim().length() == 0)
                {
                    continue;
                }

                int colonpos = token.indexOf(ProtocolConstants.INBOUND_MAP_ENTRY);
                if (colonpos == -1)
                {
                    throw new ConversionException(paramType, "Missing " + ProtocolConstants.INBOUND_MAP_ENTRY + " in object description: {1}" + token);
                }

                // Convert the value part of the token by splitting it into the
                // type and value (as passed in by Javascript)
                String valStr = token.substring(colonpos + 1).trim();
                String[] splitIv = ConvertUtil.splitInbound(valStr);
                String splitIvValue = splitIv[ConvertUtil.INBOUND_INDEX_VALUE];
                String splitIvType = splitIv[ConvertUtil.INBOUND_INDEX_TYPE];
                InboundVariable valIv = new InboundVariable(incx, null, splitIvType, splitIvValue);
                valIv.dereference();
                Object val = converterManager.convertInbound(valType, valIv, valProp);

                // Keys (unlike values) do not have type info passed with them
                // Could we have recursive key? - I don't think so because keys
                // must be strings in Javascript
                String keyStr = token.substring(0, colonpos).trim();
                //String[] keySplit = LocalUtil.splitInbound(keyStr);
                //InboundVariable keyIv = new InboundVariable(incx, splitIv[LocalUtil.INBOUND_INDEX_TYPE], splitIv[LocalUtil.INBOUND_INDEX_VALUE]);
                InboundVariable keyIv = new InboundVariable(incx, null, ProtocolConstants.TYPE_STRING, keyStr);
                keyIv.dereference();

                Object key = converterManager.convertInbound(keyType, keyIv, keyProp);

                map.put(key, val);
            }

            return map;
        }
        catch (ConversionException ex)
        {
            throw ex;
        }
        catch (Exception ex)
        {
            throw new ConversionException(paramType, ex);
        }
    }
View Full Code Here

            return LocalUtil.simpleConvert(value, paramType);
        }
        catch (NumberFormatException ex)
        {
            log.debug("Error converting " + value + " to a number.");
            throw new ConversionException(paramType, "Format error converting number.");
        }
        catch (IllegalArgumentException ex)
        {
            throw new ConversionException(paramType);
        }
    }
View Full Code Here

TOP

Related Classes of org.directwebremoting.ConversionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.