// Javadoc inherited.
  protected Value execute(
      ExpressionContext expressionContext, DevicePolicyValueAccessor accessor, Value defaultValue) {
    Value value = null;
    ExpressionFactory factory = expressionContext.getFactory();

    // determine the size of the colour palette
    String palette = accessor.getDependentPolicyValue(DevicePolicyConstants.PALETTE);
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Size of colour palette (from repository):" + palette);
    }

    try {
      value = factory.createIntValue(Integer.parseInt(palette));
    } catch (NumberFormatException e) {
      // log it but continue
      LOGGER.info(
          "function-bad-parameter-value", new Object[] {palette, DevicePolicyConstants.PALETTE});
    }

    if (value == null) {
      // Verify that the default value is of the correct type
      if (defaultValue instanceof NumericValue) {
        value = defaultValue;
      } else {
        if (defaultValue != null) {
          // log the fact that the default was present but wrong type
          LOGGER.info("function-bad-default-value", "NumericValue");
        }
        value = new SimpleIntValue(factory, 0);
      }
    }

    return value;
  }
  /**
   * Helper method that sets up the contexts and creates and sets an expression context into the
   * environment context.
   *
   * @return the MarinerPageContext
   */
  protected TestMarinerPageContext createContexts() throws Exception {
    TestMarinerPageContext pageContext = new TestMarinerPageContext();
    pageContext.setVolantis(volantis);
    TestEnvironmentContext envContext = new TestEnvironmentContext();

    DefaultDevice dev = new DefaultDevice(null, null, null);
    dev.setName("myDevice");
    dev.setPolicyValue("protocol", "XHTMLBasic");
    MarinerSessionContext session = envContext.getSessionContext();
    InternalDevice internalDevice = INTERNAL_DEVICE_FACTORY.createInternalDevice(dev);
    session.setDevice(internalDevice);
    pageContext.setDevice(session.getDevice());

    // Create an expression context for the environment context.
    final ExpressionFactory factory = ExpressionFactory.getDefaultInstance();
    final EnvironmentInteractionTracker simpleTracker = new SimpleEnvironmentInteractionTracker();
    final ExpressionContext exprContext =
        factory.createExpressionContext(simpleTracker, new DefaultNamespacePrefixTracker());

    // Associate the expression context with the environment context.
    envContext.setExpressionContext(exprContext);

    // Create the initial request context.
    MarinerRequestContext requestContext = createInitialRequestContext(envContext);

    ApplicationContext appContext = new ApplicationContext(requestContext);
    appContext.setEncodingManager(encodingManager);

    pageContext.pushRequestContext(requestContext);
    ContextInternals.setEnvironmentContext(requestContext, envContext);
    ContextInternals.setMarinerPageContext(requestContext, pageContext);
    ContextInternals.setApplicationContext(requestContext, appContext);

    return pageContext;
  }