Пример #1
0
  /** @return Decimal format from EDI configuration */
  private DecimalFormat getDecimalFormatForConfiguration() {
    final DecimalFormat decimalFormat = (DecimalFormat) NumberFormat.getInstance();

    final ModelCamelContext context = getContext();
    decimalFormat.setMaximumFractionDigits(
        Integer.valueOf(
            Util.resolvePropertyPlaceholders(context, "edi.decimalformat.maximumFractionDigits")));

    final boolean isGroupingUsed =
        Boolean.valueOf(
            Util.resolvePropertyPlaceholders(context, "edi.decimalformat.isGroupingUsed"));
    decimalFormat.setGroupingUsed(isGroupingUsed);

    final DecimalFormatSymbols decimalFormatSymbols = decimalFormat.getDecimalFormatSymbols();

    if (isGroupingUsed) {
      final char groupingSeparator =
          Util.resolvePropertyPlaceholders(context, "edi.decimalformat.symbol.groupingSeparator")
              .charAt(0);
      decimalFormatSymbols.setGroupingSeparator(groupingSeparator);
    }

    final char decimalSeparator =
        Util.resolvePropertyPlaceholders(context, "edi.decimalformat.symbol.decimalSeparator")
            .charAt(0);
    decimalFormatSymbols.setDecimalSeparator(decimalSeparator);

    decimalFormat.setDecimalFormatSymbols(
        decimalFormatSymbols); // though it seems redundant, it won't be set otherwise for some
                               // reason...

    return decimalFormat;
  }
Пример #2
0
  /**
   * @param propertiesConfigurationPath
   * @return {@link SmooksDataFormat} data format for properties configuration
   */
  protected final SmooksDataFormat getSDFForConfiguration(
      final String propertiesConfigurationPath) {
    final String smooksConfigurationPath =
        Util.resolvePropertyPlaceholders(getContext(), propertiesConfigurationPath);

    try {
      return new SmooksDataFormat(smooksConfigurationPath);
    } catch (final Exception e) {
      throw new RuntimeCamelException(e);
    }
  }