Examples of AdvancedMessageFormat


Examples of org.apache.fop.util.text.AdvancedMessageFormat

    }

    @Test
    public void testChoiceFormatting() throws Exception {
        String msg;
        AdvancedMessageFormat format;

        format = new AdvancedMessageFormat(
                "You have {amount,choice,0#nothing|0<{amount} bucks|100<more than enough}.");

        Map params = new java.util.HashMap();

        params.put("amount", new Integer(0));
        msg = format.format(params);
        assertEquals("You have nothing.", msg);

        params.put("amount", new Integer(7));
        msg = format.format(params);
        assertEquals("You have 7 bucks.", msg);

        params.put("amount", new Integer(140));
        msg = format.format(params);
        assertEquals("You have more than enough.", msg);

    }
View Full Code Here

Examples of org.apache.fop.util.text.AdvancedMessageFormat

     * @param event the event
     * @param pattern the pattern (compatible with {@link AdvancedMessageFormat})
     * @return the formatted message
     */
    public static String format(Event event, String pattern) {
        AdvancedMessageFormat format = new AdvancedMessageFormat(pattern);
        Map params = new java.util.HashMap(event.getParams());
        params.put("source", event.getSource());
        params.put("severity", event.getSeverity());
        return format.format(params);
    }
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.