|
| 1 | +/******************************************************************************* |
| 2 | + * Java2Script Pacemaker (http://j2s.sourceforge.net) |
| 3 | + * |
| 4 | + * Copyright (c) 2006 ognize.com and others. |
| 5 | + * All rights reserved. This program and the accompanying materials |
| 6 | + * are made available under the terms of the Eclipse Public License v1.0 |
| 7 | + * which accompanies this distribution, and is available at |
| 8 | + * http://www.eclipse.org/legal/epl-v10.html |
| 9 | + * |
| 10 | + * Contributors: |
| 11 | + * ognize.com - initial API and implementation |
| 12 | + *******************************************************************************/ |
| 13 | + |
| 14 | +package java.text; |
| 15 | + |
| 16 | +import java.util.Locale; |
| 17 | + |
| 18 | + |
| 19 | +/** |
| 20 | + * @author zhou renjian |
| 21 | + * |
| 22 | + * 2006-10-10 |
| 23 | + */ |
| 24 | +public class MessageFormat { |
| 25 | + private String pattern; |
| 26 | + |
| 27 | + public MessageFormat(String pattern) { |
| 28 | + this.pattern = pattern; |
| 29 | + } |
| 30 | + |
| 31 | + public MessageFormat(String pattern, Locale locale) { |
| 32 | + this.pattern = pattern; |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * @j2sNativeSrc |
| 37 | + * return pattern.replace (/\{(\d+)\}/g, function ($0, $1) { |
| 38 | + * var i = parseInt ($1); |
| 39 | + * if (args == null) return null; |
| 40 | + * return args[i]; |
| 41 | + * }); |
| 42 | + * @j2sNative |
| 43 | + * return a.replace (/\{(\d+)\}/g, function ($0, $1) { |
| 44 | + * var i = parseInt ($1); |
| 45 | + * if (b == null) return null; |
| 46 | + * return b[i]; |
| 47 | + * }); |
| 48 | + */ |
| 49 | + public static String format(String pattern, Object[] args) { |
| 50 | + return pattern; |
| 51 | + } |
| 52 | + |
| 53 | + public final String format (Object obj) { |
| 54 | + return format(pattern, new Object[] { obj }); |
| 55 | + } |
| 56 | +} |
0 commit comments