|
Lines 79-92
Link Here
|
| 79 |
|
79 |
|
| 80 |
/** the 'raw' content of the resource. In case of a text resource (charset |
80 |
/** the 'raw' content of the resource. In case of a text resource (charset |
| 81 |
* was given) the content is UTF-8 encoded. */ |
81 |
* was given) the content is UTF-8 encoded. */ |
| 82 |
private final int[] content; |
82 |
private final byte[] content; |
| 83 |
/** the charset in which the resource was encoded before read or null for |
83 |
/** the charset in which the resource was encoded before read or null for |
| 84 |
* binary resources. */ |
84 |
* binary resources. */ |
| 85 |
private final String charset; |
85 |
private final String charset; |
| 86 |
/** the resource's version or null for 'no version' */ |
86 |
/** the resource's version or null for 'no version' */ |
| 87 |
private final Integer version; |
87 |
private final Integer version; |
| 88 |
|
88 |
|
| 89 |
public Resource( int[] content, String charset, Integer version ) { |
89 |
public Resource( byte[] content, String charset, Integer version ) { |
| 90 |
this.charset = charset; |
90 |
this.charset = charset; |
| 91 |
this.content = content; |
91 |
this.content = content; |
| 92 |
this.version = version; |
92 |
this.version = version; |
|
Lines 96-102
Link Here
|
| 96 |
return charset; |
96 |
return charset; |
| 97 |
} |
97 |
} |
| 98 |
|
98 |
|
| 99 |
public int[] getContent() { |
99 |
public byte[] getContent() { |
| 100 |
return content; |
100 |
return content; |
| 101 |
} |
101 |
} |
| 102 |
|
102 |
|
|
Lines 131-139
Link Here
|
| 131 |
* @return the content of the resource or <code>null</code> if no resource |
131 |
* @return the content of the resource or <code>null</code> if no resource |
| 132 |
* with the given <code>name</code> and <code>version</code> exists. |
132 |
* with the given <code>name</code> and <code>version</code> exists. |
| 133 |
*/ |
133 |
*/ |
| 134 |
public int[] findResource( String name, Integer version ) { |
134 |
public byte[] findResource( String name, Integer version ) { |
| 135 |
ParamCheck.notNull( name, "name" ); |
135 |
ParamCheck.notNull( name, "name" ); |
| 136 |
int[] result = null; |
136 |
byte[] result = null; |
| 137 |
Resource resource = ( Resource )cache.get( createKey( name ) ); |
137 |
Resource resource = ( Resource )cache.get( createKey( name ) ); |
| 138 |
if( resource != null ) { |
138 |
if( resource != null ) { |
| 139 |
if( ( version == null && resource.getVersion() == null ) |
139 |
if( ( version == null && resource.getVersion() == null ) |
|
Lines 197-203
Link Here
|
| 197 |
ParamCheck.notNull( is, "is" ); |
197 |
ParamCheck.notNull( is, "is" ); |
| 198 |
String key = createKey( name ); |
198 |
String key = createKey( name ); |
| 199 |
try { |
199 |
try { |
| 200 |
int[] content = ResourceUtil.readBinary( is ); |
200 |
byte[] content = ResourceUtil.readBinary( is ); |
| 201 |
doRegister( name, null, RegisterOptions.NONE, key, content ); |
201 |
doRegister( name, null, RegisterOptions.NONE, key, content ); |
| 202 |
} catch ( IOException e ) { |
202 |
} catch ( IOException e ) { |
| 203 |
String text = "Failed to register resource ''{0}''."; |
203 |
String text = "Failed to register resource ''{0}''."; |
|
Lines 215-221
Link Here
|
| 215 |
boolean compress = shouldCompress( options ); |
215 |
boolean compress = shouldCompress( options ); |
| 216 |
String key = createKey( name ); |
216 |
String key = createKey( name ); |
| 217 |
try { |
217 |
try { |
| 218 |
int[] content = ResourceUtil.read( is, charset, compress ); |
218 |
byte[] content = ResourceUtil.read( is, charset, compress ); |
| 219 |
doRegister( name, charset, options, key, content ); |
219 |
doRegister( name, charset, options, key, content ); |
| 220 |
} catch ( IOException ioe ) { |
220 |
} catch ( IOException ioe ) { |
| 221 |
String msg = "Failed to register resource: " + name; |
221 |
String msg = "Failed to register resource: " + name; |
|
Lines 361-367
Link Here
|
| 361 |
if( !repository.containsKey( key ) ) { |
361 |
if( !repository.containsKey( key ) ) { |
| 362 |
boolean compress = shouldCompress( options ); |
362 |
boolean compress = shouldCompress( options ); |
| 363 |
try { |
363 |
try { |
| 364 |
int[] content = ResourceUtil.read( name, charset, compress, this ); |
364 |
byte[] content = ResourceUtil.read( name, charset, compress, this ); |
| 365 |
doRegister( name, charset, options, key, content ); |
365 |
doRegister( name, charset, options, key, content ); |
| 366 |
} catch ( IOException e ) { |
366 |
} catch ( IOException e ) { |
| 367 |
String text = "Failed to register resource ''{0}''."; |
367 |
String text = "Failed to register resource ''{0}''."; |
|
Lines 376-382
Link Here
|
| 376 |
String charset, |
376 |
String charset, |
| 377 |
RegisterOptions options, |
377 |
RegisterOptions options, |
| 378 |
String key, |
378 |
String key, |
| 379 |
int[] content ) |
379 |
byte[] content ) |
| 380 |
throws IOException |
380 |
throws IOException |
| 381 |
{ |
381 |
{ |
| 382 |
Integer version = computeVersion( content, options ); |
382 |
Integer version = computeVersion( content, options ); |
|
Lines 407-413
Link Here
|
| 407 |
} |
407 |
} |
| 408 |
} |
408 |
} |
| 409 |
|
409 |
|
| 410 |
private static Integer computeVersion( int[] content, RegisterOptions options ) { |
410 |
private static Integer computeVersion( byte[] content, RegisterOptions options ) { |
| 411 |
Integer result = null; |
411 |
Integer result = null; |
| 412 |
if( content != null && shouldVersion( options ) ) { |
412 |
if( content != null && shouldVersion( options ) ) { |
| 413 |
int version = 0; |
413 |
int version = 0; |