1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.apache.maven.archetype.metadata.io.xpp3;
25
26
27
28
29
30 import java.io.IOException;
31 import java.io.InputStream;
32 import java.io.Reader;
33 import java.text.DateFormat;
34 import org.apache.maven.archetype.metadata.AbstractArchetypeDescriptor;
35 import org.apache.maven.archetype.metadata.ArchetypeDescriptor;
36 import org.apache.maven.archetype.metadata.FileSet;
37 import org.apache.maven.archetype.metadata.ModuleDescriptor;
38 import org.apache.maven.archetype.metadata.RequiredProperty;
39 import org.codehaus.plexus.util.xml.XmlStreamReader;
40 import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
41 import org.codehaus.plexus.util.xml.pull.MXParser;
42 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
43 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
44
45
46
47
48
49
50 @SuppressWarnings( "all" )
51 public class ArchetypeDescriptorXpp3Reader
52 {
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 private boolean addDefaultEntities = true;
69
70
71
72
73 public final ContentTransformer contentTransformer;
74
75
76
77
78
79
80 public ArchetypeDescriptorXpp3Reader()
81 {
82 this( new ContentTransformer()
83 {
84 public String transform( String source, String fieldName )
85 {
86 return source;
87 }
88 } );
89 }
90
91 public ArchetypeDescriptorXpp3Reader(ContentTransformer contentTransformer)
92 {
93 this.contentTransformer = contentTransformer;
94 }
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112 private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set<String> parsed )
113 throws XmlPullParserException
114 {
115 if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) )
116 {
117 return false;
118 }
119 if ( !parsed.add( tagName ) )
120 {
121 throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null );
122 }
123 return true;
124 }
125
126
127
128
129
130
131
132
133
134
135
136
137 private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict )
138 throws XmlPullParserException, IOException
139 {
140
141 if ( strict )
142 {
143 throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null );
144 }
145 }
146
147
148
149
150
151
152
153
154
155
156 private void checkUnknownElement( XmlPullParser parser, boolean strict )
157 throws XmlPullParserException, IOException
158 {
159 if ( strict )
160 {
161 throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null );
162 }
163
164 for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; )
165 {
166 int eventType = parser.next();
167 if ( eventType == XmlPullParser.START_TAG )
168 {
169 unrecognizedTagCount++;
170 }
171 else if ( eventType == XmlPullParser.END_TAG )
172 {
173 unrecognizedTagCount--;
174 }
175 }
176 }
177
178
179
180
181
182
183 public boolean getAddDefaultEntities()
184 {
185 return addDefaultEntities;
186 }
187
188
189
190
191
192
193
194
195
196
197
198 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser )
199 throws XmlPullParserException
200 {
201 return getBooleanValue( s, attribute, parser, null );
202 }
203
204
205
206
207
208
209
210
211
212
213
214
215 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue )
216 throws XmlPullParserException
217 {
218 if ( s != null && s.length() != 0 )
219 {
220 return Boolean.valueOf( s ).booleanValue();
221 }
222 if ( defaultValue != null )
223 {
224 return Boolean.valueOf( defaultValue ).booleanValue();
225 }
226 return false;
227 }
228
229
230
231
232
233
234
235
236
237
238
239
240 private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict )
241 throws XmlPullParserException
242 {
243 if ( s != null )
244 {
245 try
246 {
247 return Byte.valueOf( s ).byteValue();
248 }
249 catch ( NumberFormatException nfe )
250 {
251 if ( strict )
252 {
253 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe );
254 }
255 }
256 }
257 return 0;
258 }
259
260
261
262
263
264
265
266
267
268
269
270 private char getCharacterValue( String s, String attribute, XmlPullParser parser )
271 throws XmlPullParserException
272 {
273 if ( s != null )
274 {
275 return s.charAt( 0 );
276 }
277 return 0;
278 }
279
280
281
282
283
284
285
286
287
288
289
290 private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser )
291 throws XmlPullParserException
292 {
293 return getDateValue( s, attribute, null, parser );
294 }
295
296
297
298
299
300
301
302
303
304
305
306
307 private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser )
308 throws XmlPullParserException
309 {
310 if ( s != null )
311 {
312 String effectiveDateFormat = dateFormat;
313 if ( dateFormat == null )
314 {
315 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS";
316 }
317 if ( "long".equals( effectiveDateFormat ) )
318 {
319 try
320 {
321 return new java.util.Date( Long.parseLong( s ) );
322 }
323 catch ( NumberFormatException e )
324 {
325 throw new XmlPullParserException( e.getMessage(), parser, e );
326 }
327 }
328 else
329 {
330 try
331 {
332 DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
333 return dateParser.parse( s );
334 }
335 catch ( java.text.ParseException e )
336 {
337 throw new XmlPullParserException( e.getMessage(), parser, e );
338 }
339 }
340 }
341 return null;
342 }
343
344
345
346
347
348
349
350
351
352
353
354
355 private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict )
356 throws XmlPullParserException
357 {
358 if ( s != null )
359 {
360 try
361 {
362 return Double.valueOf( s ).doubleValue();
363 }
364 catch ( NumberFormatException nfe )
365 {
366 if ( strict )
367 {
368 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
369 }
370 }
371 }
372 return 0;
373 }
374
375
376
377
378
379
380
381
382
383
384
385
386 private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict )
387 throws XmlPullParserException
388 {
389 if ( s != null )
390 {
391 try
392 {
393 return Float.valueOf( s ).floatValue();
394 }
395 catch ( NumberFormatException nfe )
396 {
397 if ( strict )
398 {
399 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
400 }
401 }
402 }
403 return 0;
404 }
405
406
407
408
409
410
411
412
413
414
415
416
417 private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict )
418 throws XmlPullParserException
419 {
420 if ( s != null )
421 {
422 try
423 {
424 return Integer.valueOf( s ).intValue();
425 }
426 catch ( NumberFormatException nfe )
427 {
428 if ( strict )
429 {
430 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe );
431 }
432 }
433 }
434 return 0;
435 }
436
437
438
439
440
441
442
443
444
445
446
447
448 private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict )
449 throws XmlPullParserException
450 {
451 if ( s != null )
452 {
453 try
454 {
455 return Long.valueOf( s ).longValue();
456 }
457 catch ( NumberFormatException nfe )
458 {
459 if ( strict )
460 {
461 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe );
462 }
463 }
464 }
465 return 0;
466 }
467
468
469
470
471
472
473
474
475
476
477
478
479 private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict )
480 throws XmlPullParserException
481 {
482 if ( s == null )
483 {
484 if ( strict )
485 {
486 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null );
487 }
488 }
489 return s;
490 }
491
492
493
494
495
496
497
498
499
500
501
502
503 private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict )
504 throws XmlPullParserException
505 {
506 if ( s != null )
507 {
508 try
509 {
510 return Short.valueOf( s ).shortValue();
511 }
512 catch ( NumberFormatException nfe )
513 {
514 if ( strict )
515 {
516 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe );
517 }
518 }
519 }
520 return 0;
521 }
522
523
524
525
526
527
528
529 private String getTrimmedValue( String s )
530 {
531 if ( s != null )
532 {
533 s = s.trim();
534 }
535 return s;
536 }
537
538
539
540
541
542
543
544
545 private String interpolatedTrimmed( String value, String context )
546 {
547 return getTrimmedValue( contentTransformer.transform( value, context ) );
548 }
549
550
551
552
553
554
555
556
557
558
559 private int nextTag( XmlPullParser parser )
560 throws IOException, XmlPullParserException
561 {
562 int eventType = parser.next();
563 if ( eventType == XmlPullParser.TEXT )
564 {
565 eventType = parser.next();
566 }
567 if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG )
568 {
569 throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null );
570 }
571 return eventType;
572 }
573
574
575
576
577
578
579
580
581
582
583
584 public ArchetypeDescriptor read( XmlPullParser parser, boolean strict )
585 throws IOException, XmlPullParserException
586 {
587 ArchetypeDescriptor archetypeDescriptor = null;
588 int eventType = parser.getEventType();
589 boolean parsed = false;
590 while ( eventType != XmlPullParser.END_DOCUMENT )
591 {
592 if ( eventType == XmlPullParser.START_TAG )
593 {
594 if ( strict && ! "archetype-descriptor".equals( parser.getName() ) )
595 {
596 throw new XmlPullParserException( "Expected root element 'archetype-descriptor' but found '" + parser.getName() + "'", parser, null );
597 }
598 else if ( parsed )
599 {
600
601 throw new XmlPullParserException( "Duplicated tag: 'archetype-descriptor'", parser, null );
602 }
603 archetypeDescriptor = parseArchetypeDescriptor( parser, strict );
604 archetypeDescriptor.setModelEncoding( parser.getInputEncoding() );
605 parsed = true;
606 }
607 eventType = parser.next();
608 }
609 if ( parsed )
610 {
611 return archetypeDescriptor;
612 }
613 throw new XmlPullParserException( "Expected root element 'archetype-descriptor' but found no element at all: invalid XML document", parser, null );
614 }
615
616
617
618
619
620
621
622
623
624
625
626 public ArchetypeDescriptor read( Reader reader, boolean strict )
627 throws IOException, XmlPullParserException
628 {
629 XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( );
630
631 parser.setInput( reader );
632
633
634 return read( parser, strict );
635 }
636
637
638
639
640
641
642
643
644
645
646 public ArchetypeDescriptor read( Reader reader )
647 throws IOException, XmlPullParserException
648 {
649 return read( reader, true );
650 }
651
652
653
654
655
656
657
658
659
660
661
662 public ArchetypeDescriptor read( InputStream in, boolean strict )
663 throws IOException, XmlPullParserException
664 {
665 return read( new XmlStreamReader( in ), strict );
666 }
667
668
669
670
671
672
673
674
675
676
677 public ArchetypeDescriptor read( InputStream in )
678 throws IOException, XmlPullParserException
679 {
680 return read( new XmlStreamReader( in ) );
681 }
682
683
684
685
686
687
688
689
690
691
692
693 private AbstractArchetypeDescriptor parseAbstractArchetypeDescriptor( XmlPullParser parser, boolean strict )
694 throws IOException, XmlPullParserException
695 {
696 String tagName = parser.getName();
697 AbstractArchetypeDescriptor abstractArchetypeDescriptor = new AbstractArchetypeDescriptor();
698 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
699 {
700 String name = parser.getAttributeName( i );
701 String value = parser.getAttributeValue( i );
702
703 if ( name.indexOf( ':' ) >= 0 )
704 {
705
706 }
707 else
708 {
709 checkUnknownAttribute( parser, name, tagName, strict );
710 }
711 }
712 java.util.Set<String> parsed = new java.util.HashSet<String>();
713 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
714 {
715 if ( checkFieldWithDuplicate( parser, "fileSets", null, parsed ) )
716 {
717 java.util.List<FileSet> fileSets = new java.util.ArrayList<FileSet>();
718 while ( parser.nextTag() == XmlPullParser.START_TAG )
719 {
720 if ( "fileSet".equals( parser.getName() ) )
721 {
722 fileSets.add( parseFileSet( parser, strict ) );
723 }
724 else
725 {
726 checkUnknownElement( parser, strict );
727 }
728 }
729 abstractArchetypeDescriptor.setFileSets( fileSets );
730 }
731 else if ( checkFieldWithDuplicate( parser, "modules", null, parsed ) )
732 {
733 java.util.List<ModuleDescriptor> modules = new java.util.ArrayList<ModuleDescriptor>();
734 while ( parser.nextTag() == XmlPullParser.START_TAG )
735 {
736 if ( "module".equals( parser.getName() ) )
737 {
738 modules.add( parseModuleDescriptor( parser, strict ) );
739 }
740 else
741 {
742 checkUnknownElement( parser, strict );
743 }
744 }
745 abstractArchetypeDescriptor.setModules( modules );
746 }
747 else
748 {
749 checkUnknownElement( parser, strict );
750 }
751 }
752 return abstractArchetypeDescriptor;
753 }
754
755
756
757
758
759
760
761
762
763
764
765 private ArchetypeDescriptor parseArchetypeDescriptor( XmlPullParser parser, boolean strict )
766 throws IOException, XmlPullParserException
767 {
768 String tagName = parser.getName();
769 ArchetypeDescriptor archetypeDescriptor = new ArchetypeDescriptor();
770 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
771 {
772 String name = parser.getAttributeName( i );
773 String value = parser.getAttributeValue( i );
774
775 if ( name.indexOf( ':' ) >= 0 )
776 {
777
778 }
779 else if ( "xmlns".equals( name ) )
780 {
781
782 }
783 else if ( "name".equals( name ) )
784 {
785 archetypeDescriptor.setName( interpolatedTrimmed( value, "name" ) );
786 }
787 else if ( "partial".equals( name ) )
788 {
789 archetypeDescriptor.setPartial( getBooleanValue( interpolatedTrimmed( value, "partial" ), "partial", parser, "false" ) );
790 }
791 else
792 {
793 checkUnknownAttribute( parser, name, tagName, strict );
794 }
795 }
796 java.util.Set<String> parsed = new java.util.HashSet<String>();
797 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
798 {
799 if ( checkFieldWithDuplicate( parser, "requiredProperties", null, parsed ) )
800 {
801 java.util.List<RequiredProperty> requiredProperties = new java.util.ArrayList<RequiredProperty>();
802 while ( parser.nextTag() == XmlPullParser.START_TAG )
803 {
804 if ( "requiredProperty".equals( parser.getName() ) )
805 {
806 requiredProperties.add( parseRequiredProperty( parser, strict ) );
807 }
808 else
809 {
810 checkUnknownElement( parser, strict );
811 }
812 }
813 archetypeDescriptor.setRequiredProperties( requiredProperties );
814 }
815 else if ( checkFieldWithDuplicate( parser, "fileSets", null, parsed ) )
816 {
817 java.util.List<FileSet> fileSets = new java.util.ArrayList<FileSet>();
818 while ( parser.nextTag() == XmlPullParser.START_TAG )
819 {
820 if ( "fileSet".equals( parser.getName() ) )
821 {
822 fileSets.add( parseFileSet( parser, strict ) );
823 }
824 else
825 {
826 checkUnknownElement( parser, strict );
827 }
828 }
829 archetypeDescriptor.setFileSets( fileSets );
830 }
831 else if ( checkFieldWithDuplicate( parser, "modules", null, parsed ) )
832 {
833 java.util.List<ModuleDescriptor> modules = new java.util.ArrayList<ModuleDescriptor>();
834 while ( parser.nextTag() == XmlPullParser.START_TAG )
835 {
836 if ( "module".equals( parser.getName() ) )
837 {
838 modules.add( parseModuleDescriptor( parser, strict ) );
839 }
840 else
841 {
842 checkUnknownElement( parser, strict );
843 }
844 }
845 archetypeDescriptor.setModules( modules );
846 }
847 else
848 {
849 checkUnknownElement( parser, strict );
850 }
851 }
852 return archetypeDescriptor;
853 }
854
855
856
857
858
859
860
861
862
863
864
865 private FileSet parseFileSet( XmlPullParser parser, boolean strict )
866 throws IOException, XmlPullParserException
867 {
868 String tagName = parser.getName();
869 FileSet fileSet = new FileSet();
870 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
871 {
872 String name = parser.getAttributeName( i );
873 String value = parser.getAttributeValue( i );
874
875 if ( name.indexOf( ':' ) >= 0 )
876 {
877
878 }
879 else if ( "filtered".equals( name ) )
880 {
881 fileSet.setFiltered( getBooleanValue( interpolatedTrimmed( value, "filtered" ), "filtered", parser, "false" ) );
882 }
883 else if ( "packaged".equals( name ) )
884 {
885 fileSet.setPackaged( getBooleanValue( interpolatedTrimmed( value, "packaged" ), "packaged", parser, "false" ) );
886 }
887 else if ( "encoding".equals( name ) )
888 {
889 fileSet.setEncoding( interpolatedTrimmed( value, "encoding" ) );
890 }
891 else if ( "includeCondition".equals( name ) )
892 {
893 fileSet.setIncludeCondition( interpolatedTrimmed( value, "includeCondition" ) );
894 }
895 else
896 {
897 checkUnknownAttribute( parser, name, tagName, strict );
898 }
899 }
900 java.util.Set<String> parsed = new java.util.HashSet<String>();
901 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
902 {
903 if ( checkFieldWithDuplicate( parser, "directory", null, parsed ) )
904 {
905 fileSet.setDirectory( interpolatedTrimmed( parser.nextText(), "directory" ) );
906 }
907 else if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
908 {
909 java.util.List<String> includes = new java.util.ArrayList<String>();
910 while ( parser.nextTag() == XmlPullParser.START_TAG )
911 {
912 if ( "include".equals( parser.getName() ) )
913 {
914 includes.add( interpolatedTrimmed( parser.nextText(), "includes" ) );
915 }
916 else
917 {
918 checkUnknownElement( parser, strict );
919 }
920 }
921 fileSet.setIncludes( includes );
922 }
923 else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
924 {
925 java.util.List<String> excludes = new java.util.ArrayList<String>();
926 while ( parser.nextTag() == XmlPullParser.START_TAG )
927 {
928 if ( "exclude".equals( parser.getName() ) )
929 {
930 excludes.add( interpolatedTrimmed( parser.nextText(), "excludes" ) );
931 }
932 else
933 {
934 checkUnknownElement( parser, strict );
935 }
936 }
937 fileSet.setExcludes( excludes );
938 }
939 else
940 {
941 checkUnknownElement( parser, strict );
942 }
943 }
944 return fileSet;
945 }
946
947
948
949
950
951
952
953
954
955
956
957 private ModuleDescriptor parseModuleDescriptor( XmlPullParser parser, boolean strict )
958 throws IOException, XmlPullParserException
959 {
960 String tagName = parser.getName();
961 ModuleDescriptor moduleDescriptor = new ModuleDescriptor();
962 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
963 {
964 String name = parser.getAttributeName( i );
965 String value = parser.getAttributeValue( i );
966
967 if ( name.indexOf( ':' ) >= 0 )
968 {
969
970 }
971 else if ( "id".equals( name ) )
972 {
973 moduleDescriptor.setId( interpolatedTrimmed( value, "id" ) );
974 }
975 else if ( "dir".equals( name ) )
976 {
977 moduleDescriptor.setDir( interpolatedTrimmed( value, "dir" ) );
978 }
979 else if ( "name".equals( name ) )
980 {
981 moduleDescriptor.setName( interpolatedTrimmed( value, "name" ) );
982 }
983 else
984 {
985 checkUnknownAttribute( parser, name, tagName, strict );
986 }
987 }
988 java.util.Set<String> parsed = new java.util.HashSet<String>();
989 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
990 {
991 if ( checkFieldWithDuplicate( parser, "fileSets", null, parsed ) )
992 {
993 java.util.List<FileSet> fileSets = new java.util.ArrayList<FileSet>();
994 while ( parser.nextTag() == XmlPullParser.START_TAG )
995 {
996 if ( "fileSet".equals( parser.getName() ) )
997 {
998 fileSets.add( parseFileSet( parser, strict ) );
999 }
1000 else
1001 {
1002 checkUnknownElement( parser, strict );
1003 }
1004 }
1005 moduleDescriptor.setFileSets( fileSets );
1006 }
1007 else if ( checkFieldWithDuplicate( parser, "modules", null, parsed ) )
1008 {
1009 java.util.List<ModuleDescriptor> modules = new java.util.ArrayList<ModuleDescriptor>();
1010 while ( parser.nextTag() == XmlPullParser.START_TAG )
1011 {
1012 if ( "module".equals( parser.getName() ) )
1013 {
1014 modules.add( parseModuleDescriptor( parser, strict ) );
1015 }
1016 else
1017 {
1018 checkUnknownElement( parser, strict );
1019 }
1020 }
1021 moduleDescriptor.setModules( modules );
1022 }
1023 else
1024 {
1025 checkUnknownElement( parser, strict );
1026 }
1027 }
1028 return moduleDescriptor;
1029 }
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041 private RequiredProperty parseRequiredProperty( XmlPullParser parser, boolean strict )
1042 throws IOException, XmlPullParserException
1043 {
1044 String tagName = parser.getName();
1045 RequiredProperty requiredProperty = new RequiredProperty();
1046 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1047 {
1048 String name = parser.getAttributeName( i );
1049 String value = parser.getAttributeValue( i );
1050
1051 if ( name.indexOf( ':' ) >= 0 )
1052 {
1053
1054 }
1055 else if ( "key".equals( name ) )
1056 {
1057 requiredProperty.setKey( interpolatedTrimmed( value, "key" ) );
1058 }
1059 else
1060 {
1061 checkUnknownAttribute( parser, name, tagName, strict );
1062 }
1063 }
1064 java.util.Set<String> parsed = new java.util.HashSet<String>();
1065 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1066 {
1067 if ( checkFieldWithDuplicate( parser, "defaultValue", null, parsed ) )
1068 {
1069 requiredProperty.setDefaultValue( interpolatedTrimmed( parser.nextText(), "defaultValue" ) );
1070 }
1071 else if ( checkFieldWithDuplicate( parser, "validationRegex", null, parsed ) )
1072 {
1073 requiredProperty.setValidationRegex( interpolatedTrimmed( parser.nextText(), "validationRegex" ) );
1074 }
1075 else
1076 {
1077 checkUnknownElement( parser, strict );
1078 }
1079 }
1080 return requiredProperty;
1081 }
1082
1083
1084
1085
1086
1087
1088 public void setAddDefaultEntities( boolean addDefaultEntities )
1089 {
1090 this.addDefaultEntities = addDefaultEntities;
1091 }
1092
1093 public static interface ContentTransformer
1094 {
1095
1096
1097
1098
1099
1100
1101
1102 String transform( String source, String fieldName );
1103 }
1104
1105 }