Package org.mule.api.transformer

Examples of org.mule.api.transformer.TransformerException


                        {
                            results.add(item.getItemAsStream());
                        }
                        catch (XQException e)
                        {
                            throw new TransformerException(XmlMessages.streamNotAvailble(getName()));
                        }
                    }
                    else
                    {
                        //This can be a JAXB bound  object instance depending on whether the CommonHandler has been set
                        try
                        {
                            results.add(item.getObject());
                        }
                        catch (XQException e)
                        {
                            throw new TransformerException(XmlMessages.objectNotAvailble(getName()));

                        }
                    }
                    if (!type.isArray())
                    {
                        break;
                    }
                }
                if (returnType.getType().isArray())
                {
                    return results.toArray();
                }
                if (results.size() == 1)
                {
                    return results.get(0);
                }
                else if (results.size() == 0)
                {
                    return null;
                }
                else
                {
                    return results.toArray();
                }

            }
            finally
            {
                if (transformer != null)
                {
                    if (transformer.getWarnings() != null)
                    {
                        logger.warn(transformer.getWarnings().getMessage(), transformer.getWarnings().fillInStackTrace());
                    }
                    // clear transformation parameters before returning transformer to the
                    // pool
                    //TODO find out what the scope is for bound variables, there doesn't seem to be a way to unbind them

                    transformerPool.returnObject(transformer);
                }
            }

        }
        catch (Exception e)
        {
            throw new TransformerException(this, e);
        }
    }
View Full Code Here


                return e.getValue();
            }
        }
        catch (Exception e)
        {
            throw new TransformerException(this, e);
        }
        return null;
    }
View Full Code Here

        try
        {
            XMLStreamReader xsr = XMLUtils.toXMLStreamReader(getXMLInputFactory(), src);
            if (xsr == null)
            {
                throw new TransformerException(MessageFactory
                    .createStaticMessage("Unable to convert " + src.getClass() + " to XMLStreamReader."), this);
            }
       
            if (reversible && !(xsr instanceof ReversibleXMLStreamReader))
            {
                return new ReversibleXMLStreamReader(xsr);
            }
            else
            {
                return xsr;
            }
        }
        catch (XMLStreamException e)
        {
            throw new TransformerException(this, e);
        }
    }
View Full Code Here

                Reader xml = new InputStreamReader(new ByteArrayInputStream((byte[]) src), outputEncoding);
                result = getXStream().fromXML(xml);
            }
            catch (UnsupportedEncodingException e)
            {
                throw new TransformerException(this, e);
            }
        }
        else if (src instanceof InputStream)
        {
            InputStream input = (InputStream) src;
            try
            {
                Reader xml = new InputStreamReader(input, outputEncoding);
                result = getXStream().fromXML(xml);
            }
            catch (Exception e)
            {
                throw new TransformerException(this, e);
            }
            finally
            {
                try
                {
                    input.close();
                }
                catch (IOException e)
                {
                    logger.warn("Exception closing stream: ", e);
                }
            }
        }
        else if (src instanceof String)
        {
            result = getXStream().fromXML(src.toString());
        }
        else
        {
            result = getXStream().fromXML((String) domTransformer.transform(src));
        }

        try
        {
            postDeserialisationInit(result);
            return result;
        }
        catch (Exception e)
        {
            throw new TransformerException(this, e);
        }
    }
View Full Code Here

                    }
                };
            }
            else
            {
                throw new TransformerException(CoreMessages.transformerInvalidReturnType(getReturnClass(), getName()));
            }

        }
        catch (Exception e)
        {
            throw new TransformerException(this, e);
        }
    }
View Full Code Here

                    instance = (XStream)xstream.get();
                }
            }
            catch (Exception e)
            {
                throw new TransformerException(MessageFactory.createStaticMessage("Unable to initialize XStream"), e);
            }
        }

        return instance;
    }
View Full Code Here

            return holder.getResultObject();
        }
        catch (Exception e)
        {
            throw new TransformerException(this, e);
        }
    }
View Full Code Here

            {
                doc = DocumentHelper.parseText(src.toString());
            }
            catch (DocumentException e)
            {
                throw new TransformerException(this, e);
            }
        }

        String history = doc.valueOf("/credit-profile/customer-history");
        String score = doc.valueOf("/credit-profile/credit-score");
View Full Code Here

        {
            getMapper().writeValue(writer, src);
        }
        catch (IOException e)
        {
            throw new TransformerException(this, e);
        }
       
        if (returnType.getType().equals(byte[].class))
        {
            try
            {
                return writer.toString().getBytes(outputEncoding);
            }
            catch (UnsupportedEncodingException uee)
            {
                throw new TransformerException(this, uee);
            }
        }
        else
        {
            return writer.toString();
View Full Code Here

            amount = Double.parseDouble(getParam(message, "loanAmount"));
            duration = Integer.parseInt(getParam(message, "loanDuration"));
        }
        catch (Exception e)
        {
            throw new TransformerException(this, e);
        }

        Customer c = new Customer(name, ssn);
        CustomerQuoteRequest request = new CustomerQuoteRequest(c, amount, duration);
        return request;
View Full Code Here

TOP

Related Classes of org.mule.api.transformer.TransformerException

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.