Package java.text

Examples of java.text.MessageFormat.applyPattern()


      harness.check (myformat (mf, args, buf), "Got #10.23");

      // This tests for JDK compatibility.  Pointed out by libgcj
      // user.
      harness.checkPoint ("array argument");
      mf.applyPattern ("test Message = {0}");
      args = new Object[1];
      args[0] = "a jolly string";
      harness.check (mf.format ((Object) args),
         "test Message = a jolly string");
View Full Code Here


      args[0] = "a jolly string";
      harness.check (mf.format ((Object) args),
         "test Message = a jolly string");

      harness.checkPoint("choice format in message format");
      mf.applyPattern("{0,choice,0#0 tasks|1#{0,number,integer} task|1<{0,number,integer} tasks}, {1,choice,0#0 errors|1#{1,number,integer} error|1<{1,number,integer} errors}");
      args = new Object[2];
      args[0] = new Integer(0);
      args[1] = new Integer(1);
      buf = new StringBuffer();
      mf.format(args, buf, null);
View Full Code Here

      pp.setIndex(0);
      val = mf.parse ("no variables", pp);
      harness.check (val.length, 0);

      harness.checkPoint ("one variable");
      mf.applyPattern ("I have seen zardoz number {0}.");

      pp.setIndex(0);
      val = mf.parse ("I have seen zardoz number 23.", pp);
      harness.check (val.length, 1);
      harness.check (val[0] instanceof String);
View Full Code Here

      harness.check (val.length, 1);
      harness.check (val[0] instanceof String);
      harness.check ((String) (val[0]), "23");

      harness.checkPoint ("number format");
      mf.applyPattern ("I have seen zardoz number {0,number}!");

      pp.setIndex(0);
      val = mf.parse ("I have seen zardoz number 23!", pp);
      harness.check (val.length, 1);
      harness.check (val[0] instanceof Number);
View Full Code Here

      harness.check (val.length, 1);
      harness.check (val[0] instanceof Number);
      harness.check (((Number) (val[0])).longValue (), 23);

      harness.checkPoint ("greedy string matching at end");
      mf.applyPattern ("/foo/{0}");

      pp.setIndex(0);
      val = mf.parse ("/foo/bar", pp);
      harness.check (val.length, 1);
      harness.check (val[0] instanceof String);
View Full Code Here

    }
  }
  if (msgs != null) {
    try {
      MessageFormat formatter = new MessageFormat("");     
      formatter.applyPattern(msgs.getString(key));     
      answer = formatter.format(args);
    } catch (MissingResourceException ex2) {}
  }
  return answer;
}
View Full Code Here

                args = NO_ARGS;
            }

            MessageFormat messageFormat = new MessageFormat( "" );
            messageFormat.setLocale( locale );
            messageFormat.applyPattern( value );

            return messageFormat.format( args );
        }

        private String getStringOrNull( ResourceBundle rb, String key )
View Full Code Here

        MessageFormatKey key = new MessageFormatKey(pattern, locale);
        MessageFormat format = messageFormats.get(key);
        if (format == null) {
            format = new MessageFormat(pattern);
            format.setLocale(locale);
            format.applyPattern(pattern);
            messageFormats.put(key, format);
        }

        return format;
    }
View Full Code Here

        buffer.append(locale);
        buffer.append("]");
        MessageFormat mf = new MessageFormat(pattern);
        if (locale != null) {
            mf.setLocale(locale);
            mf.applyPattern(pattern);
        }
        // System.out.println(buffer + ", result=[" + mf.format(args) +"]");
        ExtendedMessageFormat emf = null;
        if (locale == null) {
            emf = new ExtendedMessageFormat(pattern);
View Full Code Here

        // this up by providing the Locale along with the string in the
        // constructor to MessageFormat.  Until 1.4, the following workaround
        // is required for constructing the format with the appropriate locale:
        MessageFormat messageFormat = new MessageFormat("");
        messageFormat.setLocale(locale);
        messageFormat.applyPattern(value);
        return messageFormat.format(args);
    }
}
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.