MessageFormat.java :  » Scripting » java2script » java » text » Java Open Source

Java Open Source » Scripting » java2script 
java2script » java » text » MessageFormat.java
/*******************************************************************************
 * Copyright (c) 2007 java2script.org and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Zhou Renjian - initial API and implementation
 *******************************************************************************/

package java.text;

import java.util.Locale;


/**
 * @author zhou renjian
 *
 * 2006-10-10
 */
public class MessageFormat {
  private String pattern;
  
    public MessageFormat(String pattern) {
      this.pattern = pattern;
    }
    
    public MessageFormat(String pattern, Locale locale) {
      this.pattern = pattern;
    }

    /**
     * @j2sNativeSrc
     * return pattern.replace (/\{(\d+)\}/g, function ($0, $1) {
     *   var i = parseInt ($1);
     *   if (args == null) return null;
     *  return args[i];
     * });
     * @j2sNative
     * return a.replace (/\{(\d+)\}/g, function ($0, $1) {
     *   var i = parseInt ($1);
     *   if (b == null) return null;
     *  return b[i];
     * });
     */ 
    public static String format(String pattern, Object[] args) {
      return pattern;
    }
    
    public final String format (Object obj) {
      return format(pattern, new Object[] { obj });
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.