- Timestamp:
- 02/03/09 08:07:39 (13 years ago)
- Location:
- chess
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
chess/chess.jad
r9 r13 1 MIDlet-Jar-Size: 7162701 MIDlet-Jar-Size: 69346 2 2 MIDlet-Jar-URL: chess.jar 3 MIDlet-Name: Chess3 MIDlet-Name: chess 4 4 MIDlet-Vendor: I am 5 5 MIDlet-Version: 1.0 6 6 MicroEdition-Configuration: CLDC-1.1 7 7 MicroEdition-Profile: MIDP-2.1 8 Midlet-1: Chess, , chess.ui.ChessMIDlet -
chess/src/chess/MSG.java
r4 r13 8 8 /** 9 9 * Messages Bundle 10 * 10 11 * User: BegemoT<br/> 11 12 * Date: 29.01.2009<br/> … … 31 32 * parameter sign - '{0}', which is used to fill in a reason of the failure. 32 33 */ 33 private static final String _INIT_LOCALIZATION_ERROR_MSG = " __DEFAULT_ERROR__";34 private static final String _INIT_LOCALIZATION_ERROR_MSG = "Error init localization: {0}"; 34 35 35 36 /** … … 37 38 * with finding the appropriate localized message or any part of it. 38 39 */ 39 private static final String _DEFAULT_STRING = " __DEFAULT_STRING__";40 private static final String _DEFAULT_STRING = "Localization was not init"; 40 41 41 42 … … 132 133 * is returned 133 134 */ 134 public static finalString getMessage( String key ) {135 public static String getMessage( String key ) { 135 136 return getMessage( key, null ); 136 137 } … … 145 146 * is returned 146 147 */ 147 public static finalString getMessage( String key, Object[] args ) {148 public static String getMessage( String key, Object[] args ) { 148 149 if ( _messageTable == null ) { 149 150 if ( !initLocalizationSupport() ) { … … 151 152 } 152 153 } 153 StringBuffer toAppendTo = new StringBuffer();154 String s= ( String )_messageTable.get( key );155 if ( s== null ) {154 final StringBuffer toAppendTo = new StringBuffer(); 155 final String pattern = ( String )_messageTable.get( key ); 156 if ( pattern == null ) { 156 157 return _DEFAULT_STRING; 157 158 } 158 int l = s.length();159 final int l = pattern.length(); 159 160 int n = 0, lidx = -1, lastidx = 0; 160 161 for ( int i = 0; i < l; i++ ) { 161 if ( s.charAt( i ) == '{' ) {162 if ( pattern.charAt( i ) == '{' ) { 162 163 n++; 163 164 if ( n == 1 ) { 164 165 lidx = i; 165 toAppendTo.append( s.substring( lastidx, i ) );166 toAppendTo.append( pattern.substring( lastidx, i ) ); 166 167 lastidx = i; 167 168 } 168 169 } 169 if ( s.charAt( i ) == '}' ) {170 if ( pattern.charAt( i ) == '}' ) { 170 171 if ( n == 1 ) { 171 toAppendTo.append( _processPattern( s.substring( lidx + 1, i ), args ) );172 toAppendTo.append( _processPattern( pattern.substring( lidx + 1, i ), args ) ); 172 173 lidx = -1; 173 174 lastidx = i + 1; … … 177 178 } 178 179 if ( n > 0 ) { 179 toAppendTo.append( _processPattern( s.substring( lidx + 1 ), args ) );180 toAppendTo.append( _processPattern( pattern.substring( lidx + 1 ), args ) ); 180 181 } else { 181 toAppendTo.append( s.substring( lastidx ) );182 toAppendTo.append( pattern.substring( lastidx ) ); 182 183 } 183 184 … … 221 222 * @throws java.io.IOException if there is any problem with reading the messages 222 223 */ 223 private static synchronized void _loadMessages( InputStream inStream ) throws IOException {224 225 InputStreamReader in = new InputStreamReader( inStream );224 private static synchronized void _loadMessages( final InputStream inStream ) throws IOException { 225 226 final InputStreamReader in = new InputStreamReader( inStream ); 226 227 while ( true ) { 227 228 // Get next line … … 264 265 } 265 266 nextLine = nextLine.substring( startIndex, nextLine.length() ); 266 line = new String( loppedLine + nextLine );267 line = loppedLine + nextLine; 267 268 len = line.length(); 268 269 } … … 356 357 * @return resolved string 357 358 */ 358 private static String _convertString( String theString ) { 359 char aChar; 360 int len = theString.length(); 361 StringBuffer outBuffer = new StringBuffer( len ); 359 private static String _convertString( final String theString ) { 360 final int len = theString.length(); 361 final StringBuffer outBuffer = new StringBuffer( len ); 362 362 363 363 for ( int x = 0; x < len; ) { 364 aChar = theString.charAt( x++ );364 char aChar = theString.charAt( x++ ); 365 365 if ( aChar == '\\' ) { 366 366 aChar = theString.charAt( x++ ); … … 406 406 outBuffer.append( ( char )value ); 407 407 } else { 408 if ( aChar == 't' ) { 409 aChar = '\t'; 410 } else if ( aChar == 'r' ) { 411 aChar = '\r'; 412 } else if ( aChar == 'n' ) { 413 aChar = '\n'; 414 } else if ( aChar == 'f' ) { 415 aChar = '\f'; 416 } 408 switch ( aChar ) { 409 case 't': 410 aChar = '\t'; 411 break; 412 case 'r': 413 aChar = '\r'; 414 break; 415 case 'n': 416 aChar = '\n'; 417 break; 418 case 'f': 419 aChar = '\f'; 420 break; 421 } 422 417 423 outBuffer.append( aChar ); 418 424 } … … 431 437 * @return the indexString-th parameter from the array 432 438 */ 433 private static String _processPattern( String indexString, Object[] args ) { 439 private static String _processPattern( final String indexString, 440 final Object[] args ) { 434 441 try { 435 442 int index = Integer.parseInt( indexString ); -
chess/tests/chess/remote/DatagramTest.java
r9 r13 40 40 ), 41 41 new SystemAction( 42 SystemAction.YOUR_TURN _TYPE,42 SystemAction.YOUR_TURN, 43 43 Player.BLACK 44 44 ) … … 47 47 testWriteRead( 48 48 new SystemAction( 49 SystemAction.YOUR_TURN _TYPE,49 SystemAction.YOUR_TURN, 50 50 Player.BLACK 51 51 ), … … 67 67 new GenericDatagram( 68 68 new SystemAction( 69 SystemAction.YOUR_TURN _TYPE,69 SystemAction.YOUR_TURN, 70 70 Player.BLACK 71 71 ) … … 76 76 new GenericDatagram( 77 77 new SystemAction( 78 SystemAction.YOUR_TURN _TYPE,78 SystemAction.YOUR_TURN, 79 79 Player.BLACK 80 80 )
Note: See TracChangeset
for help on using the changeset viewer.