Examples of ArgumentChunk


Examples of com.google.gwt.i18n.rebind.MessageFormatParser.ArgumentChunk

    try {
      for (TemplateChunk chunk : MessageFormatParser.parse(template)) {
        if (chunk.isLiteral()) {
          buf.appendStringLiteral(chunk.getString());
        } else if (chunk instanceof ArgumentChunk) {
          ArgumentChunk argChunk = (ArgumentChunk) chunk;
          int argNumber = argChunk.getArgumentNumber();
          if (argNumber >= params.length) {
            throw error(logger, "Argument " + argNumber
                + " beyond range of arguments: " + template);
          }
          seenFlag[argNumber] = true;
          String arg = "arg" + argNumber;
          String format = argChunk.getFormat();
          if (format != null) {
            String subformat = argChunk.getSubFormat();
            ValueFormatter formatter = formatters.get(format);
            if (formatter != null) {
              String err = formatter.format(buf, subformat, arg,
                  params[argNumber].getType());
              if (err != null) {
View Full Code Here

Examples of com.google.gwt.i18n.rebind.MessageFormatParser.ArgumentChunk

    try {
      for (TemplateChunk chunk : MessageFormatParser.parse(template)) {
        if (chunk.isLiteral()) {
          buf.appendStringLiteral(chunk.getString());
        } else if (chunk instanceof ArgumentChunk) {
          ArgumentChunk argChunk = (ArgumentChunk) chunk;
          int argNumber = argChunk.getArgumentNumber();
          if (argNumber >= params.length) {
            throw error(logger, "Argument " + argNumber
                + " beyond range of arguments: " + template);
          }
          seenFlag[argNumber] = true;
          String arg = "arg" + argNumber;
          String format = argChunk.getFormat();
          if (format != null) {
            String subformat = argChunk.getSubFormat();
            ValueFormatter formatter = formatters.get(format);
            if (formatter != null) {
              String err = formatter.format(buf, subformat, arg,
                  params[argNumber].getType());
              if (err != null) {
View Full Code Here

Examples of com.google.gwt.i18n.rebind.MessageFormatParser.ArgumentChunk

    // Generate code to format any lists
    // TODO(jat): handle messages with different list formats in alternate forms
    try {
      for (TemplateChunk chunk : MessageFormatParser.parse(template)) {
        if (chunk instanceof ArgumentChunk) {
          ArgumentChunk argChunk = (ArgumentChunk) chunk;
          if (argChunk.isList()) {
            ListAccessor listAccessor = null;
            int listArgNum = argChunk.getArgumentNumber();
            JType listType = params[listArgNum].getType();
            JClassType classType = listType.isInterface();
            JType elemType = null;
            if (classType != null) {
              if ("java.util.List".equals(
View Full Code Here

Examples of com.google.gwt.i18n.rebind.MessageFormatParser.ArgumentChunk

  public void testList() throws ParseException {
    String str = "{0,list:max=3,number:curcode=1:space,currency}";
    List<TemplateChunk> parsed = MessageFormatParser.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 = MessageFormatParser.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

Examples of com.google.gwt.i18n.rebind.MessageFormatParser.ArgumentChunk

    List<TemplateChunk> parsed = MessageFormatParser.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

Examples of com.google.gwt.i18n.rebind.MessageFormatParser.ArgumentChunk

    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

Examples of com.google.gwt.i18n.rebind.MessageFormatParser.ArgumentChunk

    try {
      for (TemplateChunk chunk : MessageFormatParser.parse(template)) {
        if (chunk.isLiteral()) {
          buf.appendStringLiteral(chunk.getString());
        } else if (chunk instanceof ArgumentChunk) {
          ArgumentChunk argChunk = (ArgumentChunk) chunk;
          int argNumber = argChunk.getArgumentNumber();
          if (argNumber >= params.length) {
            throw error(logger, "Argument " + argNumber
                + " beyond range of arguments: " + template);
          }
          seenFlag[argNumber] = true;
          String arg = "arg" + argNumber;
          String format = argChunk.getFormat();
          if (format != null) {
            String subformat = argChunk.getSubFormat();
            ValueFormatter formatter = formatters.get(format);
            if (formatter != null) {
              String err = formatter.format(buf, subformat, arg,
                  params[argNumber].getType());
              if (err != null) {
View Full Code Here

Examples of com.google.gwt.i18n.rebind.MessageFormatParser.ArgumentChunk

    try {
      for (TemplateChunk chunk : MessageFormatParser.parse(template)) {
        if (chunk.isLiteral()) {
          buf.appendStringLiteral(chunk.getString());
        } else if (chunk instanceof ArgumentChunk) {
          ArgumentChunk argChunk = (ArgumentChunk) chunk;
          int argNumber = argChunk.getArgumentNumber();
          if (argNumber >= params.length) {
            throw error(logger, "Argument " + argNumber
                + " beyond range of arguments: " + template);
          }
          seenFlag[argNumber] = true;
          String arg = params[argNumber].getName();
          String format = argChunk.getFormat();
          if (format != null) {
            String subformat = argChunk.getSubFormat();
            ValueFormatter formatter = formatters.get(format);
            if (formatter != null) {
              String err = formatter.format(buf, subformat, arg,
                  params[argNumber].getType());
              if (err != null) {
View Full Code Here

Examples of com.google.gwt.i18n.rebind.MessageFormatParser.ArgumentChunk

    try {
      for (TemplateChunk chunk : MessageFormatParser.parse(template)) {
        if (chunk.isLiteral()) {
          buf.appendStringLiteral(chunk.getString());
        } else if (chunk instanceof ArgumentChunk) {
          ArgumentChunk argChunk = (ArgumentChunk) chunk;
          int argNumber = argChunk.getArgumentNumber();
          if (argNumber >= params.length) {
            throw error(logger, "Argument " + argNumber
                + " beyond range of arguments: " + template);
          }
          seenFlag[argNumber] = true;
          String arg = "arg" + argNumber;
          String format = argChunk.getFormat();
          if (format != null) {
            String subformat = argChunk.getSubFormat();
            ValueFormatter formatter = formatters.get(format);
            if (formatter != null) {
              String err = formatter.format(buf, subformat, arg,
                  params[argNumber].getType());
              if (err != null) {
View Full Code Here

Examples of com.google.gwt.i18n.rebind.MessageFormatParser.ArgumentChunk

    // Generate code to format any lists
    // TODO(jat): handle messages with different list formats in alternate forms
    try {
      for (TemplateChunk chunk : MessageFormatParser.parse(template)) {
        if (chunk instanceof ArgumentChunk) {
          ArgumentChunk argChunk = (ArgumentChunk) chunk;
          if (argChunk.isList()) {
            ListAccessor listAccessor = null;
            int listArgNum = argChunk.getArgumentNumber();
            JType listType = params[listArgNum].getType();
            JClassType classType = listType.isInterface();
            JType elemType = null;
            if (classType != null) {
              if ("java.util.List".equals(
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.