Package ognl

Examples of ognl.TypeConverter


            {
                IApplicationSpecification appSpec = _root.getPage().getEngine().getSpecification();

                if (appSpec != null && appSpec.checkExtension(Tapestry.OGNL_TYPE_CONVERTER))
                {
                    TypeConverter typeConverter =
                        (TypeConverter) appSpec.getExtension(
                            Tapestry.OGNL_TYPE_CONVERTER,
                            TypeConverter.class);

                    Ognl.setTypeConverter(_context, typeConverter);
View Full Code Here


            }

            return;
        }

        TypeConverter conv = getTypeConverterFromContext(context);
        Map contextFrom = Ognl.createDefaultContext(from);
        Ognl.setTypeConverter(contextFrom, conv);
        Map contextTo = Ognl.createDefaultContext(to);
        Ognl.setTypeConverter(contextTo, conv);
View Full Code Here

      return e;
    }
  }

  private TypeConverter createTypeConverter() {
    return new TypeConverter() {
      public Object convertValue(Map context, Object target, Member member, String propertyName, Object value,
          Class toType) throws ValueCoercionException {
        try {
          return conversionService.executeConversion(value, toType);
        } catch (ConversionException e) {
View Full Code Here

    {
        MockControl asc = newControl(IApplicationSpecification.class);
        IApplicationSpecification as = (IApplicationSpecification) asc.getMock();

        MockControl tcc = newControl(TypeConverter.class);
        TypeConverter tc = (TypeConverter) tcc.getMock();

        // Training

        as.checkExtension(Tapestry.OGNL_TYPE_CONVERTER);
        asc.setReturnValue(true);

        as.getExtension(Tapestry.OGNL_TYPE_CONVERTER, TypeConverter.class);
        asc.setReturnValue(tc);

        replayControls();

        ExpressionCache cache = new ExpressionCacheImpl();

        ExpressionEvaluatorImpl ee = new ExpressionEvaluatorImpl();

        ee.setExpressionCache(cache);
        ee.setApplicationSpecification(as);
        ee.setContributions(Collections.EMPTY_LIST);
       
        ee.initializeService();

        verifyControls();

        Fixture f = new Fixture();

        Method m = Fixture.class.getMethod("setValue", new Class[]
        { String.class });

        Date d = new Date();

        // Training

        // Since we have no idea what OGNL will stuff into that Map parameter,
        // we just ignore it.
        tc.convertValue(null, f, m, "value", d, String.class);
        tcc.setMatcher(new NullMeansIgnoreMatcher());

        tcc.setReturnValue("FROM-TYPE-CONVERTER");

        replayControls();
View Full Code Here

    public void test_Type_Converter() throws Exception
    {
        IApplicationSpecification as = newMock(IApplicationSpecification.class);
       
        TypeConverter tc = newMock(TypeConverter.class);

        // Training

        expect(as.checkExtension(Tapestry.OGNL_TYPE_CONVERTER)).andReturn(true);
View Full Code Here

    {
        MockControl asc = newControl(IApplicationSpecification.class);
        IApplicationSpecification as = (IApplicationSpecification) asc.getMock();

        MockControl tcc = newControl(TypeConverter.class);
        TypeConverter tc = (TypeConverter) tcc.getMock();

        // Training

        as.checkExtension(Tapestry.OGNL_TYPE_CONVERTER);
        asc.setReturnValue(true);

        as.getExtension(Tapestry.OGNL_TYPE_CONVERTER, TypeConverter.class);
        asc.setReturnValue(tc);

        replayControls();

        ExpressionCache cache = new ExpressionCacheImpl();

        ExpressionEvaluatorImpl ee = new ExpressionEvaluatorImpl();

        ee.setExpressionCache(cache);
        ee.setApplicationSpecification(as);
        ee.setContributions(Collections.EMPTY_LIST);
       
        ee.initializeService();

        verifyControls();

        Fixture f = new Fixture();

        Method m = Fixture.class.getMethod("setValue", new Class[]
        { String.class });

        Date d = new Date();

        // Training

        // Since we have no idea what OGNL will stuff into that Map parameter,
        // we just ignore it.
        tc.convertValue(null, f, m, "value", d, String.class);
        tcc.setMatcher(new NullMeansIgnoreMatcher());

        tcc.setReturnValue("FROM-TYPE-CONVERTER");

        replayControls();
View Full Code Here

            }

            return;
        }

        TypeConverter conv = getTypeConverterFromContext(context);
        Map contextFrom = Ognl.createDefaultContext(from);
        Ognl.setTypeConverter(contextFrom, conv);
        Map contextTo = Ognl.createDefaultContext(to);
        Ognl.setTypeConverter(contextTo, conv);
View Full Code Here

            {
                __CLOVER_52_0.S[1217]++;IApplicationSpecification appSpec = _root.getPage().getEngine().getSpecification();

                __CLOVER_52_0.S[1218]++;if ((((appSpec != null && appSpec.checkExtension(Tapestry.OGNL_TYPE_CONVERTER)) && (++__CLOVER_52_0.CT[239] != 0)) || (++__CLOVER_52_0.CF[239] == 0))){
                {
                    __CLOVER_52_0.S[1219]++;TypeConverter typeConverter =
                        (TypeConverter) appSpec.getExtension(
                            Tapestry.OGNL_TYPE_CONVERTER,
                            TypeConverter.class);

                    __CLOVER_52_0.S[1220]++;Ognl.setTypeConverter(_context, typeConverter);
View Full Code Here

    }
  }

  @SuppressWarnings("rawtypes")
  private TypeConverter createTypeConverter() {
    return new TypeConverter() {
      public Object convertValue(Map context, Object target, Member member, String propertyName, Object value,
          Class toType) throws ValueCoercionException {
        try {
          return conversionService.executeConversion(value, toType);
        } catch (ConversionException e) {
View Full Code Here

    public void testTypeConverter() throws Exception
    {
        IApplicationSpecification as = newMock(IApplicationSpecification.class);
       
        TypeConverter tc = newMock(TypeConverter.class);

        // Training

        expect(as.checkExtension(Tapestry.OGNL_TYPE_CONVERTER)).andReturn(true);

        expect(as.getExtension(Tapestry.OGNL_TYPE_CONVERTER, TypeConverter.class)).andReturn(tc);

        replay();

        ExpressionCache cache = new ExpressionCacheImpl();

        ExpressionEvaluatorImpl ee = new ExpressionEvaluatorImpl();

        ee.setExpressionCache(cache);
        ee.setApplicationSpecification(as);
        ee.setContributions(Collections.EMPTY_LIST);
        ee.setNullHandlerContributions(Collections.EMPTY_LIST);

        ee.initializeService();

        verify();

        Fixture f = new Fixture();

        Method m = Fixture.class.getMethod("setValue", new Class[]
        { String.class });

        Date d = new Date();

        // Training

        // Since we have no idea what OGNL will stuff into that Map parameter,
        // we just ignore it.
        expect(tc.convertValue(isA(Map.class), eq(f), eq(m), eq("value"), eq(d), eq(String.class)))
        .andReturn("FROM-TYPE-CONVERTER");

        replay();

        ee.write(f, "value", d);
View Full Code Here

TOP

Related Classes of ognl.TypeConverter

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.