Package com.ibm.icu.text

Examples of com.ibm.icu.text.MessageFormat.format()


        if (!objs[0].toString().equals("z"))
            errln("argument0: \"" + objs[0] + "\"");
        mf.setLocale(Locale.US);
        mf.applyPattern("{0,number,#.##}, {0,number,#.#}");
        Object[] oldobjs = {new Double(3.1415)};
        String result = mf.format( oldobjs );
        logln("pattern: \"" + mf.toPattern() + "\"");
        logln("text for parsing: \"" + result + "\"");
        // result now equals "3.14, 3.1"
        if (!result.equals("3.14, 3.1"))
            errln("result = " + result);
View Full Code Here


        ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
        form1.setFormat(1, fileform);
        form2.setFormat(0, fileform);
        Object[] testArgs = {new Long(12373), "MyDisk"};
        logln(form1.format(testArgs));
        logln(form2.format(testArgs));
    }
    /* @bug 4120552
     * MessageFormat.parse incorrectly sets errorIndex.
     */
    public void Test4120552()
View Full Code Here

            " client personnel.",
            " clients personnels."
        };
   
        for (int i=0; i<3; i++) {
            String out = mf.format(new Object[]{new Integer(i)});
            if (SUFFIX[i] == null) {
                if (!out.equals(PREFIX[i]))
                    errln("" + i + ": Got \"" + out + "\"; Want \"" + PREFIX[i] + "\"");
            }
            else {
View Full Code Here

   
    public void test4293229() {
        MessageFormat format = new MessageFormat("'''{'0}'' '''{0}'''");
        Object[] args = { null };
        String expected = "'{0}' '{0}'";
        String result = format.format(args);
        if (!result.equals(expected)) {
            throw new RuntimeException("wrong format result - expected \"" +
                    expected + "\", got \"" + result + "\"");
        }
    }
View Full Code Here

        try {
            logln("Apply with pattern : " + pattern1);
            messageFormatter.applyPattern(pattern1);
            HashMap paramsMap = new HashMap();
            paramsMap.put("arg0", new Integer(7));
            String tempBuffer = messageFormatter.format(paramsMap);
            if (!tempBuffer.equals("Impossible {arg1} has occurred -- status code is 7 and message is {arg2}."))
                errln("Tests arguments < substitution failed");
            logln("Formatted with 7 : " + tempBuffer);
            ParsePosition status = new ParsePosition(0);
            Map objs = messageFormatter.parseToMap(tempBuffer, status);
View Full Code Here

                String key = (String) keyIter.next();
                if (objs.get(key) != null && !objs.get(key).toString().equals(paramsMap.get(key).toString())) {
                    errln("Parse failed on object " + objs.get(key) + " with argument name : " + key );
                }
            }
            tempBuffer = messageFormatter.format(null);
            if (!tempBuffer.equals("Impossible {arg1} has occurred -- status code is {arg0} and message is {arg2}."))
                errln("Tests with no arguments failed");
            logln("Formatted with null : " + tempBuffer);
            logln("Apply with pattern : " + pattern2);
            messageFormatter.applyPattern(pattern2);
View Full Code Here

            logln("Formatted with null : " + tempBuffer);
            logln("Apply with pattern : " + pattern2);
            messageFormatter.applyPattern(pattern2);
            paramsMap.clear();
            paramsMap.put("ARG_ZERO", new Integer(7));
            tempBuffer = messageFormatter.format(paramsMap);
            if (!tempBuffer.equals("Double ' Quotes 7 test and quoted {ARG_ONE} test plus other {ARG_TWO} stuff."))
                errln("quote format test (w/ params) failed.");
            logln("Formatted with params : " + tempBuffer);
            tempBuffer = messageFormatter.format(null);
            if (!tempBuffer.equals("Double ' Quotes {ARG_ZERO} test and quoted {ARG_ONE} test plus other {ARG_TWO} stuff."))
View Full Code Here

            paramsMap.put("ARG_ZERO", new Integer(7));
            tempBuffer = messageFormatter.format(paramsMap);
            if (!tempBuffer.equals("Double ' Quotes 7 test and quoted {ARG_ONE} test plus other {ARG_TWO} stuff."))
                errln("quote format test (w/ params) failed.");
            logln("Formatted with params : " + tempBuffer);
            tempBuffer = messageFormatter.format(null);
            if (!tempBuffer.equals("Double ' Quotes {ARG_ZERO} test and quoted {ARG_ONE} test plus other {ARG_TWO} stuff."))
                errln("quote format test (w/ null) failed.");
            logln("Formatted with null : " + tempBuffer);
            logln("toPattern : " + messageFormatter.toPattern());
        } catch (Exception foo) {
View Full Code Here

        Map objs3 = new HashMap();
        objs3.put("arg", null);
        try {
            logln("pattern: \"" + mf.toPattern() + "\"");
            log("format(null) : ");
            logln("\"" + mf.format(objs1) + "\"");
            log("format({})   : ");
            logln("\"" + mf.format(objs2) + "\"");
            log("format({null}) :");
            logln("\"" + mf.format(objs3) + "\"");
        } catch (Exception e) {
View Full Code Here

        try {
            logln("pattern: \"" + mf.toPattern() + "\"");
            log("format(null) : ");
            logln("\"" + mf.format(objs1) + "\"");
            log("format({})   : ");
            logln("\"" + mf.format(objs2) + "\"");
            log("format({null}) :");
            logln("\"" + mf.format(objs3) + "\"");
        } catch (Exception e) {
            errln("Exception thrown for null argument tests.");
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.