Package org.mule.transformer

Examples of org.mule.transformer.TransformerWeighting


        {
            if (logger.isDebugEnabled())
            {
                logger.debug("Comparing transformers for best match: input = " + input + " output = " + output + " Possible transformers = " + trans);
            }
            TransformerWeighting weighting = null;
            for (Transformer transformer : trans)
            {
                TransformerWeighting current = new TransformerWeighting(input, output, transformer);
                if (weighting == null)
                {
                    weighting = current;
                }
                else
                {
                    int compare = current.compareTo(weighting);
                    if (compare == 1)
                    {
                        weighting = current;
                    }
                    else if (compare == 0)
                    {
                        //We may have two transformers that are exactly the same, in which case we can use either i.e. use the current
                        if (!weighting.getTransformer().getClass().equals(current.getTransformer().getClass()))
                        {
                            throw new ResolverException(CoreMessages.transformHasMultipleMatches(input, output,
                                    current.getTransformer(), weighting.getTransformer()));
                        }
                    }
                }
            }
            return weighting.getTransformer();
View Full Code Here


                logger.debug("Comparing transformers for best match: input = " + input + " output = " + output + " Possible transformers = " + trans);
            }

            List<TransformerWeighting> weightings = calculateTransformerWeightings(trans, input, output);

            TransformerWeighting maxWeighting = weightings.get(weightings.size() - 1);

            for (int index = weightings.size() - 2; index >= 0 && maxWeighting.compareTo(weightings.get(index)) == 0; index--)
            {
                //We may have two transformers that are exactly the same, in which case we can use either i.e. use the current
                TransformerWeighting current = weightings.get(index);

                if (!maxWeighting.getTransformer().getClass().equals(current.getTransformer().getClass()))
                {
                    throw new ResolverException(CoreMessages.transformHasMultipleMatches(input, output,
                                                                                         current.getTransformer(), maxWeighting.getTransformer()));
                }
            }

            return maxWeighting.getTransformer();
        }
View Full Code Here

    {
        List<TransformerWeighting> weightings = new ArrayList<TransformerWeighting>(transformers.size());

        for (Transformer transformer : transformers)
        {
            TransformerWeighting transformerWeighting = new TransformerWeighting(input, output, transformer);
            weightings.add(transformerWeighting);
        }

        Collections.sort(weightings);
View Full Code Here

            return Collections.emptyList();
        }

        List<TransformerWeighting> weightings = getTransformerWeightings(converters, source.getType(), result.getType());

        TransformerWeighting transformerWeighting = weightings.get(weightings.size() - 1);
        int index = weightings.size() - 2;
        List<Converter> heaviestConverter = new LinkedList<Converter>();
        heaviestConverter.add((Converter) transformerWeighting.getTransformer());

        for (; index > -1; --index)
        {
            if (weightings.get(index).compareTo(transformerWeighting) < 0)
            {
View Full Code Here

    private List<TransformerWeighting> getTransformerWeightings(List<Converter> converters, Class input, Class output)
    {
        List<TransformerWeighting> weightings = new LinkedList<TransformerWeighting>();
        for (Converter converter : converters)
        {
            TransformerWeighting current = new TransformerWeighting(input, output, converter);
            weightings.add(current);
        }
        Collections.sort(weightings);

        return weightings;
View Full Code Here

TOP

Related Classes of org.mule.transformer.TransformerWeighting

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.