Package com.ibm.icu.text

Examples of com.ibm.icu.text.MessageFormat


    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.toPattern()'
     */
    public void testToPattern() {
        MessageFormat mf = new MessageFormat(altPattern);
        assertEquals(pattern, mf.toPattern());
    }
View Full Code Here


     */
    public void testSetFormats() {
        // this api, while it has the problem that the order of formats depends
        // on the order in the string, at least lets you set all the formats.
       
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        Format[] formats = {
            NumberFormat.getIntegerInstance(),
            DateFormat.getTimeInstance(DateFormat.SHORT),
            DateFormat.getDateInstance(),
        };
        mf.setFormats(formats);
        assertEquals(englishTarget, mf.format(args));
   }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.setFormat(int, Format)'
     */
    public void testSetFormat() {
        // and ok again       
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        mf.setFormat(1, DateFormat.getTimeInstance(DateFormat.LONG));
        assertEquals(modifiedTarget, mf.format(args));
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.getFormats()'
     */
    public void testGetFormats() {
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        Format[] formats = mf.getFormats();
        NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
        assertEquals(formats[0], nf);
        DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US);
        assertEquals(formats[1], tf);
        DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.US);
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.format(Object[], StringBuffer, FieldPosition)'
     */
    public void testFormatObjectArrayStringBufferFieldPosition() {
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        StringBuffer buf = new StringBuffer();
        FieldPosition fp = new FieldPosition(0);
        mf.format(args, buf, fp);
        assertEquals(englishTarget, buf.toString());
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.format(Object, StringBuffer, FieldPosition)'
     */
    public void testFormatObjectStringBufferFieldPosition() {
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        StringBuffer buf = new StringBuffer();
        FieldPosition fp = new FieldPosition(0);
        mf.format((Object)args, buf, fp);
        assertEquals(englishTarget, buf.toString());
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.parse(String, ParsePosition)'
     */
    public void testParseStringParsePosition() {
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        ParsePosition pp = new ParsePosition(1);
        Object[] result = mf.parse("!" + englishTarget, pp);
        assertEquals(num, result[0]);
        assertEquals(dateOnly, result[1]);
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.parse(String)'
     */
    public void testParseString() {
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        try {
            Object[] result = mf.parse(englishTarget);
            assertEquals(num, result[0]);
            assertEquals(dateOnly, result[1]);
        }
        catch (ParseException e) {
            fail(e.getMessage());
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.parseObject(String, ParsePosition)'
     */
    public void testParseObjectStringParsePosition() {
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        ParsePosition pp = new ParsePosition(0);
        Object result = mf.parseObject(englishTarget, pp);
        assertEquals(num, ((Object[])result)[0]);
        assertEquals(dateOnly, ((Object[])result)[1]);
    }
View Full Code Here

     * Test method for 'com.ibm.icu.text.MessageFormat.autoQuoteApostrophe(String)'
     */
    public void testAutoQuoteApostrophe() {
        String str = "Let's meet at {1,time,h 'o'' clock'} at l'Orange Bleue";
        String pat = MessageFormat.autoQuoteApostrophe(str);
        MessageFormat mf = new MessageFormat(pat, Locale.US);
        String result = mf.format(args);
        assertEquals("Let's meet at 8 o' clock at l'Orange Bleue", result);
        assertEquals("Let''s meet at {1,time,h 'o'' clock'} at l''Orange Bleue", pat);
    }
View Full Code Here

TOP

Related Classes of com.ibm.icu.text.MessageFormat

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.