1
2
3
4
5
6 package org.apache.maven.plugins.javadoc.options.io.xpp3;
7
8
9
10
11
12 import java.io.IOException;
13 import java.io.InputStream;
14 import java.io.Reader;
15 import java.text.DateFormat;
16 import org.apache.maven.plugins.javadoc.options.BootclasspathArtifact;
17 import org.apache.maven.plugins.javadoc.options.DocletArtifact;
18 import org.apache.maven.plugins.javadoc.options.Group;
19 import org.apache.maven.plugins.javadoc.options.JavadocOptions;
20 import org.apache.maven.plugins.javadoc.options.JavadocPathArtifact;
21 import org.apache.maven.plugins.javadoc.options.OfflineLink;
22 import org.apache.maven.plugins.javadoc.options.ResourcesArtifact;
23 import org.apache.maven.plugins.javadoc.options.Tag;
24 import org.apache.maven.plugins.javadoc.options.Taglet;
25 import org.apache.maven.plugins.javadoc.options.TagletArtifact;
26 import org.codehaus.plexus.util.xml.XmlStreamReader;
27 import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
28 import org.codehaus.plexus.util.xml.pull.MXParser;
29 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
30 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
31
32
33
34
35
36
37 @SuppressWarnings( "all" )
38 public class JavadocOptionsXpp3Reader
39 {
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 private boolean addDefaultEntities = true;
56
57
58
59
60 public final ContentTransformer contentTransformer;
61
62
63
64
65
66
67 public JavadocOptionsXpp3Reader()
68 {
69 this( new ContentTransformer()
70 {
71 public String transform( String source, String fieldName )
72 {
73 return source;
74 }
75 } );
76 }
77
78 public JavadocOptionsXpp3Reader(ContentTransformer contentTransformer)
79 {
80 this.contentTransformer = contentTransformer;
81 }
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99 private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set<String> parsed )
100 throws XmlPullParserException
101 {
102 if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) )
103 {
104 return false;
105 }
106 if ( !parsed.add( tagName ) )
107 {
108 throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null );
109 }
110 return true;
111 }
112
113
114
115
116
117
118
119
120
121
122
123
124 private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict )
125 throws XmlPullParserException, IOException
126 {
127
128 if ( strict )
129 {
130 throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null );
131 }
132 }
133
134
135
136
137
138
139
140
141
142
143 private void checkUnknownElement( XmlPullParser parser, boolean strict )
144 throws XmlPullParserException, IOException
145 {
146 if ( strict )
147 {
148 throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null );
149 }
150
151 for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; )
152 {
153 int eventType = parser.next();
154 if ( eventType == XmlPullParser.START_TAG )
155 {
156 unrecognizedTagCount++;
157 }
158 else if ( eventType == XmlPullParser.END_TAG )
159 {
160 unrecognizedTagCount--;
161 }
162 }
163 }
164
165
166
167
168
169
170 public boolean getAddDefaultEntities()
171 {
172 return addDefaultEntities;
173 }
174
175
176
177
178
179
180
181
182
183
184
185 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser )
186 throws XmlPullParserException
187 {
188 return getBooleanValue( s, attribute, parser, null );
189 }
190
191
192
193
194
195
196
197
198
199
200
201
202 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue )
203 throws XmlPullParserException
204 {
205 if ( s != null && s.length() != 0 )
206 {
207 return Boolean.valueOf( s ).booleanValue();
208 }
209 if ( defaultValue != null )
210 {
211 return Boolean.valueOf( defaultValue ).booleanValue();
212 }
213 return false;
214 }
215
216
217
218
219
220
221
222
223
224
225
226
227 private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict )
228 throws XmlPullParserException
229 {
230 if ( s != null )
231 {
232 try
233 {
234 return Byte.valueOf( s ).byteValue();
235 }
236 catch ( NumberFormatException nfe )
237 {
238 if ( strict )
239 {
240 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe );
241 }
242 }
243 }
244 return 0;
245 }
246
247
248
249
250
251
252
253
254
255
256
257 private char getCharacterValue( String s, String attribute, XmlPullParser parser )
258 throws XmlPullParserException
259 {
260 if ( s != null )
261 {
262 return s.charAt( 0 );
263 }
264 return 0;
265 }
266
267
268
269
270
271
272
273
274
275
276
277 private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser )
278 throws XmlPullParserException
279 {
280 return getDateValue( s, attribute, null, parser );
281 }
282
283
284
285
286
287
288
289
290
291
292
293
294 private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser )
295 throws XmlPullParserException
296 {
297 if ( s != null )
298 {
299 String effectiveDateFormat = dateFormat;
300 if ( dateFormat == null )
301 {
302 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS";
303 }
304 if ( "long".equals( effectiveDateFormat ) )
305 {
306 try
307 {
308 return new java.util.Date( Long.parseLong( s ) );
309 }
310 catch ( NumberFormatException e )
311 {
312 throw new XmlPullParserException( e.getMessage(), parser, e );
313 }
314 }
315 else
316 {
317 try
318 {
319 DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
320 return dateParser.parse( s );
321 }
322 catch ( java.text.ParseException e )
323 {
324 throw new XmlPullParserException( e.getMessage(), parser, e );
325 }
326 }
327 }
328 return null;
329 }
330
331
332
333
334
335
336
337
338
339
340
341
342 private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict )
343 throws XmlPullParserException
344 {
345 if ( s != null )
346 {
347 try
348 {
349 return Double.valueOf( s ).doubleValue();
350 }
351 catch ( NumberFormatException nfe )
352 {
353 if ( strict )
354 {
355 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
356 }
357 }
358 }
359 return 0;
360 }
361
362
363
364
365
366
367
368
369
370
371
372
373 private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict )
374 throws XmlPullParserException
375 {
376 if ( s != null )
377 {
378 try
379 {
380 return Float.valueOf( s ).floatValue();
381 }
382 catch ( NumberFormatException nfe )
383 {
384 if ( strict )
385 {
386 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
387 }
388 }
389 }
390 return 0;
391 }
392
393
394
395
396
397
398
399
400
401
402
403
404 private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict )
405 throws XmlPullParserException
406 {
407 if ( s != null )
408 {
409 try
410 {
411 return Integer.valueOf( s ).intValue();
412 }
413 catch ( NumberFormatException nfe )
414 {
415 if ( strict )
416 {
417 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe );
418 }
419 }
420 }
421 return 0;
422 }
423
424
425
426
427
428
429
430
431
432
433
434
435 private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict )
436 throws XmlPullParserException
437 {
438 if ( s != null )
439 {
440 try
441 {
442 return Long.valueOf( s ).longValue();
443 }
444 catch ( NumberFormatException nfe )
445 {
446 if ( strict )
447 {
448 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe );
449 }
450 }
451 }
452 return 0;
453 }
454
455
456
457
458
459
460
461
462
463
464
465
466 private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict )
467 throws XmlPullParserException
468 {
469 if ( s == null )
470 {
471 if ( strict )
472 {
473 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null );
474 }
475 }
476 return s;
477 }
478
479
480
481
482
483
484
485
486
487
488
489
490 private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict )
491 throws XmlPullParserException
492 {
493 if ( s != null )
494 {
495 try
496 {
497 return Short.valueOf( s ).shortValue();
498 }
499 catch ( NumberFormatException nfe )
500 {
501 if ( strict )
502 {
503 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe );
504 }
505 }
506 }
507 return 0;
508 }
509
510
511
512
513
514
515
516 private String getTrimmedValue( String s )
517 {
518 if ( s != null )
519 {
520 s = s.trim();
521 }
522 return s;
523 }
524
525
526
527
528
529
530
531
532 private String interpolatedTrimmed( String value, String context )
533 {
534 return getTrimmedValue( contentTransformer.transform( value, context ) );
535 }
536
537
538
539
540
541
542
543
544
545
546 private int nextTag( XmlPullParser parser )
547 throws IOException, XmlPullParserException
548 {
549 int eventType = parser.next();
550 if ( eventType == XmlPullParser.TEXT )
551 {
552 eventType = parser.next();
553 }
554 if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG )
555 {
556 throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null );
557 }
558 return eventType;
559 }
560
561
562
563
564
565
566
567
568
569
570
571 public JavadocOptions read( XmlPullParser parser, boolean strict )
572 throws IOException, XmlPullParserException
573 {
574 JavadocOptions javadocOptions = null;
575 int eventType = parser.getEventType();
576 boolean parsed = false;
577 while ( eventType != XmlPullParser.END_DOCUMENT )
578 {
579 if ( eventType == XmlPullParser.START_TAG )
580 {
581 if ( strict && ! "javadocOptions".equals( parser.getName() ) )
582 {
583 throw new XmlPullParserException( "Expected root element 'javadocOptions' but found '" + parser.getName() + "'", parser, null );
584 }
585 else if ( parsed )
586 {
587
588 throw new XmlPullParserException( "Duplicated tag: 'javadocOptions'", parser, null );
589 }
590 javadocOptions = parseJavadocOptions( parser, strict );
591 javadocOptions.setModelEncoding( parser.getInputEncoding() );
592 parsed = true;
593 }
594 eventType = parser.next();
595 }
596 if ( parsed )
597 {
598 return javadocOptions;
599 }
600 throw new XmlPullParserException( "Expected root element 'javadocOptions' but found no element at all: invalid XML document", parser, null );
601 }
602
603
604
605
606
607
608
609
610
611
612
613 public JavadocOptions read( Reader reader, boolean strict )
614 throws IOException, XmlPullParserException
615 {
616 XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( );
617
618 parser.setInput( reader );
619
620
621 return read( parser, strict );
622 }
623
624
625
626
627
628
629
630
631
632
633 public JavadocOptions read( Reader reader )
634 throws IOException, XmlPullParserException
635 {
636 return read( reader, true );
637 }
638
639
640
641
642
643
644
645
646
647
648
649 public JavadocOptions read( InputStream in, boolean strict )
650 throws IOException, XmlPullParserException
651 {
652 return read( new XmlStreamReader( in ), strict );
653 }
654
655
656
657
658
659
660
661
662
663
664 public JavadocOptions read( InputStream in )
665 throws IOException, XmlPullParserException
666 {
667 return read( new XmlStreamReader( in ) );
668 }
669
670
671
672
673
674
675
676
677
678
679
680 private BootclasspathArtifact parseBootclasspathArtifact( XmlPullParser parser, boolean strict )
681 throws IOException, XmlPullParserException
682 {
683 String tagName = parser.getName();
684 BootclasspathArtifact bootclasspathArtifact = new BootclasspathArtifact();
685 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
686 {
687 String name = parser.getAttributeName( i );
688 String value = parser.getAttributeValue( i );
689
690 if ( name.indexOf( ':' ) >= 0 )
691 {
692
693 }
694 else
695 {
696 checkUnknownAttribute( parser, name, tagName, strict );
697 }
698 }
699 java.util.Set<String> parsed = new java.util.HashSet<String>();
700 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
701 {
702 if ( checkFieldWithDuplicate( parser, "groupId", null, parsed ) )
703 {
704 bootclasspathArtifact.setGroupId( interpolatedTrimmed( parser.nextText(), "groupId" ) );
705 }
706 else if ( checkFieldWithDuplicate( parser, "artifactId", null, parsed ) )
707 {
708 bootclasspathArtifact.setArtifactId( interpolatedTrimmed( parser.nextText(), "artifactId" ) );
709 }
710 else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
711 {
712 bootclasspathArtifact.setVersion( interpolatedTrimmed( parser.nextText(), "version" ) );
713 }
714 else if ( checkFieldWithDuplicate( parser, "classifier", null, parsed ) )
715 {
716 bootclasspathArtifact.setClassifier( interpolatedTrimmed( parser.nextText(), "classifier" ) );
717 }
718 else
719 {
720 checkUnknownElement( parser, strict );
721 }
722 }
723 return bootclasspathArtifact;
724 }
725
726
727
728
729
730
731
732
733
734
735
736 private DocletArtifact parseDocletArtifact( XmlPullParser parser, boolean strict )
737 throws IOException, XmlPullParserException
738 {
739 String tagName = parser.getName();
740 DocletArtifact docletArtifact = new DocletArtifact();
741 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
742 {
743 String name = parser.getAttributeName( i );
744 String value = parser.getAttributeValue( i );
745
746 if ( name.indexOf( ':' ) >= 0 )
747 {
748
749 }
750 else
751 {
752 checkUnknownAttribute( parser, name, tagName, strict );
753 }
754 }
755 java.util.Set<String> parsed = new java.util.HashSet<String>();
756 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
757 {
758 if ( checkFieldWithDuplicate( parser, "groupId", null, parsed ) )
759 {
760 docletArtifact.setGroupId( interpolatedTrimmed( parser.nextText(), "groupId" ) );
761 }
762 else if ( checkFieldWithDuplicate( parser, "artifactId", null, parsed ) )
763 {
764 docletArtifact.setArtifactId( interpolatedTrimmed( parser.nextText(), "artifactId" ) );
765 }
766 else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
767 {
768 docletArtifact.setVersion( interpolatedTrimmed( parser.nextText(), "version" ) );
769 }
770 else if ( checkFieldWithDuplicate( parser, "classifier", null, parsed ) )
771 {
772 docletArtifact.setClassifier( interpolatedTrimmed( parser.nextText(), "classifier" ) );
773 }
774 else
775 {
776 checkUnknownElement( parser, strict );
777 }
778 }
779 return docletArtifact;
780 }
781
782
783
784
785
786
787
788
789
790
791
792 private Group parseGroup( XmlPullParser parser, boolean strict )
793 throws IOException, XmlPullParserException
794 {
795 String tagName = parser.getName();
796 Group group = new Group();
797 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
798 {
799 String name = parser.getAttributeName( i );
800 String value = parser.getAttributeValue( i );
801
802 if ( name.indexOf( ':' ) >= 0 )
803 {
804
805 }
806 else
807 {
808 checkUnknownAttribute( parser, name, tagName, strict );
809 }
810 }
811 java.util.Set<String> parsed = new java.util.HashSet<String>();
812 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
813 {
814 if ( checkFieldWithDuplicate( parser, "title", null, parsed ) )
815 {
816 group.setTitle( interpolatedTrimmed( parser.nextText(), "title" ) );
817 }
818 else if ( checkFieldWithDuplicate( parser, "packages", null, parsed ) )
819 {
820 group.setPackages( interpolatedTrimmed( parser.nextText(), "packages" ) );
821 }
822 else
823 {
824 checkUnknownElement( parser, strict );
825 }
826 }
827 return group;
828 }
829
830
831
832
833
834
835
836
837
838
839
840 private JavadocOptions parseJavadocOptions( XmlPullParser parser, boolean strict )
841 throws IOException, XmlPullParserException
842 {
843 String tagName = parser.getName();
844 JavadocOptions javadocOptions = new JavadocOptions();
845 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
846 {
847 String name = parser.getAttributeName( i );
848 String value = parser.getAttributeValue( i );
849
850 if ( name.indexOf( ':' ) >= 0 )
851 {
852
853 }
854 else if ( "xmlns".equals( name ) )
855 {
856
857 }
858 else
859 {
860 checkUnknownAttribute( parser, name, tagName, strict );
861 }
862 }
863 java.util.Set<String> parsed = new java.util.HashSet<String>();
864 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
865 {
866 if ( checkFieldWithDuplicate( parser, "groups", null, parsed ) )
867 {
868 java.util.List<Group> groups = new java.util.ArrayList<Group>();
869 while ( parser.nextTag() == XmlPullParser.START_TAG )
870 {
871 if ( "group".equals( parser.getName() ) )
872 {
873 groups.add( parseGroup( parser, strict ) );
874 }
875 else
876 {
877 checkUnknownElement( parser, strict );
878 }
879 }
880 javadocOptions.setGroups( groups );
881 }
882 else if ( checkFieldWithDuplicate( parser, "tags", null, parsed ) )
883 {
884 java.util.List<Tag> tags = new java.util.ArrayList<Tag>();
885 while ( parser.nextTag() == XmlPullParser.START_TAG )
886 {
887 if ( "tag".equals( parser.getName() ) )
888 {
889 tags.add( parseTag( parser, strict ) );
890 }
891 else
892 {
893 checkUnknownElement( parser, strict );
894 }
895 }
896 javadocOptions.setTags( tags );
897 }
898 else if ( checkFieldWithDuplicate( parser, "docletArtifacts", null, parsed ) )
899 {
900 java.util.List<DocletArtifact> docletArtifacts = new java.util.ArrayList<DocletArtifact>();
901 while ( parser.nextTag() == XmlPullParser.START_TAG )
902 {
903 if ( "docletArtifact".equals( parser.getName() ) )
904 {
905 docletArtifacts.add( parseDocletArtifact( parser, strict ) );
906 }
907 else
908 {
909 checkUnknownElement( parser, strict );
910 }
911 }
912 javadocOptions.setDocletArtifacts( docletArtifacts );
913 }
914 else if ( checkFieldWithDuplicate( parser, "taglets", null, parsed ) )
915 {
916 java.util.List<Taglet> taglets = new java.util.ArrayList<Taglet>();
917 while ( parser.nextTag() == XmlPullParser.START_TAG )
918 {
919 if ( "taglet".equals( parser.getName() ) )
920 {
921 taglets.add( parseTaglet( parser, strict ) );
922 }
923 else
924 {
925 checkUnknownElement( parser, strict );
926 }
927 }
928 javadocOptions.setTaglets( taglets );
929 }
930 else if ( checkFieldWithDuplicate( parser, "offlineLinks", null, parsed ) )
931 {
932 java.util.List<OfflineLink> offlineLinks = new java.util.ArrayList<OfflineLink>();
933 while ( parser.nextTag() == XmlPullParser.START_TAG )
934 {
935 if ( "offlineLink".equals( parser.getName() ) )
936 {
937 offlineLinks.add( parseOfflineLink( parser, strict ) );
938 }
939 else
940 {
941 checkUnknownElement( parser, strict );
942 }
943 }
944 javadocOptions.setOfflineLinks( offlineLinks );
945 }
946 else if ( checkFieldWithDuplicate( parser, "tagletArtifacts", null, parsed ) )
947 {
948 java.util.List<TagletArtifact> tagletArtifacts = new java.util.ArrayList<TagletArtifact>();
949 while ( parser.nextTag() == XmlPullParser.START_TAG )
950 {
951 if ( "tagletArtifact".equals( parser.getName() ) )
952 {
953 tagletArtifacts.add( parseTagletArtifact( parser, strict ) );
954 }
955 else
956 {
957 checkUnknownElement( parser, strict );
958 }
959 }
960 javadocOptions.setTagletArtifacts( tagletArtifacts );
961 }
962 else if ( checkFieldWithDuplicate( parser, "resourcesArtifacts", null, parsed ) )
963 {
964 java.util.List<ResourcesArtifact> resourcesArtifacts = new java.util.ArrayList<ResourcesArtifact>();
965 while ( parser.nextTag() == XmlPullParser.START_TAG )
966 {
967 if ( "resourcesArtifact".equals( parser.getName() ) )
968 {
969 resourcesArtifacts.add( parseResourcesArtifact( parser, strict ) );
970 }
971 else
972 {
973 checkUnknownElement( parser, strict );
974 }
975 }
976 javadocOptions.setResourcesArtifacts( resourcesArtifacts );
977 }
978 else if ( checkFieldWithDuplicate( parser, "bootclasspathArtifacts", null, parsed ) )
979 {
980 java.util.List<BootclasspathArtifact> bootclasspathArtifacts = new java.util.ArrayList<BootclasspathArtifact>();
981 while ( parser.nextTag() == XmlPullParser.START_TAG )
982 {
983 if ( "bootclasspathArtifact".equals( parser.getName() ) )
984 {
985 bootclasspathArtifacts.add( parseBootclasspathArtifact( parser, strict ) );
986 }
987 else
988 {
989 checkUnknownElement( parser, strict );
990 }
991 }
992 javadocOptions.setBootclasspathArtifacts( bootclasspathArtifacts );
993 }
994 else if ( checkFieldWithDuplicate( parser, "links", null, parsed ) )
995 {
996 java.util.List<String> links = new java.util.ArrayList<String>();
997 while ( parser.nextTag() == XmlPullParser.START_TAG )
998 {
999 if ( "link".equals( parser.getName() ) )
1000 {
1001 links.add( interpolatedTrimmed( parser.nextText(), "links" ) );
1002 }
1003 else
1004 {
1005 checkUnknownElement( parser, strict );
1006 }
1007 }
1008 javadocOptions.setLinks( links );
1009 }
1010 else if ( checkFieldWithDuplicate( parser, "excludePackageNames", null, parsed ) )
1011 {
1012 java.util.List<String> excludePackageNames = new java.util.ArrayList<String>();
1013 while ( parser.nextTag() == XmlPullParser.START_TAG )
1014 {
1015 if ( "excludePackageName".equals( parser.getName() ) )
1016 {
1017 excludePackageNames.add( interpolatedTrimmed( parser.nextText(), "excludePackageNames" ) );
1018 }
1019 else
1020 {
1021 checkUnknownElement( parser, strict );
1022 }
1023 }
1024 javadocOptions.setExcludePackageNames( excludePackageNames );
1025 }
1026 else if ( checkFieldWithDuplicate( parser, "docfilesSubdirsUsed", null, parsed ) )
1027 {
1028 javadocOptions.setDocfilesSubdirsUsed( getBooleanValue( interpolatedTrimmed( parser.nextText(), "docfilesSubdirsUsed" ), "docfilesSubdirsUsed", parser, "false" ) );
1029 }
1030 else if ( checkFieldWithDuplicate( parser, "excludedDocfilesSubdirs", null, parsed ) )
1031 {
1032 javadocOptions.setExcludedDocfilesSubdirs( interpolatedTrimmed( parser.nextText(), "excludedDocfilesSubdirs" ) );
1033 }
1034 else if ( checkFieldWithDuplicate( parser, "javadocResourcesDirectory", null, parsed ) )
1035 {
1036 javadocOptions.setJavadocResourcesDirectory( interpolatedTrimmed( parser.nextText(), "javadocResourcesDirectory" ) );
1037 }
1038 else
1039 {
1040 checkUnknownElement( parser, strict );
1041 }
1042 }
1043 return javadocOptions;
1044 }
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056 private JavadocPathArtifact parseJavadocPathArtifact( XmlPullParser parser, boolean strict )
1057 throws IOException, XmlPullParserException
1058 {
1059 String tagName = parser.getName();
1060 JavadocPathArtifact javadocPathArtifact = new JavadocPathArtifact();
1061 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1062 {
1063 String name = parser.getAttributeName( i );
1064 String value = parser.getAttributeValue( i );
1065
1066 if ( name.indexOf( ':' ) >= 0 )
1067 {
1068
1069 }
1070 else
1071 {
1072 checkUnknownAttribute( parser, name, tagName, strict );
1073 }
1074 }
1075 java.util.Set<String> parsed = new java.util.HashSet<String>();
1076 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1077 {
1078 if ( checkFieldWithDuplicate( parser, "groupId", null, parsed ) )
1079 {
1080 javadocPathArtifact.setGroupId( interpolatedTrimmed( parser.nextText(), "groupId" ) );
1081 }
1082 else if ( checkFieldWithDuplicate( parser, "artifactId", null, parsed ) )
1083 {
1084 javadocPathArtifact.setArtifactId( interpolatedTrimmed( parser.nextText(), "artifactId" ) );
1085 }
1086 else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
1087 {
1088 javadocPathArtifact.setVersion( interpolatedTrimmed( parser.nextText(), "version" ) );
1089 }
1090 else if ( checkFieldWithDuplicate( parser, "classifier", null, parsed ) )
1091 {
1092 javadocPathArtifact.setClassifier( interpolatedTrimmed( parser.nextText(), "classifier" ) );
1093 }
1094 else
1095 {
1096 checkUnknownElement( parser, strict );
1097 }
1098 }
1099 return javadocPathArtifact;
1100 }
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112 private OfflineLink parseOfflineLink( XmlPullParser parser, boolean strict )
1113 throws IOException, XmlPullParserException
1114 {
1115 String tagName = parser.getName();
1116 OfflineLink offlineLink = new OfflineLink();
1117 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1118 {
1119 String name = parser.getAttributeName( i );
1120 String value = parser.getAttributeValue( i );
1121
1122 if ( name.indexOf( ':' ) >= 0 )
1123 {
1124
1125 }
1126 else
1127 {
1128 checkUnknownAttribute( parser, name, tagName, strict );
1129 }
1130 }
1131 java.util.Set<String> parsed = new java.util.HashSet<String>();
1132 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1133 {
1134 if ( checkFieldWithDuplicate( parser, "url", null, parsed ) )
1135 {
1136 offlineLink.setUrl( interpolatedTrimmed( parser.nextText(), "url" ) );
1137 }
1138 else if ( checkFieldWithDuplicate( parser, "location", null, parsed ) )
1139 {
1140 offlineLink.setLocation( interpolatedTrimmed( parser.nextText(), "location" ) );
1141 }
1142 else
1143 {
1144 checkUnknownElement( parser, strict );
1145 }
1146 }
1147 return offlineLink;
1148 }
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160 private ResourcesArtifact parseResourcesArtifact( XmlPullParser parser, boolean strict )
1161 throws IOException, XmlPullParserException
1162 {
1163 String tagName = parser.getName();
1164 ResourcesArtifact resourcesArtifact = new ResourcesArtifact();
1165 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1166 {
1167 String name = parser.getAttributeName( i );
1168 String value = parser.getAttributeValue( i );
1169
1170 if ( name.indexOf( ':' ) >= 0 )
1171 {
1172
1173 }
1174 else
1175 {
1176 checkUnknownAttribute( parser, name, tagName, strict );
1177 }
1178 }
1179 java.util.Set<String> parsed = new java.util.HashSet<String>();
1180 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1181 {
1182 if ( checkFieldWithDuplicate( parser, "groupId", null, parsed ) )
1183 {
1184 resourcesArtifact.setGroupId( interpolatedTrimmed( parser.nextText(), "groupId" ) );
1185 }
1186 else if ( checkFieldWithDuplicate( parser, "artifactId", null, parsed ) )
1187 {
1188 resourcesArtifact.setArtifactId( interpolatedTrimmed( parser.nextText(), "artifactId" ) );
1189 }
1190 else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
1191 {
1192 resourcesArtifact.setVersion( interpolatedTrimmed( parser.nextText(), "version" ) );
1193 }
1194 else if ( checkFieldWithDuplicate( parser, "classifier", null, parsed ) )
1195 {
1196 resourcesArtifact.setClassifier( interpolatedTrimmed( parser.nextText(), "classifier" ) );
1197 }
1198 else
1199 {
1200 checkUnknownElement( parser, strict );
1201 }
1202 }
1203 return resourcesArtifact;
1204 }
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216 private Tag parseTag( XmlPullParser parser, boolean strict )
1217 throws IOException, XmlPullParserException
1218 {
1219 String tagName = parser.getName();
1220 Tag tag = new Tag();
1221 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1222 {
1223 String name = parser.getAttributeName( i );
1224 String value = parser.getAttributeValue( i );
1225
1226 if ( name.indexOf( ':' ) >= 0 )
1227 {
1228
1229 }
1230 else
1231 {
1232 checkUnknownAttribute( parser, name, tagName, strict );
1233 }
1234 }
1235 java.util.Set<String> parsed = new java.util.HashSet<String>();
1236 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1237 {
1238 if ( checkFieldWithDuplicate( parser, "name", null, parsed ) )
1239 {
1240 tag.setName( interpolatedTrimmed( parser.nextText(), "name" ) );
1241 }
1242 else if ( checkFieldWithDuplicate( parser, "head", null, parsed ) )
1243 {
1244 tag.setHead( interpolatedTrimmed( parser.nextText(), "head" ) );
1245 }
1246 else if ( checkFieldWithDuplicate( parser, "placement", null, parsed ) )
1247 {
1248 tag.setPlacement( interpolatedTrimmed( parser.nextText(), "placement" ) );
1249 }
1250 else
1251 {
1252 checkUnknownElement( parser, strict );
1253 }
1254 }
1255 return tag;
1256 }
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268 private Taglet parseTaglet( XmlPullParser parser, boolean strict )
1269 throws IOException, XmlPullParserException
1270 {
1271 String tagName = parser.getName();
1272 Taglet taglet = new Taglet();
1273 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1274 {
1275 String name = parser.getAttributeName( i );
1276 String value = parser.getAttributeValue( i );
1277
1278 if ( name.indexOf( ':' ) >= 0 )
1279 {
1280
1281 }
1282 else
1283 {
1284 checkUnknownAttribute( parser, name, tagName, strict );
1285 }
1286 }
1287 java.util.Set<String> parsed = new java.util.HashSet<String>();
1288 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1289 {
1290 if ( checkFieldWithDuplicate( parser, "tagletClass", null, parsed ) )
1291 {
1292 taglet.setTagletClass( interpolatedTrimmed( parser.nextText(), "tagletClass" ) );
1293 }
1294 else if ( checkFieldWithDuplicate( parser, "tagletpath", null, parsed ) )
1295 {
1296 taglet.setTagletpath( interpolatedTrimmed( parser.nextText(), "tagletpath" ) );
1297 }
1298 else if ( checkFieldWithDuplicate( parser, "tagletArtifact", null, parsed ) )
1299 {
1300 taglet.setTagletArtifact( parseTagletArtifact( parser, strict ) );
1301 }
1302 else
1303 {
1304 checkUnknownElement( parser, strict );
1305 }
1306 }
1307 return taglet;
1308 }
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320 private TagletArtifact parseTagletArtifact( XmlPullParser parser, boolean strict )
1321 throws IOException, XmlPullParserException
1322 {
1323 String tagName = parser.getName();
1324 TagletArtifact tagletArtifact = new TagletArtifact();
1325 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1326 {
1327 String name = parser.getAttributeName( i );
1328 String value = parser.getAttributeValue( i );
1329
1330 if ( name.indexOf( ':' ) >= 0 )
1331 {
1332
1333 }
1334 else
1335 {
1336 checkUnknownAttribute( parser, name, tagName, strict );
1337 }
1338 }
1339 java.util.Set<String> parsed = new java.util.HashSet<String>();
1340 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1341 {
1342 if ( checkFieldWithDuplicate( parser, "groupId", null, parsed ) )
1343 {
1344 tagletArtifact.setGroupId( interpolatedTrimmed( parser.nextText(), "groupId" ) );
1345 }
1346 else if ( checkFieldWithDuplicate( parser, "artifactId", null, parsed ) )
1347 {
1348 tagletArtifact.setArtifactId( interpolatedTrimmed( parser.nextText(), "artifactId" ) );
1349 }
1350 else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
1351 {
1352 tagletArtifact.setVersion( interpolatedTrimmed( parser.nextText(), "version" ) );
1353 }
1354 else if ( checkFieldWithDuplicate( parser, "classifier", null, parsed ) )
1355 {
1356 tagletArtifact.setClassifier( interpolatedTrimmed( parser.nextText(), "classifier" ) );
1357 }
1358 else
1359 {
1360 checkUnknownElement( parser, strict );
1361 }
1362 }
1363 return tagletArtifact;
1364 }
1365
1366
1367
1368
1369
1370
1371 public void setAddDefaultEntities( boolean addDefaultEntities )
1372 {
1373 this.addDefaultEntities = addDefaultEntities;
1374 }
1375
1376 public static interface ContentTransformer
1377 {
1378
1379
1380
1381
1382
1383
1384
1385 String transform( String source, String fieldName );
1386 }
1387
1388 }