Package java.text

Examples of java.text.MessageFormat.applyPattern()


                            //System.out.println("LOCALE: " + locale);
                            if (locale != null) {
                                formatter.setLocale(locale);
                            }
                        }
      formatter.applyPattern(message);
      message = formatter.format(messageArgs);
        }
    } catch (MissingResourceException mre) {
        message = UNDEFINED_KEY + key + UNDEFINED_KEY;
    }
View Full Code Here


        if (args != null) {
      MessageFormat formatter = new MessageFormat("");
      if (locCtxt.getLocale() != null) {
          formatter.setLocale(locCtxt.getLocale());
      }
      formatter.applyPattern(message);
      message = formatter.format(args);
        }
    } catch (MissingResourceException mre) {
    }
      }
View Full Code Here

      harness.check (MessageFormat.format ("no variables", args),
         "no variables");

      harness.checkPoint ("quoted brace");
      mf.applyPattern ("no '{' variables");
      harness.check (myformat (mf, args, buf), "no { variables");
      harness.check (mf.toPattern (), "no '{' variables");

      harness.checkPoint ("one variable");
      mf.applyPattern ("the disk contains {0} files");
View Full Code Here

      mf.applyPattern ("no '{' variables");
      harness.check (myformat (mf, args, buf), "no { variables");
      harness.check (mf.toPattern (), "no '{' variables");

      harness.checkPoint ("one variable");
      mf.applyPattern ("the disk contains {0} files");
      args = new Object[1];
      args[0] = new Long (23);
      harness.check (myformat (mf, args, buf), "the disk contains 23 files");

      // Check to make sure excess args are ignored.
View Full Code Here

      // Check to make sure excess args are ignored.
      args = new Object[10];
      args[0] = new Long (27);
      harness.check (myformat (mf, args, buf), "the disk contains 27 files");

      mf.applyPattern ("the disk contains {0,number} files");
      harness.check (myformat (mf, args, buf), "the disk contains 27 files");
      args[0] = "zap";
      harness.check (myformat (mf, args, buf),
         "caught IllegalArgumentException");
View Full Code Here

      args[0] = "zap";
      harness.check (myformat (mf, args, buf),
         "caught IllegalArgumentException");

      args[0] = new Double (.99);
      mf.applyPattern ("the disk is {0,number,percent} full");
      harness.check (myformat (mf, args, buf),
         "the disk is 99% full");

      harness.checkPoint ("two variables");
      args = new Object[2];
View Full Code Here

      harness.checkPoint ("two variables");
      args = new Object[2];
      args[0] = "files";
      args[1] = new Long (29);
      mf.applyPattern ("the disk contains {1} {0}");
      harness.check (myformat (mf, args, buf), "the disk contains 29 files");

      // Check the case of missing args
      args = new Object[1];
      args[0] = "files";
View Full Code Here

      harness.check (myformat (mf, args, buf), "the disk contains 29 files");

      // Check the case of missing args
      args = new Object[1];
      args[0] = "files";
      mf.applyPattern ("the disk contains {1} {0}");
      harness.check (myformat (mf, args, buf), "the disk contains {1} files");
      args = null;
      harness.check (myformat (mf, args, buf), "the disk contains {1} {0}");

      args = new Object[1];
View Full Code Here

      harness.check (myformat (mf, args, buf), "the disk contains {1} {0}");

      args = new Object[1];
      harness.checkPoint ("choice format");
      args[0] = new Long (5);
      mf.applyPattern ("There {0,choice,0#are no files|1#is one file|1<are {0, number, integer} files}.");
      harness.check (myformat (mf, args, buf), "There are 5 files.");

      args[0] = new Double (10.23);
      mf.applyPattern ("Got {0,number,'#'.##}");
      harness.check (myformat (mf, args, buf), "Got #10.23");
View Full Code Here

      args[0] = new Long (5);
      mf.applyPattern ("There {0,choice,0#are no files|1#is one file|1<are {0, number, integer} files}.");
      harness.check (myformat (mf, args, buf), "There are 5 files.");

      args[0] = new Double (10.23);
      mf.applyPattern ("Got {0,number,'#'.##}");
      harness.check (myformat (mf, args, buf), "Got #10.23");

      // This tests for JDK compatibility.  Pointed out by libgcj
      // user.
      harness.checkPoint ("array argument");
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.