Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / text / MessageFormat.js
1 Clazz.declarePackage("java.text");
2 c$=Clazz.decorateAsClass(function(){
3 this.pattern=null;
4 Clazz.instantialize(this,arguments);
5 },java.text,"MessageFormat");
6 Clazz.makeConstructor(c$,
7 function(pattern){
8 this.pattern=pattern;
9 },"~S");
10 Clazz.makeConstructor(c$,
11 function(pattern,locale){
12 this.pattern=pattern;
13 },"~S,java.util.Locale");
14 c$.format=Clazz.defineMethod(c$,"format",
15 function(pattern,args){
16 return pattern.replace(/\{(\d+)\}/g,function($0,$1){
17 var i=parseInt($1);
18 if(args==null)return null;
19 return args[i];
20 });
21 },"~S,~A");
22 Clazz.defineMethod(c$,"format",
23 function(obj){
24 return java.text.MessageFormat.format(this.pattern,[obj]);
25 },"~O");