Package java.text

Examples of java.text.ChoiceFormat


                                // If the currency is handled by a ChoiceFormat,
                                // then we're not going to use the expanded
                                // patterns.  Instantiate the ChoiceFormat and
                                // return.
                                if (currencyChoice == null) {
                                    currencyChoice = new ChoiceFormat(s);
                                }
                                // We could almost return null or "" here, since the
                                // expanded affixes are almost not used at all
                                // in this situation.  However, one method --
                                // toPattern() -- still does use the expanded
View Full Code Here


    {
        final double limit[] = {0.0, 1.0, 2.0};
        final String formats[] = {"0.0<=Arg<1.0",
                                  "1.0<=Arg<2.0",
                                  "2.0<-Arg"};
        ChoiceFormat cf = new ChoiceFormat(limit, formats);
        assertEquals("ChoiceFormat.format", formats[1], cf.format(1));
    }
View Full Code Here

    public void TestMsgFormatChoice()
    {
        MessageFormat form = new MessageFormat("The disk \"{1}\" contains {0}.");
        double filelimits[] = {0,1,2};
        String filepart[] = {"no files","one file","{0,number} files"};
        ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
        form.setFormat(1, fileform); // NOT zero, see below

        FieldPosition ignore = new FieldPosition(FieldPosition_DONT_CARE);
        StringBuffer string = new StringBuffer();
        Object testArgs1[] = {new Integer(0), "MyDisk"};
View Full Code Here

            new MessageFormat("The folder contains {0}.")
        };

        double filelimits[] = {0,1,2};
        String filepart[] = {"no files","one file","{0,number} files"};
        ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
        msgfmts[2].setFormat(0, fileform);

       
        Object[] args0 = new Object[] {"tmp", new Date(1184777888000L), new Integer(15), new Integer(2)};
View Full Code Here

                                    Currency.SYMBOL_NAME,
                                    isChoiceFormat);
            // If this is a ChoiceFormat currency, then format an
            // arbitrary value; pick something != 1; more common.
            currencySymbol = isChoiceFormat[0]
                ? new ChoiceFormat(currname).format(2.0)
                : currname;
        } else {
            intlCurrencySymbol = "XXX";
            currencySymbol = "\u00A4"; // 'OX' currency symbol
        }
View Full Code Here

    XYAxis xAxis = frame.getXAxis();
    XYAxis yAxis = frame.getYAxis();
    yAxis.setPreferredSize(new Dimension(75, 50));
    xAxis.setStartMargin(75);
    ((LinearXYAxis) yAxis).setFormat(new ChoiceFormat(new double[] {-Double.POSITIVE_INFINITY, 0, 1, 2, 2.000001}, new String[] {"", "red",
        "green", "blue", ""}));
    ((LinearXYAxis) yAxis).setTickMarkCalculator(new IntegerTickMarkCalculator());
    final LinearXYPlotLine line = new LinearXYPlotLine(xAxis, yAxis, XYDimension.X);
    line.setForeground(Color.white);
    line.setLineMode(LineMode.STEP_YX);
View Full Code Here

                                BrowserMessages.getString("GB_ManyGems") };
        String[] catStrings = { BrowserMessages.getString("GB_NoCategories"),
                                BrowserMessages.getString("GB_OneCategory"),
                                BrowserMessages.getString("GB_ManyCategories") };

        ChoiceFormat gemChoice = new ChoiceFormat(limits, gemStrings);
        ChoiceFormat catChoice = new ChoiceFormat(limits, catStrings);
        ChoiceFormat[] formats = { gemChoice, catChoice };
       
        MessageFormat message = new MessageFormat(BrowserMessages.getString("GB_NodeToolTip"));
        message.setFormats(formats);
        return message.format(arguments);
View Full Code Here

        String[] choices = { NavigatorMessages.getString("NAV_SearchResultsNone"),
                             NavigatorMessages.getString("NAV_SearchResultsOne"),
                             NavigatorMessages.getString("NAV_SearchResultsMultiple") };
       
        double[] limits = { 0, 1, 2 };
        Format[] formats = { new ChoiceFormat(limits, choices), null };
        Object[] arguments = { Integer.valueOf(results.size()), url.getBase() };

        MessageFormat messageFormat = new MessageFormat(message);
        messageFormat.setFormats(formats);
View Full Code Here

            boolean[] isChoiceFormat = new boolean[1];
            currname = currency.getName(locale, Currency.SYMBOL_NAME, isChoiceFormat);
            // If this is a ChoiceFormat currency, then format an
            // arbitrary value; pick something != 1; more common.
            currencySymbol = isChoiceFormat[0]
                ? new ChoiceFormat(currname).format(2.0)
                : currname;
            CurrencyFormatInfo fmtInfo = info.getFormatInfo(intlCurrencySymbol);
            if (fmtInfo != null) {
                currencyPattern = fmtInfo.currencyPattern;
                monetarySeparator = fmtInfo.monetarySeparator;
View Full Code Here

                .getTimeInstance()));
        assertTrue("Wrong date format", formats[1].equals(DateFormat
                .getDateInstance()));
        assertTrue("Wrong number format", formats[2].equals(NumberFormat
                .getInstance()));
        assertTrue("Wrong choice format", formats[3].equals(new ChoiceFormat(
                "0.0#low|1.0#high")));
    assertNull("Wrong string format", formats[4]);

        Date date = new Date();
        FieldPosition pos = new FieldPosition(-1);
View Full Code Here

TOP

Related Classes of java.text.ChoiceFormat

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.