/
customoptions.po
1093 lines (987 loc) · 32.1 KB
/
customoptions.po
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Language zh-CN translations for PACKAGE package.
# Automatically generated, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2011-11-14 10:37+0000\n"
"PO-Revision-Date: 2011-02-11 14:56+0000\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: zh-CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: customoptions.xml:24
#, no-c-format
msgid "Hibernate Validator Specifics"
msgstr ""
#. Tag: para
#: customoptions.xml:26
#, no-c-format
msgid ""
"In the following sections we are having a closer look at some of the "
"Hibernate Validator specific features (features which are not part of the "
"Bean Validation specification). This includes the fail fast mode, the "
"programmatic constraint configuration API and boolean composition of "
"composing constraints."
msgstr ""
#. Tag: para
#: customoptions.xml:33
#, no-c-format
msgid ""
"The features described in the following sections are not portable between "
"Bean Validation providers/implementations."
msgstr ""
#. Tag: title
#: customoptions.xml:38
#, no-c-format
msgid "Public API"
msgstr ""
#. Tag: para
#: customoptions.xml:40
#, no-c-format
msgid ""
"Let's start, however, with a look at the public API of Hibernate Validator. "
"<xref linkend=\"validator-public-api\"/> lists all packages belonging to "
"this API and describes their purpose."
msgstr ""
#. Tag: para
#: customoptions.xml:44
#, no-c-format
msgid ""
"Any packages not listed in that table are internal packages of Hibernate "
"Validator and are not intended to be accessed by clients. The contents of "
"these internal packages can change from release to release without notice, "
"thus possibly breaking any client code relying on it."
msgstr ""
#. Tag: para
#: customoptions.xml:51
#, no-c-format
msgid ""
"In the following table, when a package is public its not necessarily true "
"for its nested packages."
msgstr ""
#. Tag: title
#: customoptions.xml:56
#, no-c-format
msgid "Hibernate Validator public API"
msgstr ""
#. Tag: entry
#: customoptions.xml:61
#, no-c-format
msgid "Packages"
msgstr ""
#. Tag: entry
#: customoptions.xml:63
#, no-c-format
msgid "Description"
msgstr ""
#. Tag: package
#: customoptions.xml:69
#, no-c-format
msgid "org.hibernate.validator"
msgstr ""
#. Tag: entry
#: customoptions.xml:71
#, no-c-format
msgid ""
"This package contains the classes used by the Bean Validation bootstrap "
"mechanism (eg. validation provider, configuration class). For more details "
"see <xref linkend=\"validator-bootstrapping\"/>."
msgstr ""
#. Tag: entry
#: customoptions.xml:78
#, no-c-format
msgid ""
"<package>org.hibernate.validator.cfg</package>, <package>org.hibernate."
"validator.cfg.context</package>, <package>org.hibernate.validator.cfg.defs</"
"package>"
msgstr ""
#. Tag: entry
#: customoptions.xml:82
#, no-c-format
msgid ""
"With Hibernate Validator you can define constraints via a fluent API. These "
"packages contain all classes needed to use this feature. In the package "
"<package>org.hibernate.validator.cfg</package> you will find the "
"<classname>ConstraintMapping</classname> class and in package <package>org."
"hibernate.validator.cfg.defs</package> all constraint definitions. For more "
"details see <xref linkend=\"programmaticapi\"/>."
msgstr ""
#. Tag: package
#: customoptions.xml:93
#, no-c-format
msgid "org.hibernate.validator.constraints"
msgstr ""
#. Tag: entry
#: customoptions.xml:95
#, no-c-format
msgid ""
"In addition to Bean Validation constraints, Hibernate Validator provides "
"some useful custom constraints. This package contains all custom annotation "
"classes. For more details see <xref linkend=\"validator-defineconstraints-hv-"
"constraints\"/>."
msgstr ""
#. Tag: package
#: customoptions.xml:102
#, no-c-format
msgid "org.hibernate.validator.group"
msgstr ""
#. Tag: entry
#: customoptions.xml:104
#, no-c-format
msgid ""
"With Hibernate Validator you can define dynamic default group sequences in "
"function of the validated object state. This package contains all classes "
"needed to use this feature (<classname>GroupSequenceProvider</classname> "
"annotation and <classname>DefaultGroupSequenceProvider</classname> "
"contract). For more details see <xref linkend=\"section-default-group-class"
"\"/>."
msgstr ""
#. Tag: entry
#: customoptions.xml:114
#, no-c-format
msgid ""
"<package>org.hibernate.validator.messageinterpolation</package>, "
"<package>org.hibernate.validator.resourceloading</package>"
msgstr ""
#. Tag: entry
#: customoptions.xml:117
#, no-c-format
msgid ""
"These packages contain the classes related to constraint message "
"interpolation. The first package contains two implementations of "
"<classname>MessageInterpolator</classname>. The first one, "
"<classname>ValueFormatterMessageInterpolator</classname> allows to "
"interpolate the validated value into the constraint message, see <xref "
"linkend=\"section-message-interpolator\"/>. The second implementation named "
"<classname>ResourceBundleMessageInterpolator</classname> is the "
"implementation used by default by Hibernate Validator. This implementation "
"relies on a <classname>ResourceBundleLocator</classname>, see <xref linkend="
"\"section-resource-bundle-locator\"/>. Hibernate Validator provides "
"different <classname>ResourceBundleLocator</classname> implementations "
"located in the package <package>org.hibernate.validator.resourceloading</"
"package>."
msgstr ""
#. Tag: entry
#: customoptions.xml:136
#, no-c-format
msgid ""
"<package>org.hibernate.validator.method</package>, <package>org.hibernate."
"validator.method.metadata</package>"
msgstr ""
#. Tag: entry
#: customoptions.xml:139
#, no-c-format
msgid ""
"Hibernate Validator provides support for method-level constraints based on "
"appendix C of the Bean Validation specification. The first package contains "
"the <classname>MethodValidator</classname> interface allowing you to "
"validate method return values and parameters. The second package contains "
"meta data for constraints hosted on parameters and methods which can be "
"retrieved via the <classname>MethodValidator</classname>."
msgstr ""
#. Tag: title
#: customoptions.xml:154
#, no-c-format
msgid "Fail fast mode"
msgstr ""
#. Tag: para
#: customoptions.xml:156
#, no-c-format
msgid ""
"First off, the fail fast mode. Hibernate Validator allows to return from the "
"current validation as soon as the first constraint violation occurs. This is "
"called the <emphasis>fail fast mode</emphasis> and can be useful for "
"validation of large object graphs where one is only interested whether there "
"is a constraint violation or not. <xref linkend=\"example-fail-fast-property"
"\"/>, <xref linkend=\"example-fail-fast-configuration\"/> and <xref linkend="
"\"example-fail-fast-factory\"/> show multiple ways to enable the fail fast "
"mode."
msgstr ""
#. Tag: title
#: customoptions.xml:167
#, no-c-format
msgid "Enabling <option>failFast</option> via a property"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:169
#, no-c-format
msgid ""
"HibernateValidatorConfiguration configuration = Validation.byProvider"
"( HibernateValidator.class ).configure();\n"
"ValidatorFactory factory = configuration.addProperty( \"hibernate.validator."
"fail_fast\", \"true\" ).buildValidatorFactory();\n"
"Validator validator = factory.getValidator();\n"
"\n"
"// do some actual fail fast validation\n"
"..."
msgstr ""
#. Tag: title
#: customoptions.xml:173
#, no-c-format
msgid ""
"Enabling <option>failFast</option> at the <classname>Configuration</"
"classname> level"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:176
#, no-c-format
msgid ""
"HibernateValidatorConfiguration configuration = Validation.byProvider"
"( HibernateValidator.class ).configure();\n"
"ValidatorFactory factory = configuration.failFast( true )."
"buildValidatorFactory();\n"
"Validator validator = factory.getValidator();\n"
"\n"
"// do some actual fail fast validation\n"
"..."
msgstr ""
#. Tag: title
#: customoptions.xml:180
#, no-c-format
msgid ""
"Enabling <option>failFast</option> at the <classname>ValidatorFactory</"
"classname> level"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:183
#, no-c-format
msgid ""
"HibernateValidatorConfiguration configuration = Validation.byProvider"
"( HibernateValidator.class ).configure();\n"
"ValidatorFactory factory = configuration.buildValidatorFactory();\n"
"\n"
"Validator validator = factory.getValidator();\n"
"\n"
"// do some non fail fast validation\n"
"...\n"
"\n"
"validator = factory.unwrap( HibernateValidatorFactory.class )\n"
" .usingContext()\n"
" .failFast( true )\n"
" .getValidator();\n"
"\n"
"// do fail fast validation\n"
"..."
msgstr ""
#. Tag: title
#: customoptions.xml:188
#, no-c-format
msgid "Method validation"
msgstr ""
#. Tag: para
#: customoptions.xml:190
#, no-c-format
msgid ""
"The Bean Validation API allows to specify constraints for fields, properties "
"and types. Hibernate Validator goes one step further and allows to place "
"contraint annotations also on method parameters and method return values, "
"thus enabling a programming style known as \"Programming by Contract\"."
msgstr ""
#. Tag: para
#: customoptions.xml:196
#, no-c-format
msgid ""
"More specifically this means that Bean Validation constraints can be used to "
"specify"
msgstr ""
#. Tag: para
#: customoptions.xml:201
#, no-c-format
msgid ""
"the preconditions that must be met before a method invocation (by annotating "
"method parameters with constraints) and"
msgstr ""
#. Tag: para
#: customoptions.xml:206
#, no-c-format
msgid ""
"the postconditions that are guaranteed after a method invocation (by "
"annotating methods)"
msgstr ""
#. Tag: para
#: customoptions.xml:211
#, no-c-format
msgid ""
"This approach has several advantages over traditional ways of parameter and "
"return value checking:"
msgstr ""
#. Tag: para
#: customoptions.xml:216
#, no-c-format
msgid ""
"The checks don't have to be performed manually (e.g. by throwing "
"<classname>IllegalArgumentExceptions</classname> or similar), resulting in "
"less code to write and maintain."
msgstr ""
#. Tag: para
#: customoptions.xml:222
#, no-c-format
msgid ""
"A method's pre- and postconditions don't have to be expressed again in the "
"method's JavaDoc, since the constraint annotations will automatically be "
"included in the generated JavaDoc. This avoids redundancy and reduces the "
"chance of inconsistencies between implementation and documentation."
msgstr ""
#. Tag: para
#: customoptions.xml:231
#, no-c-format
msgid ""
"Method validation was also considered to be included in the Bean Validation "
"API as defined by JSR 303, but it didn't become part of the 1.0 version. A "
"basic draft is outlined in appendix C of the specification, and the "
"implementation in Hibernate Validator is largely influenced by this draft. "
"The feature is considered again for inclusion in BV 1.1."
msgstr ""
#. Tag: title
#: customoptions.xml:240
#, no-c-format
msgid "Defining method-level constraints"
msgstr ""
#. Tag: para
#: customoptions.xml:242
#, no-c-format
msgid "demonstrates the definition of method-level constraints."
msgstr ""
#. Tag: title
#: customoptions.xml:245
#, no-c-format
msgid "Using method-level constraints"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:247
#, no-c-format
msgid ""
"public class RentalStation {\n"
"\n"
" @NotNull \n"
" public Car rentCar(@NotNull Customer customer, @NotNull @Future Date "
"startDate, @Min(1) int durationInDays) { \n"
" //...\n"
" }\n"
"}"
msgstr ""
#. Tag: para
#: customoptions.xml:250
#, no-c-format
msgid ""
"Here the following pre- and postconditions for the <methodname>rentCar()</"
"methodname> method are declared:"
msgstr ""
#. Tag: para
#: customoptions.xml:255
#, no-c-format
msgid "The renting customer may not be null"
msgstr ""
#. Tag: para
#: customoptions.xml:259
#, no-c-format
msgid "The rental's start date must not be null and must be in the future"
msgstr ""
#. Tag: para
#: customoptions.xml:264
#, no-c-format
msgid "The rental duration must be at least one day"
msgstr ""
#. Tag: para
#: customoptions.xml:268
#, no-c-format
msgid "The returned <classname>Car</classname> instance may not be null"
msgstr ""
#. Tag: para
#: customoptions.xml:273
#, no-c-format
msgid ""
"Using the <classname>@Valid</classname> annotation it's also possible to "
"define that a cascaded validation of parameter or return value objects shall "
"be performed. An example can be found in <xref lang=\"\" linkend=\"example-"
"cascaded-method-constraints\"/>."
msgstr ""
#. Tag: title
#: customoptions.xml:279
#, no-c-format
msgid "Cascaded validation of method-level constraints"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:281
#, no-c-format
msgid ""
"public class RentalStation {\n"
"\n"
" @Valid\n"
" public Set<Rental> getRentalsByCustomer(@Valid Customer customer) "
"{ \n"
" //...\n"
" }\n"
"}"
msgstr ""
#. Tag: para
#: customoptions.xml:284
#, no-c-format
msgid ""
"Here all the constraints declared at the <classname>Customer</classname> "
"type will be evaluated when validating the method parameter and all "
"constraints declared at the returned <classname>Rental</classname> objects "
"will be evaluated when validating the method's return value."
msgstr ""
#. Tag: title
#: customoptions.xml:291
#, no-c-format
msgid "Using method constraints in type hierarchies"
msgstr ""
#. Tag: para
#: customoptions.xml:293
#, no-c-format
msgid ""
"Special care must be taken when defining parameter constraints in "
"inheritance hierarchies."
msgstr ""
#. Tag: para
#: customoptions.xml:296
#, no-c-format
msgid ""
"When a method is overridden in sub-types method parameter constraints can "
"only be declared at the base type. The reason for this restriction is that "
"the preconditions to be fulfilled by a type's client must not be "
"strengthened in sub-types (which may not even be known to the base type's "
"client). Note that also if the base method doesn't declare any parameter "
"constraints at all, no parameter constraints may be added in overriding "
"methods."
msgstr ""
#. Tag: para
#: customoptions.xml:304
#, no-c-format
msgid ""
"The same restriction applies to interface methods: no parameter constraints "
"may be defined at the implementing method (or the same method declared in "
"sub-interfaces)."
msgstr ""
#. Tag: para
#: customoptions.xml:308
#, no-c-format
msgid ""
"If a violation of this rule is detected by the validation engine, a "
"<classname>javax.validation.ConstraintDeclarationException</classname> will "
"be thrown. In <xref lang=\"\" linkend=\"example-illegal-method-constraints\"/"
"> some examples for illegal parameter constraints declarations are shown."
msgstr ""
#. Tag: title
#: customoptions.xml:316
#, no-c-format
msgid "Illegal parameter constraint declarations"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:318
#, no-c-format
msgid ""
"public class Car {\n"
"\n"
" public void drive(Person driver) { ... }\n"
"\n"
"}\n"
"\n"
"public class RentalCar extends Car {\n"
"\n"
" //not allowed, parameter constraint added in overriding method\n"
" public void drive(@NotNull Person driver) { ... }\n"
"\n"
"}\n"
"\n"
"public interface ICar {\n"
"\n"
" void drive(Person driver);\n"
"\n"
"}\n"
"\n"
"public class CarImpl implements ICar {\n"
"\n"
" //not allowed, parameter constraint added in implementation of interface "
"method\n"
" public void drive(@NotNull Person driver) { ... }\n"
"\n"
"}"
msgstr ""
#. Tag: para
#: customoptions.xml:321
#, no-c-format
msgid ""
"This rule only applies to parameter constraints, return value constraints "
"may be added in sub-types without any restrictions as it is alright to "
"strengthen the postconditions guaranteed to a type's client."
msgstr ""
#. Tag: title
#: customoptions.xml:329
#, no-c-format
msgid "Evaluating method-level constraints"
msgstr ""
#. Tag: para
#: customoptions.xml:331
#, no-c-format
msgid ""
"To validate method-level constraints Hibernate Validator provides the "
"interface <classname>org.hibernate.validator.method.MethodValidator</"
"classname>."
msgstr ""
#. Tag: para
#: customoptions.xml:335
#, no-c-format
msgid ""
"As shown in <xref lang=\"\" linkend=\"example-methodvalidator\"/> this "
"interface defines methods for the evaluation of parameter as well as return "
"value constraints and for retrieving an extended type descriptor providing "
"method constraint related meta data."
msgstr ""
#. Tag: title
#: customoptions.xml:341
#, no-c-format
msgid "The <classname>MethodValidator</classname> interface"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:343
#, no-c-format
msgid ""
"public interface MethodValidator {\n"
"\n"
" <T> Set<MethodConstraintViolation<T>> validateParameter"
"(T object, Method method, Object parameterValue, int parameterIndex, "
"Class<?>... groups);\n"
" \n"
" <T> Set<MethodConstraintViolation<T>> "
"validateAllParameters(T object, Method method, Object[] parameterValues, "
"Class<?>... groups);\n"
" \n"
" <T> Set<MethodConstraintViolation<T>> "
"validateReturnValue(T object, Method method, Object returnValue, Class<?"
">... groups);\n"
" \n"
" TypeDescriptor getConstraintsForType(Class<?> clazz);\n"
"}"
msgstr ""
#. Tag: para
#: customoptions.xml:346
#, no-c-format
msgid ""
"To retrieve a method validator get hold of an instance of HV's "
"<classname>javax.validation.Validator</classname> implementation and unwrap "
"it to <classname>MethodValidator</classname> as shown in <xref lang=\"\" "
"linkend=\"example-retrieving-methodvalidator\"/>."
msgstr ""
#. Tag: title
#: customoptions.xml:352
#, no-c-format
msgid "Retrieving a <classname>MethodValidator</classname> instance"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:355
#, no-c-format
msgid ""
"MethodValidator methodValidator = Validation.byProvider( HibernateValidator."
"class )\n"
" .configure()\n"
" .buildValidatorFactory()\n"
" .getValidator()\n"
" .unwrap( MethodValidator.class );"
msgstr ""
#. Tag: para
#: customoptions.xml:358
#, no-c-format
msgid ""
"The validation methods defined on <classname>MethodValidator</classname> "
"each return a <classname>Set<MethodConstraintViolation></classname>. "
"The type <classname>MethodConstraintViolation</classname> (see <xref lang="
"\"\" linkend=\"example-methodconstraintviolation\"/>) extends "
"<classname>javax.validation.ConstraintViolation</classname> and provides "
"additional method level validation specific information such as the method "
"and index of the parameter which caused the constraint violation."
msgstr ""
#. Tag: title
#: customoptions.xml:369
#, no-c-format
msgid "The <classname>MethodConstraintViolation</classname> type"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:372
#, no-c-format
msgid ""
"public interface MethodConstraintViolation<T> extends "
"ConstraintViolation<T> {\n"
" \n"
" public static enum Kind { PARAMETER, RETURN_VALUE }\n"
"\n"
" Method getMethod();\n"
"\n"
" Integer getParameterIndex();\n"
"\n"
" String getParameterName();\n"
"\n"
" Kind getKind();\n"
"}"
msgstr ""
#. Tag: para
#: customoptions.xml:376
#, no-c-format
msgid ""
"The method <methodname>getParameterName()</methodname> currently returns "
"synthetic parameter identifiers such as \"arg0\", \"arg1\" etc. In a future "
"version of Hibernate Validator support for specifying parameter identifiers "
"might be added."
msgstr ""
#. Tag: para
#: customoptions.xml:382
#, no-c-format
msgid ""
"Typically the validation of method-level constraints is not invoked manually "
"but automatically upon method invocation by an integration layer using AOP "
"(aspect-oriented programming) or similar method interception facilities such "
"as the JDK's <classname>java.lang.reflect.Proxy</classname> API or CDI "
"(\"JSR 299: Contexts and Dependency Injection for the Java<superscript>TM</"
"superscript> EE platform\")."
msgstr ""
#. Tag: para
#: customoptions.xml:390
#, no-c-format
msgid ""
"If a parameter or return value constraint can't be validated sucessfully "
"such an integration layer typically will throw a "
"<classname>MethodConstraintViolationException</classname> which similar to "
"<classname>javax.validation.ConstraintViolationException</classname> "
"contains a set with the occurred constraint violations."
msgstr ""
#. Tag: para
#: customoptions.xml:397
#, no-c-format
msgid ""
"If you are using CDI you might be interested in the <ulink url=\"http://"
"seamframework.org/Seam3/ValidationModule\">Seam Validation</ulink> project. "
"This Seam module provides an interceptor which integrates the method "
"validation functionality with CDI."
msgstr ""
#. Tag: title
#: customoptions.xml:405
#, no-c-format
msgid "Retrieving method-level constraint meta data"
msgstr ""
#. Tag: para
#: customoptions.xml:407
#, no-c-format
msgid ""
"As outlined in <xref lang=\"\" linkend=\"validator-metadata-api\"/> the Bean "
"Validation API provides rich capabilities for retrieving constraint related "
"meta data. Hibernate Validator extends this API and allows to retrieve "
"constraint meta data also for method-level constraints."
msgstr ""
#. Tag: para
#: customoptions.xml:413
#, no-c-format
msgid ""
"shows how to use this extended API to retrieve constraint meta data for the "
"<methodname>rentCar()</methodname> method from the <classname>RentalStation</"
"classname> type."
msgstr ""
#. Tag: title
#: customoptions.xml:419
#, no-c-format
msgid "Retrieving meta data for method-level constraints"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:421
#, no-c-format
msgid ""
"TypeDescriptor typeDescriptor = methodValidator.getConstraintsForType"
"(RentalStation.class)\n"
"\n"
"//retrieve a descriptor for the rentCar() method\n"
"MethodDescriptor rentCarMethod = typeDescriptor.getConstraintsForMethod"
"(\"rentCar\", Customer.class, Date.class, int.class);\n"
"assertEquals(rentCarMethod.getMethodName(), \"rentCar\");\n"
"assertTrue(rentCarMethod.hasConstraints());\n"
"assertFalse(rentCarMethod.isCascaded());\n"
"\n"
"//retrieve constraints from the return value\n"
"Set<ConstraintDescriptor<?>> returnValueConstraints = "
"rentCarMethod.findConstraints().getConstraintDescriptors();\n"
"assertEquals(returnValueConstraints.size(), 1);\n"
"assertEquals(returnValueConstraints.iterator().next().getAnnotation()."
"annotationType(), NotNull.class);\n"
"\n"
"List<ParameterDescriptor> allParameters = rentCarMethod."
"getParameterDescriptors();\n"
"assertEquals(allParameters.size(), 3);\n"
"\n"
"//retrieve a descriptor for the startDate parameter\n"
"ParameterDescriptor startDateParameter = allParameters.get(1);\n"
"assertEquals(startDateParameter.getIndex(), 1);\n"
"assertFalse(startDateParameter.isCascaded());\n"
"assertEquals(startDateParameter.findConstraints().getConstraintDescriptors()."
"size(), 2);"
msgstr ""
#. Tag: para
#: customoptions.xml:424
#, no-c-format
msgid ""
"Refer to the <ulink url=\"http://docs.jboss.org/hibernate/validator/4.2/api/"
"index.html?org/hibernate/validator/method/metadata/package-summary.html"
"\">JavaDoc</ulink> of the package <classname>org.hibernate.validator.method."
"metadata</classname> for more details on the extended meta data API."
msgstr ""
#. Tag: title
#: customoptions.xml:433 customoptions.xml:449
#, no-c-format
msgid "Programmatic constraint definition"
msgstr ""
#. Tag: para
#: customoptions.xml:435
#, no-c-format
msgid ""
"Another addition to the Bean Validation specification is the ability to "
"configure constraints via a fluent API. This API can be used exclusively or "
"in combination with annotations and xml. If used in combination programmatic "
"constraints are additive to constraints configured via the standard "
"configuration capabilities."
msgstr ""
#. Tag: para
#: customoptions.xml:441
#, no-c-format
msgid ""
"The API is centered around the <classname>ConstraintMapping</classname> "
"class which can be found in the package<package> org.hibernate.validator."
"cfg</package>. Starting with the instantiation of a new "
"<classname>ConstraintMapping</classname>, constraints can be defined in a "
"fluent manner as shown in <xref lang=\"\" linkend=\"example-constraint-"
"mapping\"/>."
msgstr ""
#. Tag: programlisting
#: customoptions.xml:451
#, no-c-format
msgid ""
"ConstraintMapping mapping = new ConstraintMapping();\n"
"mapping.type( Car.class )\n"
" .property( \"manufacturer\", FIELD )\n"
" .constraint( new NotNullDef() )\n"
" .property( \"licensePlate\", FIELD )\n"
" .constraint( new NotNullDef() )\n"
" .constraint( new SizeDef().min( 2 ).max( 14 ) )\n"
" .property( \"seatCount\", FIELD )\n"
" .constraint( new MinDef()value ( 2 ) )\n"
".type( RentalCar.class )\n"
" .property( \"rentalStation\", METHOD )\n"
" .constraint( new NotNullDef() );"
msgstr ""
#. Tag: para
#: customoptions.xml:454
#, no-c-format
msgid ""
"As you can see constraints can be configured on multiple classes and "
"properties using method chaining. The constraint definition classes "
"<classname>NotNullDef</classname>, <classname>SizeDef</classname> and "
"<classname>MinDef</classname> are helper classes which allow to configure "
"constraint parameters in a type-safe fashion. Definition classes exist for "
"all built-in constraints in the <classname>org.hibernate.validator.cfg.defs</"
"classname> package."
msgstr ""
#. Tag: para
#: customoptions.xml:462
#, no-c-format
msgid ""
"For custom constraints you can either create your own definition classes "
"extending <classname>ConstraintDef</classname> or you can use "
"<classname>GenericConstraintDef</classname> as seen in <xref linkend="
"\"example-generic-constraint-mapping\"/>."
msgstr ""
#. Tag: title
#: customoptions.xml:468
#, no-c-format
msgid ""
"Programmatic constraint definition using <methodname>createGeneric()</"
"methodname>"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:471
#, no-c-format
msgid ""
"ConstraintMapping mapping = new ConstraintMapping();\n"
"mapping.type( Car.class )\n"
" .property( \"licensePlate\", FIELD )\n"
" .constraint( new GenericConstraintDef<CheckCase.class>"
"( CheckCase.class ).param( \"value\", CaseMode.UPPER ) );"
msgstr ""
#. Tag: para
#: customoptions.xml:474
#, no-c-format
msgid ""
"Not only standard class- and property-level constraints but also method "
"constraints can be configured using the API. As shown in <xref lang=\"\" "
"linkend=\"example-method-constraint-mapping\"/> methods are identified by "
"their name and their parameters (if there are any). Having selected a "
"method, constraints can be placed on the method's parameters and/or return "
"value."
msgstr ""
#. Tag: title
#: customoptions.xml:482
#, no-c-format
msgid "Programmatic definition of method constraints"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:484
#, no-c-format
msgid ""
"ConstraintMapping mapping = new ConstraintMapping();\n"
"mapping.type( Car.class )\n"
" .method( \"drive\", String.class, Integer.class )\n"
" .parameter( 0 )\n"
" .constraint( new NotNullDef() )\n"
" .constraint( new MinDef().value ( 1 ) )\n"
" .parameter( 1 )\n"
" .constraint( new NotNullDef() )\n"
" .returnValue()\n"
" .constraint( new NotNullDef() )\n"
" .method( \"check\" )\n"
" .returnValue()\n"
" .constraint( new NotNullDef() );"
msgstr ""
#. Tag: para
#: customoptions.xml:487
#, no-c-format
msgid ""
"Using the API it's also possible to mark properties, method parameters and "
"method return values as cascading (equivalent to annotating them with "
"<classname>@Valid</classname>). An example can be found in <xref lang=\"\" "
"linkend=\"example-cascading-constraints\"/>."
msgstr ""
#. Tag: title
#: customoptions.xml:493
#, no-c-format
msgid "Marking constraints for cascaded validation"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:495
#, no-c-format
msgid ""
"ConstraintMapping mapping = new ConstraintMapping();\n"
"mapping.type( Car.class )\n"
" .property( \"manufacturer\", FIELD )\n"
" .valid()\n"
" .property( \"licensePlate\", METHOD )\n"
" .valid()\n"
" .method( \"drive\", String.class, Integer.class )\n"
" .parameter( 0 )\n"
" .valid()\n"
" .parameter( 1 )\n"
" .valid()\n"
" .returnValue()\n"
" .valid()\n"
".type( RentalCar.class )\n"
" .property( \"rentalStation\", METHOD )\n"
" .valid();"
msgstr ""
#. Tag: para
#: customoptions.xml:498
#, no-c-format
msgid ""
"Last but not least you can configure the default group sequence or the "
"default group sequence provider of a type as shown in <xref lang=\"\" "
"linkend=\"example-sequences\"/>."
msgstr ""
#. Tag: title
#: customoptions.xml:501
#, no-c-format
msgid ""
"Configuration of default group sequence and default group sequence provider"
msgstr ""
#. Tag: programlisting
#: customoptions.xml:504
#, no-c-format
msgid ""
"ConstraintMapping mapping = new ConstraintMapping();\n"
"mapping.type( Car.class )\n"
" .defaultGroupSequence( Car.class, CarChecks.class )\n"
".type( RentalCar.class )\n"