Examples of Coercion


Examples of org.apache.tapestry.ioc.services.Coercion

        // Is a coercion even necessary? Not if the target type is assignable from the
        // input value.

        if (effectiveTargetType.isAssignableFrom(inputType)) return "";

        Coercion coercion = findCoercion(inputType, effectiveTargetType);

        return coercion.toString();
    }
View Full Code Here

Examples of org.apache.tapestry.ioc.services.Coercion

    private Coercion findCoercion(Class sourceType, Class targetType)
    {
        CacheKey key = new CacheKey(sourceType, targetType);

        Coercion result = _cache.get(key);

        if (result == null)
        {
            result = findOrCreateCoercion(sourceType, targetType);
            _cache.put(key, result);
View Full Code Here

Examples of org.apache.tapestry.ioc.services.Coercion

                // The intermediateTuple coercer gets from S --> I1 (an intermediate type).
                // The current tuple's coercer gets us from I2 --> X. where I2 is assignable
                // from I1 (i.e., I2 is a superclass/superinterface of I1) and X is a new
                // intermediate type, hopefully closer to our eventual target type.

                Coercion compoundCoercer = new CompoundCoercion(intermediateTuple.getCoercion(),
                        tuple.getCoercion());

                CoercionTuple compoundTuple = new CoercionTuple(sourceType, newIntermediateType,
                        compoundCoercer, false);
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.Coercion

                // The intermediateTuple coercer gets from S --> I1 (an intermediate type).
                // The current tuple's coercer gets us from I2 --> X. where I2 is assignable
                // from I1 (i.e., I2 is a superclass/superinterface of I1) and X is a new
                // intermediate type, hopefully closer to our eventual target type.

                Coercion compoundCoercer = new CompoundCoercion(intermediateTuple.getCoercion(), tuple.getCoercion());

                CoercionTuple compoundTuple = new CoercionTuple(sourceType, newIntermediateType, compoundCoercer, false);

                // So, every tuple that is added to the queue can take as input the sourceType.
                // The target type may be another intermediate type, or may be something
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.Coercion

            if (type.isAssignableFrom(sourceType))
            {
                return input;
            }

            Coercion c = getCoercion(sourceType);

            try
            {
                return type.cast(c.coerce(input));
            } catch (Exception ex)
            {
                throw new RuntimeException(ServiceMessages.failedCoercion(input, type, c, ex), ex);
            }
        }
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.Coercion

            return getCoercion(sourceType).toString();
        }

        private Coercion getCoercion(Class sourceType)
        {
            Coercion c = cache.get(sourceType);

            if (c == null)
            {
                c = findOrCreateCoercion(sourceType, type);
                cache.put(sourceType, c);
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.Coercion

    {
        Object input = new Integer(-37);

        assertSame(coercer.coerce(input, Number.class), input);

        Coercion coercion = coercer.getCoercion(int.class, Number.class);

        assertSame(coercion.coerce(input), input);
    }
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.Coercion

    {
        Object actual = coercer.coerce(input, targetType);

        assertEquals(actual, expected);

        Coercion c = coercer.getCoercion(input == null ? void.class : input.getClass(), targetType);

        assertEquals(c.coerce(input), expected);
    }
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.Coercion

            if (type.isAssignableFrom(sourceType))
            {
                return input;
            }

            Coercion c = getCoercion(sourceType);

            try
            {
                return type.cast(c.coerce(input));
            } catch (Exception ex)
            {
                throw new RuntimeException(ServiceMessages.failedCoercion(input, type, c, ex), ex);
            }
        }
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.Coercion

            return getCoercion(sourceType).toString();
        }

        private Coercion getCoercion(Class sourceType)
        {
            Coercion c = cache.get(sourceType);

            if (c == null)
            {
                c = findOrCreateCoercion(sourceType, type);
                cache.put(sourceType, c);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.