Example usage for java.text ChoiceFormat setChoices

List of usage examples for java.text ChoiceFormat setChoices

Introduction

In this page you can find the example usage for java.text ChoiceFormat setChoices.

Prototype

public void setChoices(double[] limits, String formats[]) 

Source Link

Document

Set the choices to be used in formatting.

Usage

From source file:net.gtaun.wl.lang.BeanMessageFormat.java

/**
 * Do something TODO. //from   ww w. j a  v  a2  s.c om
 * <p> 
 * Details of the function. 
 * </p> 
 */
private void applyFormats(MessageFormat subFormat) {

    for (Format format : subFormat.getFormats()) {
        if (!(format instanceof ChoiceFormat)) {
            continue;
        }

        ChoiceFormat choice = (ChoiceFormat) format;
        String[] choiceFormats = (String[]) choice.getFormats();
        for (int i = 0; i < choiceFormats.length; i++) {
            String innerFormat = choiceFormats[i];
            if (innerFormat.contains("{")) {
                BeanMessageFormat recursive = new BeanMessageFormat(innerFormat, root);
                choiceFormats[i] = recursive.inner.toPattern();
            }
        }

        choice.setChoices(choice.getLimits(), choiceFormats);
    }
}

From source file:org.mypsycho.text.BeanMessageFormat.java

/**
 * Do something TODO./*from   w  w  w. j  a va  2s  . c  o  m*/
 * <p>
 * Details of the function.
 * </p>
 */
private void applyFormats(java.text.MessageFormat subFormat) {

    for (Format format : subFormat.getFormats()) {
        if (!(format instanceof ChoiceFormat)) {
            continue;
        }

        ChoiceFormat choice = (ChoiceFormat) format;
        String[] choiceFormats = (String[]) choice.getFormats();
        for (int i = 0; i < choiceFormats.length; i++) {
            String innerFormat = choiceFormats[i];
            if (innerFormat.contains("{")) {
                BeanMessageFormat recursive = new BeanMessageFormat(innerFormat, root);
                choiceFormats[i] = recursive.inner.toPattern();
            }
        }

        choice.setChoices(choice.getLimits(), choiceFormats);
    }
}