@@ -28,10 +28,6 @@ Content
28
28
- [ How to use the builder I18NBindingBuilder] ( #HoToUsBiBu )
29
29
- [ How to use the builder I18NMessageBuilder] ( #HoToUsMeBu )
30
30
* [ Conventions] ( #Conventions )
31
- - [ Convention: 'baseBundleName' from ResourceBundle] ( #CoBaFrRe )
32
- - [ Convention: 'Key not found' in ResourceBundle] ( #CoKeInReBu )
33
- - [ Convention: Defined supported Locales, default and actual Locale] ( #CoDeSuDeAcLo )
34
- - [ Convention: Basic validation] ( #CoBaVa )
35
31
* [ Features] ( #Features )
36
32
* [ JavaDoc] ( #JavaDoc )
37
33
* [ Download] ( #Download )
@@ -245,7 +241,7 @@ public void lastStepWithoutArguments() {
245
241
.build();
246
242
assertEquals(" RB: Test title" , result);
247
243
}
248
-
244
+
249
245
@Test
250
246
public void lastStepWithArguments() {
251
247
I18NResourceBundleBuilder . configure()
@@ -276,243 +272,34 @@ Conventions<a name="Conventions" />
276
272
---
277
273
278
274
In this chapter, the interested developer can find out all about the conventions
279
- from the library ` Lib-I18N ` :
280
-
281
- ### Convention: 'baseBundleName' from ResourceBundle<a name =" CoBaFrRe " />
282
-
283
- If a [ ResourceBundle] with the defined 'baseBundleName' can't be found a spezific
284
- MissingResourceException will be thrown.
285
-
286
- ``` java
287
- public final class DefaultI18NResourceBundle implements I18NResourceBundle {
288
- ...
289
- private ResourceBundle getResourceBundle () {
290
- ResourceBundle bundle = null ;
291
- try {
292
- bundle = ResourceBundle . getBundle(this . getBaseBundleName(), this . getActualLocale());
293
- } catch (MissingResourceException mre) {
294
- LoggerFacade . getDefault(). error(this . getClass(),
295
- String . format(" Can't access the ResourceBundle[path=%s, actual-locale=%s]" ,
296
- this . getBaseBundleName(), this . getActualLocale(). getDisplayLanguage()),
297
- mre);
298
- }
299
-
300
- return bundle;
301
- }
302
- ...
303
- }
304
- ```
305
-
306
- ### Convention: 'Key not found' in ResourceBundle<a name =" CoKeInReBu " />
307
-
308
- If a key can't be found in the defined ResourceBundle then
309
- * the String pattern '< ; key> ; ' will returned instead and
310
- * the 'warning' message will be logged: "Can't find key(%s) in resourcebundle. Return: %s"
311
-
312
- ``` java
313
- public final class DefaultI18NResourceBundle implements I18NResourceBundle {
314
- ...
315
- @Override
316
- public String getMessage (final String key , final Object ... arguments ) {
317
- DefaultI18NValidator . requireNonNullAndNotEmpty(key);
318
- DefaultI18NValidator . requireNonNullAndNotEmpty(arguments);
319
- DefaultI18NValidator . requireResourceBundleExist(this . getBaseBundleName(), this . getActualLocale());
320
-
321
- final ResourceBundle bundle = getResourceBundle();
322
- String value = MessageFormat . format(PATTERN_KEY_NAME , key);
323
-
324
- if (bundle != null ) {
325
- try {
326
- value = MessageFormat . format(bundle. getString(key), arguments);
327
- } catch (MissingResourceException mre) {
328
- LoggerFacade . getDefault(). warn(this . getClass(),
329
- String . format(" Can't find key(%s) in resourcebundle. Return: %s" , key, value),
330
- mre);
331
- }
332
- }
333
-
334
- return value;
335
- }
336
- ...
337
- }
338
- ```
339
-
340
-
341
- ### Convention: Defined supported Locales, default and actual Locale<a name =" CoDeSuDeAcLo " />
342
-
343
- _ Supported Locales_
344
- * Defines all supported [ Locale] s in the momentary session.
345
-
346
- ``` java
347
- public final class I18NResourceBundleBuilder {
348
- ...
349
- private static final class I18NResourceBundleBuilderImpl implements
350
- FirstStep , ForthStep , LastStep , SecondStep , ThirdStep
351
- {
352
- ...
353
- @Override
354
- public ThirdStep supportedLocales (final Locale ... locales ) {
355
- LoggerFacade . getDefault(). debug(this . getClass(), " I18NResourceBundleBuilderImpl.supportedLocales(Locale...)" ); // NOI18N
356
-
357
- final List<Locale > list = Arrays . asList(locales);
358
- DefaultI18NValidator . requireNonNullAndNotEmpty(list);
359
-
360
- final ObservableList<Locale > observableList = FXCollections . observableArrayList();
361
- observableList. addAll(list);
362
- properties. put(ATTR__SUPPORTED_LOCALES , new SimpleObjectProperty (observableList));
363
-
364
- return this ;
365
- }
366
-
367
- @Override
368
- public ThirdStep supportedLocales (final ObservableList<Locale > locales ) {
369
- LoggerFacade . getDefault(). debug(this . getClass(), " I18NResourceBundleBuilderImpl.supportedLocales(ObservableList<Locale>)" ); // NOI18N
370
-
371
- DefaultI18NValidator . requireNonNullAndNotEmpty(locales);
372
- properties. put(ATTR__SUPPORTED_LOCALES , new SimpleObjectProperty (locales));
373
-
374
- return this ;
375
- }
376
- ...
377
- }
378
- }
379
- ```
380
-
381
- ``` java
382
- public final class I18NFacade implements I18NBinding , I18NResourceBundle {
383
- ...
384
- @Override
385
- public ObservableList<Locale > getSupportedLocales () {
386
- return i18NResourceBundle. getSupportedLocales();
387
- }
388
-
389
- @Override
390
- public void setSupportedLocales (final ObservableList<Locale > locales ) {
391
- i18NResourceBundle. setSupportedLocales(locales);
392
- }
393
-
394
- @Override
395
- public void setSupportedLocales (final Locale ... locales ) {
396
- i18NResourceBundle. setSupportedLocales(locales);
397
- }
398
- ...
399
- }
400
- ```
401
-
402
- ``` java
403
- public final class DefaultI18NResourceBundle implements I18NResourceBundle {
404
- ...
405
- @Override
406
- public ObservableList<Locale > getSupportedLocales () {
407
- DefaultI18NValidator . requireNonNull(supportedLocales);
408
-
409
- return supportedLocales;
410
- }
411
-
412
- @Override
413
- public void setSupportedLocales (final ObservableList<Locale > locales ) {
414
- DefaultI18NValidator . requireNonNullAndNotEmpty(locales);
415
-
416
- supportedLocales. clear();
417
- supportedLocales. addAll(locales);
418
- }
419
-
420
- @Override
421
- public void setSupportedLocales (final Locale ... locales ) {
422
- final List<Locale > list = Arrays . asList(locales);
423
- DefaultI18NValidator . requireNonNullAndNotEmpty(list);
424
-
425
- supportedLocales. clear();
426
- supportedLocales. addAll(list);
427
- }
428
- ...
429
- }
430
- ```
431
-
432
- _ Default Locale_
433
- * If the supported Locales doesn't contained the default Locale then the Locale#ENGLISH
275
+ in the library ` Lib-I18N ` :
276
+
277
+ __ Convention__ : 'baseBundleName' from ResourceBundle
278
+ * If a [ ResourceBundle] with the defined 'baseBundleName' can't be found a
279
+ MissingResourceException will be thrown.
280
+
281
+ __ Convention__ : 'Key not found' in ResourceBundle
282
+ * If a key can't be found in the defined ResourceBundle then
283
+ * the String pattern '< ; key> ; ' will returned instead and
284
+ * the 'warning' message will be logged: "Can't find key(%s) in resourcebundle. Return: %s"
285
+
286
+ __ Convention__ : Defined supported Locales, default and actual Locale.
287
+ * Supported Locales
288
+ Defines all supported [ Locale] s in the momentary session.
289
+ * Default Locale
290
+ If the supported Locales doesn't contained the default Locale then the Locale#ENGLISH
434
291
will be used instead.
435
-
436
- ``` java
437
- ```
438
-
439
- ``` java
440
- ```
441
-
442
- ``` java
443
- ```
444
-
445
- _ Actual Locale_
446
- * If the upported Locales doesn't contained the actual Locale then the default Locale
292
+ * Actual Locale
293
+ If the upported Locales doesn't contained the actual Locale then the default Locale
447
294
will be used instead.
448
295
449
- ``` java
450
- ```
451
-
452
-
453
- ### Convention: Basic validation<a name =" CoBaVa " />
454
-
455
- * Every ` functionality ` in the builders and in the default implementations will checked
456
- against minimal preconditions with the validator [ DefaultI18NValidator] .
457
- * ` Getters ` and ` Setters ` functionalities are only checked if they are initial only
458
- instantiate and not declarated.
296
+ __ Convention__ : Basic validation
297
+ * Every attributes in the builders and in all setters will be check against minimal
298
+ preconditions with [ DefaultI18NValidator] .
299
+ * Getters attributs will only checked if they are initial only instantiate and not
300
+ declarated.
459
301
* For example a String will be validate if it's not NULL and not EMPTY.
460
302
461
- ``` java
462
- public final class I18NResourceBundleBuilder {
463
- ...
464
- private static final class I18NResourceBundleBuilderImpl implements
465
- FirstStep , ForthStep , LastStep , SecondStep , ThirdStep
466
- {
467
- ...
468
- @Override
469
- public SecondStep baseBundleName (final String baseBundleName ) {
470
- LoggerFacade . getDefault(). debug(this . getClass(), " I18NResourceBundleBuilderImpl.baseBundleName(String)" ); // NOI18N
471
-
472
- DefaultI18NValidator . requireNonNullAndNotEmpty(baseBundleName);
473
- properties. put(ATTR__BASE_BUNDLE_NAME , new SimpleStringProperty (baseBundleName));
474
-
475
- return this ;
476
- }
477
- ...
478
- }
479
- }
480
- ```
481
-
482
- ``` java
483
- public final class DefaultI18NResourceBundle implements I18NResourceBundle {
484
- ...
485
- @Override
486
- public String getBaseBundleName () {
487
- DefaultI18NValidator . requireNonNullAndNotEmpty(baseBundleName);
488
-
489
- return baseBundleName;
490
- }
491
-
492
- @Override
493
- public void setBaseBundleName (final String baseBundleName ) {
494
- DefaultI18NValidator . requireNonNullAndNotEmpty(baseBundleName);
495
-
496
- this . baseBundleName = baseBundleName;
497
- }
498
- ...
499
- }
500
- ```
501
-
502
- ``` java
503
- public final class DefaultI18NBinding implements I18NBinding {
504
- ...
505
- @Override
506
- public StringBinding createStringBinding (final String key , Object ... arguments ) {
507
- DefaultI18NValidator . requireNonNullAndNotEmpty(key);
508
- DefaultI18NValidator . requireNonNullAndNotEmpty(arguments);
509
-
510
- return Bindings . createStringBinding(() - > I18NFacade . getDefault(). getMessage(key, arguments), I18NFacade . getDefault(). actualLocaleProperty());
511
- }
512
- ...
513
- }
514
- ```
515
-
516
303
517
304
518
305
Features<a name =" Features " />
0 commit comments