BBOS/src/bing/Bing.java
/**
	 * Internal use only, but for those who want to know it is a manual implemented java.text.MessageFormat.
	 */
Internal use only, but for those who want to know it is a manual implemented java.text.MessageFormat.
Internal use only but for those who want to know it is a manual implemented java . text . MessageFormat .
public static String format(String format, Object[] args)
	{
		int len = format.length();
		StringBuffer buf = new StringBuffer();
		boolean onFormat = false;
		for(int i = 0; i < len; i++)
		{
			char c;
			if(onFormat)
			{
				StringBuffer index = new StringBuffer();
				boolean hasIndex = false;
				String elementFormat = null;
				String styleFormat = null;
				for(int k = i; k < len; k++, i++)
				{
					c = format.charAt(k);
					if(c == '}')
					{
						onFormat = false;
						break;
					}
					else if(Character.isDigit(c) && !hasIndex)
					{
						index.append(c);
					}
					else
					{
						if(c != '}')
						{
							String sub = format.substring(k + 1, format.indexOf('}', k));
							int l = sub.length();
							k += l;
							i += l;
							if(sub.indexOf(',') != -1)
							{
								elementFormat = sub.substring(0, sub.indexOf(','));
								styleFormat = sub.substring(sub.indexOf(',') + 1);
							}
							else
							{
								elementFormat = sub;
							}
						}
						hasIndex = true;
					}
				}
				buf.append(inFormat(args[Integer.parseInt(index.toString())], elementFormat, styleFormat));
			}
			else
			{
				c = format.charAt(i);
				if(c == '{')
				{
					onFormat = true;
				}
				else
				{
					buf.append(c);
				}
			}
		}
		return buf.toString();
	}
public static String format ( String format , Object [ ] args ) { int len = format . length ( ) ; StringBuffer buf = new StringBuffer ( ) ; boolean onFormat = false ; for ( int i = 0 ; i < len ; i ++ ) { char c ; if ( onFormat ) { StringBuffer index = new StringBuffer ( ) ; boolean hasIndex = false ; String elementFormat = null ; String styleFormat = null ; for ( int k = i ; k < len ; k ++ , i ++ ) { c = format . charAt ( k ) ; if ( c == '}' ) { onFormat = false ; break ; } else if ( Character . isDigit ( c ) && ! hasIndex ) { index . append ( c ) ; } else { if ( c != '}' ) { String sub = format . substring ( k + 1 , format . indexOf ( '}' , k ) ) ; int l = sub . length ( ) ; k += l ; i += l ; if ( sub . indexOf ( ',' ) != - 1 ) { elementFormat = sub . substring ( 0 , sub . indexOf ( ',' ) ) ; styleFormat = sub . substring ( sub . indexOf ( ',' ) + 1 ) ; } else { elementFormat = sub ; } } hasIndex = true ; } } buf . append ( inFormat ( args [ Integer . parseInt ( index . toString ( ) ) ] , elementFormat , styleFormat ) ) ; } else { c = format . charAt ( i ) ; if ( c == '{' ) { onFormat = true ; } else { buf . append ( c ) ; } } } return buf . toString ( ) ; }
Internal use only, but for those who want to know it is a manual implemented java.text.MessageFormat.
Internal use only but for those who want to know it is a manual implemented java . text . MessageFormat .
//Until net.rim.device.api.i18n.MessageFormat supports the "number" property this has to be done manually.
