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