Mercurial > projects > dwt-linux
comparison dwt/dwthelper/ResourceBundle.d @ 219:9b4e6fc63930
utils updates
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Apr 2008 22:26:22 +0200 |
parents | a481ab32da3d |
children | 6da025bf255e |
comparison
equal
deleted
inserted
replaced
218:0a390aaee2ee | 219:9b4e6fc63930 |
---|---|
5 | 5 |
6 import tango.text.Util; | 6 import tango.text.Util; |
7 import tango.io.Stdout; | 7 import tango.io.Stdout; |
8 | 8 |
9 import dwt.DWT; | 9 import dwt.DWT; |
10 import dwt.dwthelper.utils; | |
10 | 11 |
11 class ResourceBundle { | 12 class ResourceBundle { |
12 | 13 |
13 char[][ char[] ] map; | 14 char[][ char[] ] map; |
14 | 15 |
33 char[] value; | 34 char[] value; |
34 nextline: | 35 nextline: |
35 while( dataIndex < data.length ){ | 36 while( dataIndex < data.length ){ |
36 //tango.io.Stdout.Stdout.formatln( "properties put {} startline", __LINE__ ); | 37 //tango.io.Stdout.Stdout.formatln( "properties put {} startline", __LINE__ ); |
37 readLine(); | 38 readLine(); |
38 line = line.trim(); | 39 line = dwt.dwthelper.utils.trim(line); |
39 if( line.length is 0 ){ | 40 if( line.length is 0 ){ |
40 //tango.io.Stdout.Stdout.formatln( "properties put {} was 0 length", __LINE__ ); | 41 //tango.io.Stdout.Stdout.formatln( "properties put {} was 0 length", __LINE__ ); |
41 continue; | 42 continue; |
42 } | 43 } |
43 if( line[0] == '#' ){ | 44 if( line[0] == '#' ){ |
93 if( iskeypart ){ | 94 if( iskeypart ){ |
94 // Cannot find '=' in record | 95 // Cannot find '=' in record |
95 DWT.error( __FILE__, __LINE__, DWT.ERROR_INVALID_ARGUMENT ); | 96 DWT.error( __FILE__, __LINE__, DWT.ERROR_INVALID_ARGUMENT ); |
96 continue; | 97 continue; |
97 } | 98 } |
98 key = key.trim(); | 99 key = dwt.dwthelper.utils.trim(key); |
99 value = value.trim(); | 100 value = dwt.dwthelper.utils.trim(value); |
100 //tango.io.Stdout.Stdout.formatln( "properties put {}=>{}", key, value ); | 101 //tango.io.Stdout.Stdout.formatln( "properties put {}=>{}", key, value ); |
101 | 102 |
102 map[ key.dup ] = value.dup; | 103 map[ key.dup ] = value.dup; |
103 //tango.io.Stdout.Stdout.formatln( "properties put {}", __LINE__ ); | 104 //tango.io.Stdout.Stdout.formatln( "properties put {}", __LINE__ ); |
104 } | 105 } |
110 | 111 |
111 public char[] getString( char[] key ){ | 112 public char[] getString( char[] key ){ |
112 if( auto v = key in map ){ | 113 if( auto v = key in map ){ |
113 return (*v).dup; | 114 return (*v).dup; |
114 } | 115 } |
115 return key; | 116 throw new MissingResourceException( "key not found", this.classinfo.name, key ); |
117 } | |
118 | |
119 public char[][] getKeys(){ | |
120 return map.keys; | |
116 } | 121 } |
117 | 122 |
118 public static ResourceBundle getBundle( char[] name ){ | 123 public static ResourceBundle getBundle( char[] name ){ |
119 return new ResourceBundle( null ); | 124 return new ResourceBundle( null ); |
120 } | 125 } |