Package com.google.gwt.i18n.server.MessageFormatUtils

Examples of com.google.gwt.i18n.server.MessageFormatUtils.ArgumentChunk


    String str = "You have {#} widgets";
    List<TemplateChunk> parsed = MessageStyle.MESSAGE_FORMAT.parse(str);
    assertEquals(3, parsed.size());
    StringChunk stringChunk = (StringChunk) parsed.get(0);
    assertEquals("You have ", stringChunk.getString());
    ArgumentChunk argChunk = (ArgumentChunk) parsed.get(1);
    assertEquals(-1, argChunk.getArgumentNumber());
    assertEquals("{#}", argChunk.getAsMessageFormatString());
    stringChunk = (StringChunk) parsed.get(2);
    assertEquals(" widgets", stringChunk.getString());
  }
View Full Code Here


    List<TemplateChunk> parsed = MessageStyle.MESSAGE_FORMAT.parse(str);
    assertEquals(1, parsed.size());
    TemplateChunk chunk = parsed.get(0);
    assertFalse(chunk.isLiteral());
    assertEquals("{0}", chunk.getString());
    ArgumentChunk argChunk = (ArgumentChunk) chunk;
    assertEquals(0, argChunk.getArgumentNumber());
    assertNull(argChunk.getFormat());
    assertNull(argChunk.getSubFormat());
  }
View Full Code Here

    assertTrue(chunk.isLiteral());
    assertEquals("Message ", chunk.getString());
    chunk = parsed.get(1);
    assertFalse(chunk.isLiteral());
    assertEquals("{0}", chunk.getString());
    ArgumentChunk argChunk = (ArgumentChunk) chunk;
    assertEquals(0, argChunk.getArgumentNumber());
    assertNull(argChunk.getFormat());
    assertNull(argChunk.getSubFormat());
    chunk = parsed.get(2);
    assertTrue(chunk.isLiteral());
    assertEquals(" has one arg, {0}", chunk.getString());
  }
View Full Code Here

  public void testList() throws ParseException {
    String str = "{0,list:max=3,number:curcode=1:space,currency}";
    List<TemplateChunk> parsed = MessageStyle.MESSAGE_FORMAT.parse(str);
    assertEquals(1, parsed.size());
    ArgumentChunk chunk = (ArgumentChunk) parsed.get(0);
    assertTrue(chunk.isList());
    assertEquals("number", chunk.getFormat());
    assertEquals("currency", chunk.getSubFormat());
    Map<String, String> args = chunk.getListArgs();
    assertEquals(1, args.size());
    assertEquals("3", args.get("max"));
    args = chunk.getFormatArgs();
    assertEquals(2, args.size());
    assertEquals("1", args.get("curcode"));
    assertEquals("", args.get("space"));

    str = "{0,list,number}";
    parsed = MessageStyle.MESSAGE_FORMAT.parse(str);
    assertEquals(1, parsed.size());
    chunk = (ArgumentChunk) parsed.get(0);
    assertTrue(chunk.isList());
    assertEquals("number", chunk.getFormat());
    assertNull(chunk.getSubFormat());
    args = chunk.getListArgs();
    assertEquals(0, args.size());
    args = chunk.getFormatArgs();
    assertEquals(0, args.size());
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.i18n.server.MessageFormatUtils.ArgumentChunk

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.