Package org.directwebremoting.extend

Examples of org.directwebremoting.extend.NonNestedOutboundVariable


        return null;
    }

    @Override public OutboundVariable convertOutbound(Object data, OutboundContext outctx) throws ConversionException {
        try {
            return new NonNestedOutboundVariable(data == null ? "null" : "'" + cipherer.encrypt(((UUID) data).toString()) + "'");
        } catch (Exception e) {
            throw new ConversionException(data.getClass(), new IWebMvcException("Could not generate encrypted UUID from: " + data, e));
        }
    }
View Full Code Here


     * @param arg1 any (unused)
     * @return
     * @throws ConversionException never
     */
    @Override public OutboundVariable convertOutbound(Object arg0, OutboundContext arg1) throws ConversionException {
        return new NonNestedOutboundVariable("null");
    }
View Full Code Here

        Object[] enums = enumClass.getEnumConstants();
        for (int index = 0; index < enums.length; index++)
            if (enums[index] == data)
                pos = index;
        if (pos < 0) throw new ConversionException(enumClass);
        return new NonNestedOutboundVariable("{position: " + pos + ", displayable: \'" + messageResolver.getMessage(enumClass.getSimpleName() + "." + ((Enum<?>) data).name(), null, WebContextLocale.getActiveLocale()) + "\'}");
    }
View Full Code Here

    @Override public OutboundVariable convertOutbound(Object data, OutboundContext outctx) throws ConversionException {
        try {
            String name = ClassUtils.getActualClass(data).getName();
            if (name.indexOf("_$$_javassist") > 0) name = name.substring(0, name.indexOf("_$$_javassist"));
            return new NonNestedOutboundVariable(data == null ? "null" : "'" + cipherer.encrypt(name) + "'");
        } catch (Exception e) {
            throw new ConversionException(data.getClass(), new IWebMvcException("Could not generate encrypted class name from: " + data, e));
        }
    }
View Full Code Here

    }

    @Override
    public OutboundVariable convertOutbound(Object data, OutboundContext context) throws ConversionException {
        RollbackException ex = (RollbackException) data;
        if ((data == null) || (ex.getValue() == null)) return new NonNestedOutboundVariable("null");
        return converterManager.convertOutbound(ex.getValue(), context);
    }
View Full Code Here

    @Override
    public OutboundVariable convertOutbound(Object data, OutboundContext ctx) throws MarshallException {
        if (decipherer == null) initEncryption();
        try {
            return new NonNestedOutboundVariable("'" + cipherer.encrypt(((UUID) data).toString()) + "'");
        } catch (Exception e) {
            throw new MarshallException(data.getClass(), new IWebMvcException("Could not generate encrypted UUID from: " + data, e));
        }
    }
View Full Code Here

    }

    public OutboundVariable convertOutbound(Object data, OutboundContext ctx) throws MarshallException {
        if (decipherer == null) initEncryption();
        try {
            return new NonNestedOutboundVariable("'" + cipherer.encrypt(((Class<?>) data).getName()) + "'");
        } catch (Exception e) {
            throw new MarshallException(data.getClass(), new IWebMvcException("Could not generate encrypted class name from: " + data, e));
        }
    }
View Full Code Here

                user.setSalt(null);
                user.setPassword(null);
            }
        } catch (Exception ex) {
            // Better safe than sorry
            return new NonNestedOutboundVariable("null");
        }
        return super.convertOutbound(data, outctx);
    }
View Full Code Here

      }
        return null;
    }

    @Override public OutboundVariable convertOutbound(Object data, OutboundContext outctx) throws ConversionException {
        return new NonNestedOutboundVariable(data == null ? "0" : String.valueOf(((Rating) data).getRating()));
    }
View Full Code Here

     */
    public OutboundVariable convertOutbound(final Object object, OutboundContext outboundContext) throws ConversionException
    {
        if (object == null)
        {
            return new NonNestedOutboundVariable("null");
        }

        try
        {
            FileTransfer transfer;

            if (object instanceof BufferedImage)
            {
                transfer = new FileTransfer((BufferedImage) object, "png");
            }
            else if (object instanceof InputStream)
            {
                final InputStream in = (InputStream) object;
                transfer = new FileTransfer("download.dat", "binary/octet-stream", -1, new InputStreamFactory()
                {
                    public InputStream getInputStream() throws IOException
                    {
                        return in;
                    }

                    public void close() throws IOException
                    {
                        in.close();
                    }
                });
            }
            else if (object instanceof FileTransfer)
            {
                transfer = (FileTransfer) object;
            }
            else if (object.getClass().isArray() && object.getClass().getComponentType() == Byte.TYPE)
            {
                transfer = new FileTransfer("download.dat", "binary/octet-stream", (byte[]) object);
            }
            else
            {
                throw new ConversionException(object.getClass());
            }

            Container container = WebContextFactory.get().getContainer();
            boolean preferDataUrlSchema = ContainerUtil.getBooleanSetting(container, "preferDataUrlSchema", false);

            DownloadManager downloadManager;
            if (preferDataUrlSchema && isDataUrlAvailable())
            {
                downloadManager = new DataUrlDownloadManager();
            }
            else
            {
                downloadManager = container.getBean(DownloadManager.class);
            }

            String url = downloadManager.addFileTransfer(transfer);
            return new NonNestedOutboundVariable(url);
        }
        catch (IOException ex)
        {
            throw new ConversionException(getClass(), ex);
        }
View Full Code Here

TOP

Related Classes of org.directwebremoting.extend.NonNestedOutboundVariable

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.