comparison base/src/java/util/ResourceBundle.d @ 120:536e43f63c81

Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661 ===D2=== * added [Try]Immutable/Const/Shared templates to work with differenses in D1/D2 instead of version statements used these templates to work with strict type storage rules of dmd-2.053 * com.ibm.icu now also compilable with D2, but not tested yet * small fixes Snippet288 - shared data is in TLS ===Phobos=== * fixed critical bugs in Phobos implemention completely incorrect segfault prone fromStringz (Linux's port ruthless killer) terrible, incorrect StringBuffer realization (StyledText killer) * fixed small bugs as well Snippet72 - misprint in the snippet * implemented missed functionality for Phobos ByteArrayOutputStream implemented (image loading available) formatting correctly works for all DWT's cases As a result, folowing snippets now works with Phobos (Snippet### - what is fixed): Snippet24, 42, 111, 115, 130, 235, 276 - bad string formatting Snippet48, 282 - crash on image loading Snippet163, 189, 211, 213, 217, 218, 222 - crash on copy/cut in StyledText Snippet244 - hang-up ===Tango=== * few changes for the latest Tango trunc-r5661 * few small performance improvments ===General=== * implMissing-s for only one version changed to implMissingInTango/InPhobos * incorrect calls to Format in toString-s fixed * fixed loading \uXXXX characters in ResourceBundle * added good UTF-8 support for StyledText, TextLayout (Win32) and friends UTF functions revised and tested. It is now in java.nonstandard.*Utf modules StyledText and TextLayout (Win32) modules revised for UTF-8 support * removed small diferences in most identical files in *.swt.* folders *.swt.internal.image, *.swt.events and *.swt.custom are identical in Win32/Linux32 now 179 of 576 (~31%) files in *.swt.* folders are fully identical * Win32: snippets now have right subsystem, pretty icons and native system style controls * small fixes in snippets Snippet44 - it's not Snippet44 Snippet212 - functions work with different images and offsets arrays Win32: Snippet282 - crash on close if the button has an image Snippet293 - setGrayed is commented and others Win32: As a result, folowing snippets now works Snippet68 - color doesn't change Snippet163, 189, 211, 213, 217, 218, 222 - UTF-8 issues (see above) Snippet193 - no tabel headers
author Denis Shelomovskij <verylonglogin.reg@gmail.com>
date Sat, 09 Jul 2011 15:50:20 +0300
parents 3daece18b48e
children
comparison
equal deleted inserted replaced
119:d00e8db0a568 120:536e43f63c81
11 import java.nonstandard.Locale; 11 import java.nonstandard.Locale;
12 version(Tango){ 12 version(Tango){
13 //import tango.text.Util; 13 //import tango.text.Util;
14 import tango.io.device.File; 14 import tango.io.device.File;
15 } else { // Phobos 15 } else { // Phobos
16 import std.file; 16 static import std.file;
17 } 17 }
18 18
19 19
20 class ResourceBundle { 20 class ResourceBundle {
21 21
22 String[ String ] map; 22 String[ String ] map;
23 23
24 /++ 24 /++
25 + First entry is the default entry if no maching locale is found 25 + First entry is the default entry if no maching locale is found
26 +/ 26 +/
27 public this( ImportData[] data ){ 27 public this( in ImportData[] data ){
28 char[] name = caltureName.dup; 28 char[] name = caltureName.dup;
29 if( name.length is 5 && name[2] is '-' ){ 29 if( name.length is 5 && name[2] is '-' ){
30 name[2] = '_'; 30 name[2] = '_';
31 char[] end = "_" ~ name ~ ".properties"; 31 char[] end = "_" ~ name ~ ".properties";
32 foreach( entry; data ){ 32 foreach( entry; data ){
46 } 46 }
47 } 47 }
48 //Trace.formatln( "ResourceBundle default" ); 48 //Trace.formatln( "ResourceBundle default" );
49 initialize( cast(String)data[0].data ); 49 initialize( cast(String)data[0].data );
50 } 50 }
51 public this( ImportData data ){ 51 public this( in ImportData data ){
52 initialize( cast(String)data.data ); 52 initialize( cast(String)data.data );
53 } 53 }
54 public this( String data ){ 54 public this( String data ){
55 initialize( data ); 55 initialize( data );
56 } 56 }
99 case 't' : c = '\t'; break; 99 case 't' : c = '\t'; break;
100 case 'n' : c = '\n'; break; 100 case 'n' : c = '\n'; break;
101 case '\\': c = '\\'; break; 101 case '\\': c = '\\'; break;
102 case '\"': c = '\"'; break; 102 case '\"': c = '\"'; break;
103 case 'u' : 103 case 'u' :
104 dchar d = Integer.parseInt( line[ pos+1 .. pos+5 ], 16 ); 104 c = Integer.parseInt( line[ pos+1 .. pos+5 ], 16 );
105 pos += 4; 105 pos += 4;
106 break; 106 break;
107 default: break; 107 default: break;
108 } 108 }
109 } 109 }
135 throw new RuntimeException( __FILE__, __LINE__, "Cannot find = in record" ); 135 throw new RuntimeException( __FILE__, __LINE__, "Cannot find = in record" );
136 } 136 }
137 key = java.lang.util.trim(key); 137 key = java.lang.util.trim(key);
138 value = java.lang.util.trim(value); 138 value = java.lang.util.trim(value);
139 139
140 version(D_Version2){ 140 map[ _idup(key) ] = _idup(value);
141 map[ key.idup ] = value.idup;
142 } else {
143 map[ key.dup ] = value.dup;
144 }
145 } 141 }
146 } 142 }
147 143
148 public bool hasString( CString key ){ 144 public bool hasString( String key ){
149 return ( key in map ) !is null; 145 return ( key in map ) !is null;
150 } 146 }
151 147
152 public String getString( CString key ){ 148 public String getString( String key ){
153 if( auto v = key in map ){ 149 if( auto v = key in map ){
154 version(D_Version2){ 150 return _idup(*v);
155 return (*v).idup;
156 } else {
157 return (*v).dup;
158 }
159 } 151 }
160 throw new MissingResourceException( "key not found", this.classinfo.name, key._idup() ); 152 throw new MissingResourceException( "key not found", this.classinfo.name, key._idup() );
161 } 153 }
162 154
163 public Enumeration getKeys(){ 155 public Enumeration getKeys(){
166 } 158 }
167 public String[] getKeysAsArray(){ 159 public String[] getKeysAsArray(){
168 return map.keys; 160 return map.keys;
169 } 161 }
170 162
171 public static ResourceBundle getBundle( ImportData[] data ){ 163 public static ResourceBundle getBundle( in ImportData[] data ){
172 return new ResourceBundle( data ); 164 return new ResourceBundle( data );
173 } 165 }
174 public static ResourceBundle getBundle( ImportData data ){ 166 public static ResourceBundle getBundle( in ImportData data ){
175 return new ResourceBundle( data ); 167 return new ResourceBundle( data );
176 } 168 }
177 public static ResourceBundle getBundle( CString name ){ 169 public static ResourceBundle getBundle( String name ){
178 try{ 170 try{
179 version(Tango){ 171 version(Tango){
180 return new ResourceBundle( cast(String) File.get(name) ); 172 return new ResourceBundle( cast(String) File.get(name) );
181 } else { // Phobos 173 } else { // Phobos
182 return new ResourceBundle( cast(String) std.file.read(name) ); 174 return new ResourceBundle( cast(String) std.file.read(name) );