1
2
3
4
5 package org.apache.maven.model.v4;
6
7 import java.io.IOException;
8 import java.io.InputStream;
9 import java.io.Reader;
10 import java.text.DateFormat;
11 import java.util.ArrayList;
12 import java.util.Date;
13 import java.util.HashMap;
14 import java.util.HashSet;
15 import java.util.LinkedHashMap;
16 import java.util.List;
17 import java.util.Map;
18 import java.util.Set;
19 import org.apache.maven.api.annotations.Generated;
20 import org.apache.maven.internal.xml.XmlNodeBuilder;
21 import org.apache.maven.api.model.InputSource;
22 import org.apache.maven.api.model.InputLocation;
23 import org.apache.maven.api.model.Model;
24 import org.apache.maven.api.model.ModelBase;
25 import org.apache.maven.api.model.PluginContainer;
26 import org.apache.maven.api.model.PluginConfiguration;
27 import org.apache.maven.api.model.BuildBase;
28 import org.apache.maven.api.model.Build;
29 import org.apache.maven.api.model.CiManagement;
30 import org.apache.maven.api.model.Notifier;
31 import org.apache.maven.api.model.Contributor;
32 import org.apache.maven.api.model.Dependency;
33 import org.apache.maven.api.model.Developer;
34 import org.apache.maven.api.model.Exclusion;
35 import org.apache.maven.api.model.IssueManagement;
36 import org.apache.maven.api.model.DistributionManagement;
37 import org.apache.maven.api.model.License;
38 import org.apache.maven.api.model.MailingList;
39 import org.apache.maven.api.model.Organization;
40 import org.apache.maven.api.model.PatternSet;
41 import org.apache.maven.api.model.Parent;
42 import org.apache.maven.api.model.Scm;
43 import org.apache.maven.api.model.FileSet;
44 import org.apache.maven.api.model.Resource;
45 import org.apache.maven.api.model.RepositoryBase;
46 import org.apache.maven.api.model.Repository;
47 import org.apache.maven.api.model.DeploymentRepository;
48 import org.apache.maven.api.model.RepositoryPolicy;
49 import org.apache.maven.api.model.Site;
50 import org.apache.maven.api.model.ConfigurationContainer;
51 import org.apache.maven.api.model.Plugin;
52 import org.apache.maven.api.model.PluginExecution;
53 import org.apache.maven.api.model.DependencyManagement;
54 import org.apache.maven.api.model.PluginManagement;
55 import org.apache.maven.api.model.Reporting;
56 import org.apache.maven.api.model.Profile;
57 import org.apache.maven.api.model.Activation;
58 import org.apache.maven.api.model.ActivationProperty;
59 import org.apache.maven.api.model.ActivationOS;
60 import org.apache.maven.api.model.ActivationFile;
61 import org.apache.maven.api.model.ReportPlugin;
62 import org.apache.maven.api.model.ReportSet;
63 import org.apache.maven.api.model.Prerequisites;
64 import org.apache.maven.api.model.Relocation;
65 import org.apache.maven.api.model.Extension;
66 import org.apache.maven.api.model.InputLocation;
67 import org.apache.maven.api.model.InputSource;
68 import org.codehaus.plexus.util.ReaderFactory;
69 import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
70 import org.codehaus.plexus.util.xml.pull.MXParser;
71 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
72 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
73
74 @Generated
75 public class MavenXpp3ReaderEx {
76
77 private boolean addDefaultEntities = true;
78
79 private final ContentTransformer contentTransformer;
80
81 public MavenXpp3ReaderEx() {
82 this((s, f) -> s);
83 }
84
85 public MavenXpp3ReaderEx(ContentTransformer contentTransformer) {
86 this.contentTransformer = contentTransformer;
87 }
88
89
90
91
92
93
94 public boolean getAddDefaultEntities() {
95 return addDefaultEntities;
96 }
97
98
99
100
101
102
103 public void setAddDefaultEntities(boolean addDefaultEntities) {
104 this.addDefaultEntities = addDefaultEntities;
105 }
106
107
108
109
110
111
112
113
114
115
116
117 public Model read(Reader reader, boolean strict, InputSource source) throws IOException, XmlPullParserException {
118 XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser();
119 parser.setInput(reader);
120 return read(parser, strict, source);
121 }
122
123
124
125
126
127
128
129
130
131
132
133 public Model read(InputStream in, boolean strict, InputSource source) throws IOException, XmlPullParserException {
134 return read(ReaderFactory.newXmlReader(in), strict, source);
135 }
136
137
138
139
140
141
142
143
144
145
146
147 public Model read(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
148 Model model = null;
149 int eventType = parser.getEventType();
150 boolean parsed = false;
151 while (eventType != XmlPullParser.END_DOCUMENT) {
152 if (eventType == XmlPullParser.START_TAG) {
153 if (strict && ! "project".equals(parser.getName())) {
154 throw new XmlPullParserException("Expected root element 'project' but found '" + parser.getName() + "'", parser, null);
155 } else if (parsed) {
156
157 throw new XmlPullParserException("Duplicated tag: 'project'", parser, null);
158 }
159 model = parseModel(parser, strict, source);
160 parsed = true;
161 }
162 eventType = parser.next();
163 }
164 if (parsed) {
165 return model;
166 }
167 throw new XmlPullParserException("Expected root element 'project' but found no element at all: invalid XML document", parser, null);
168 }
169
170 private Model parseModel(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
171 String tagName = parser.getName();
172 Model.Builder model = Model.newBuilder(true);
173 model.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
174 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
175 String name = parser.getAttributeName(i);
176 String value = parser.getAttributeValue(i);
177 if (name.indexOf(':') >= 0) {
178
179 } else if ("xmlns".equals(name)) {
180
181 } else if ("child.project.url.inherit.append.path".equals(name)) {
182 model.location(name, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
183 model.childProjectUrlInheritAppendPath(interpolatedTrimmed(value, "child.project.url.inherit.append.path"));
184 } else if ("root".equals(name)) {
185 model.location(name, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
186 model.root(getBooleanValue(interpolatedTrimmed(value, "root"), "root", parser, false));
187 } else {
188 checkUnknownAttribute(parser, name, tagName, strict);
189 }
190 }
191 Set<String> parsed = new HashSet<>();
192 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
193 String childName = unalias(parser.getName());
194 if (!parsed.add(childName)) {
195 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
196 }
197 int line = parser.getLineNumber();
198 int column = parser.getColumnNumber();
199 Map<Object, InputLocation> locations = null;
200 switch (childName) {
201 case "modelVersion": {
202 model.modelVersion(interpolatedTrimmed(parser.nextText(), "modelVersion"));
203 break;
204 }
205 case "parent": {
206 model.parent(parseParent(parser, strict, source ));
207 break;
208 }
209 case "groupId": {
210 model.groupId(interpolatedTrimmed(parser.nextText(), "groupId"));
211 break;
212 }
213 case "artifactId": {
214 model.artifactId(interpolatedTrimmed(parser.nextText(), "artifactId"));
215 break;
216 }
217 case "version": {
218 model.version(interpolatedTrimmed(parser.nextText(), "version"));
219 break;
220 }
221 case "packaging": {
222 model.packaging(interpolatedTrimmed(parser.nextText(), "packaging"));
223 break;
224 }
225 case "name": {
226 model.name(interpolatedTrimmed(parser.nextText(), "name"));
227 break;
228 }
229 case "description": {
230 model.description(interpolatedTrimmed(parser.nextText(), "description"));
231 break;
232 }
233 case "url": {
234 model.url(interpolatedTrimmed(parser.nextText(), "url"));
235 break;
236 }
237 case "inceptionYear": {
238 model.inceptionYear(interpolatedTrimmed(parser.nextText(), "inceptionYear"));
239 break;
240 }
241 case "organization": {
242 model.organization(parseOrganization(parser, strict, source ));
243 break;
244 }
245 case "licenses": {
246 List<License> licenses = new ArrayList<>();
247 while (parser.nextTag() == XmlPullParser.START_TAG) {
248 if ("license".equals(parser.getName())) {
249 licenses.add(parseLicense(parser, strict, source));
250 } else {
251 checkUnknownElement(parser, strict);
252 }
253 }
254 model.licenses(licenses);
255 break;
256 }
257 case "developers": {
258 List<Developer> developers = new ArrayList<>();
259 while (parser.nextTag() == XmlPullParser.START_TAG) {
260 if ("developer".equals(parser.getName())) {
261 developers.add(parseDeveloper(parser, strict, source));
262 } else {
263 checkUnknownElement(parser, strict);
264 }
265 }
266 model.developers(developers);
267 break;
268 }
269 case "contributors": {
270 List<Contributor> contributors = new ArrayList<>();
271 while (parser.nextTag() == XmlPullParser.START_TAG) {
272 if ("contributor".equals(parser.getName())) {
273 contributors.add(parseContributor(parser, strict, source));
274 } else {
275 checkUnknownElement(parser, strict);
276 }
277 }
278 model.contributors(contributors);
279 break;
280 }
281 case "mailingLists": {
282 List<MailingList> mailingLists = new ArrayList<>();
283 while (parser.nextTag() == XmlPullParser.START_TAG) {
284 if ("mailingList".equals(parser.getName())) {
285 mailingLists.add(parseMailingList(parser, strict, source));
286 } else {
287 checkUnknownElement(parser, strict);
288 }
289 }
290 model.mailingLists(mailingLists);
291 break;
292 }
293 case "prerequisites": {
294 model.prerequisites(parsePrerequisites(parser, strict, source ));
295 break;
296 }
297 case "modules": {
298 List<String> modules = new ArrayList<>();
299 locations = new HashMap<>();
300 while (parser.nextTag() == XmlPullParser.START_TAG) {
301 if ("module".equals(parser.getName())) {
302 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
303 modules.add(interpolatedTrimmed(parser.nextText(), "modules"));
304 } else {
305 checkUnknownElement(parser, strict);
306 }
307 }
308 model.modules(modules);
309 break;
310 }
311 case "scm": {
312 model.scm(parseScm(parser, strict, source ));
313 break;
314 }
315 case "issueManagement": {
316 model.issueManagement(parseIssueManagement(parser, strict, source ));
317 break;
318 }
319 case "ciManagement": {
320 model.ciManagement(parseCiManagement(parser, strict, source ));
321 break;
322 }
323 case "distributionManagement": {
324 model.distributionManagement(parseDistributionManagement(parser, strict, source ));
325 break;
326 }
327 case "properties": {
328 Map<String, String> properties = new LinkedHashMap<>();
329 locations = new HashMap<>();
330 while (parser.nextTag() == XmlPullParser.START_TAG) {
331 String key = parser.getName();
332 String value = parser.nextText().trim();
333 locations.put(key, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
334 properties.put(key, value);
335 }
336 model.properties(properties);
337 break;
338 }
339 case "dependencyManagement": {
340 model.dependencyManagement(parseDependencyManagement(parser, strict, source ));
341 break;
342 }
343 case "dependencies": {
344 List<Dependency> dependencies = new ArrayList<>();
345 while (parser.nextTag() == XmlPullParser.START_TAG) {
346 if ("dependency".equals(parser.getName())) {
347 dependencies.add(parseDependency(parser, strict, source));
348 } else {
349 checkUnknownElement(parser, strict);
350 }
351 }
352 model.dependencies(dependencies);
353 break;
354 }
355 case "repositories": {
356 List<Repository> repositories = new ArrayList<>();
357 while (parser.nextTag() == XmlPullParser.START_TAG) {
358 if ("repository".equals(parser.getName())) {
359 repositories.add(parseRepository(parser, strict, source));
360 } else {
361 checkUnknownElement(parser, strict);
362 }
363 }
364 model.repositories(repositories);
365 break;
366 }
367 case "pluginRepositories": {
368 List<Repository> pluginRepositories = new ArrayList<>();
369 while (parser.nextTag() == XmlPullParser.START_TAG) {
370 if ("pluginRepository".equals(parser.getName())) {
371 pluginRepositories.add(parseRepository(parser, strict, source));
372 } else {
373 checkUnknownElement(parser, strict);
374 }
375 }
376 model.pluginRepositories(pluginRepositories);
377 break;
378 }
379 case "build": {
380 model.build(parseBuild(parser, strict, source ));
381 break;
382 }
383 case "reporting": {
384 model.reporting(parseReporting(parser, strict, source ));
385 break;
386 }
387 case "profiles": {
388 List<Profile> profiles = new ArrayList<>();
389 while (parser.nextTag() == XmlPullParser.START_TAG) {
390 if ("profile".equals(parser.getName())) {
391 profiles.add(parseProfile(parser, strict, source));
392 } else {
393 checkUnknownElement(parser, strict);
394 }
395 }
396 model.profiles(profiles);
397 break;
398 }
399 default: {
400 checkUnknownElement(parser, strict);
401 break;
402 }
403 }
404 model.location(childName, new InputLocation(line, column, source, locations));
405 }
406 model.modelEncoding(parser.getInputEncoding());
407 return model.build();
408 }
409
410 private ModelBase parseModelBase(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
411 String tagName = parser.getName();
412 ModelBase.Builder modelBase = ModelBase.newBuilder(true);
413 modelBase.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
414 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
415 String name = parser.getAttributeName(i);
416 String value = parser.getAttributeValue(i);
417 if (name.indexOf(':') >= 0) {
418
419 } else {
420 checkUnknownAttribute(parser, name, tagName, strict);
421 }
422 }
423 Set<String> parsed = new HashSet<>();
424 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
425 String childName = unalias(parser.getName());
426 if (!parsed.add(childName)) {
427 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
428 }
429 int line = parser.getLineNumber();
430 int column = parser.getColumnNumber();
431 Map<Object, InputLocation> locations = null;
432 switch (childName) {
433 case "modules": {
434 List<String> modules = new ArrayList<>();
435 locations = new HashMap<>();
436 while (parser.nextTag() == XmlPullParser.START_TAG) {
437 if ("module".equals(parser.getName())) {
438 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
439 modules.add(interpolatedTrimmed(parser.nextText(), "modules"));
440 } else {
441 checkUnknownElement(parser, strict);
442 }
443 }
444 modelBase.modules(modules);
445 break;
446 }
447 case "distributionManagement": {
448 modelBase.distributionManagement(parseDistributionManagement(parser, strict, source ));
449 break;
450 }
451 case "properties": {
452 Map<String, String> properties = new LinkedHashMap<>();
453 locations = new HashMap<>();
454 while (parser.nextTag() == XmlPullParser.START_TAG) {
455 String key = parser.getName();
456 String value = parser.nextText().trim();
457 locations.put(key, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
458 properties.put(key, value);
459 }
460 modelBase.properties(properties);
461 break;
462 }
463 case "dependencyManagement": {
464 modelBase.dependencyManagement(parseDependencyManagement(parser, strict, source ));
465 break;
466 }
467 case "dependencies": {
468 List<Dependency> dependencies = new ArrayList<>();
469 while (parser.nextTag() == XmlPullParser.START_TAG) {
470 if ("dependency".equals(parser.getName())) {
471 dependencies.add(parseDependency(parser, strict, source));
472 } else {
473 checkUnknownElement(parser, strict);
474 }
475 }
476 modelBase.dependencies(dependencies);
477 break;
478 }
479 case "repositories": {
480 List<Repository> repositories = new ArrayList<>();
481 while (parser.nextTag() == XmlPullParser.START_TAG) {
482 if ("repository".equals(parser.getName())) {
483 repositories.add(parseRepository(parser, strict, source));
484 } else {
485 checkUnknownElement(parser, strict);
486 }
487 }
488 modelBase.repositories(repositories);
489 break;
490 }
491 case "pluginRepositories": {
492 List<Repository> pluginRepositories = new ArrayList<>();
493 while (parser.nextTag() == XmlPullParser.START_TAG) {
494 if ("pluginRepository".equals(parser.getName())) {
495 pluginRepositories.add(parseRepository(parser, strict, source));
496 } else {
497 checkUnknownElement(parser, strict);
498 }
499 }
500 modelBase.pluginRepositories(pluginRepositories);
501 break;
502 }
503 case "reporting": {
504 modelBase.reporting(parseReporting(parser, strict, source ));
505 break;
506 }
507 default: {
508 checkUnknownElement(parser, strict);
509 break;
510 }
511 }
512 modelBase.location(childName, new InputLocation(line, column, source, locations));
513 }
514 return modelBase.build();
515 }
516
517 private PluginContainer parsePluginContainer(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
518 String tagName = parser.getName();
519 PluginContainer.Builder pluginContainer = PluginContainer.newBuilder(true);
520 pluginContainer.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
521 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
522 String name = parser.getAttributeName(i);
523 String value = parser.getAttributeValue(i);
524 if (name.indexOf(':') >= 0) {
525
526 } else {
527 checkUnknownAttribute(parser, name, tagName, strict);
528 }
529 }
530 Set<String> parsed = new HashSet<>();
531 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
532 String childName = unalias(parser.getName());
533 if (!parsed.add(childName)) {
534 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
535 }
536 int line = parser.getLineNumber();
537 int column = parser.getColumnNumber();
538 Map<Object, InputLocation> locations = null;
539 switch (childName) {
540 case "plugins": {
541 List<Plugin> plugins = new ArrayList<>();
542 while (parser.nextTag() == XmlPullParser.START_TAG) {
543 if ("plugin".equals(parser.getName())) {
544 plugins.add(parsePlugin(parser, strict, source));
545 } else {
546 checkUnknownElement(parser, strict);
547 }
548 }
549 pluginContainer.plugins(plugins);
550 break;
551 }
552 default: {
553 checkUnknownElement(parser, strict);
554 break;
555 }
556 }
557 pluginContainer.location(childName, new InputLocation(line, column, source, locations));
558 }
559 return pluginContainer.build();
560 }
561
562 private PluginConfiguration parsePluginConfiguration(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
563 String tagName = parser.getName();
564 PluginConfiguration.Builder pluginConfiguration = PluginConfiguration.newBuilder(true);
565 pluginConfiguration.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
566 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
567 String name = parser.getAttributeName(i);
568 String value = parser.getAttributeValue(i);
569 if (name.indexOf(':') >= 0) {
570
571 } else {
572 checkUnknownAttribute(parser, name, tagName, strict);
573 }
574 }
575 Set<String> parsed = new HashSet<>();
576 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
577 String childName = unalias(parser.getName());
578 if (!parsed.add(childName)) {
579 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
580 }
581 int line = parser.getLineNumber();
582 int column = parser.getColumnNumber();
583 Map<Object, InputLocation> locations = null;
584 switch (childName) {
585 case "pluginManagement": {
586 pluginConfiguration.pluginManagement(parsePluginManagement(parser, strict, source ));
587 break;
588 }
589 case "plugins": {
590 List<Plugin> plugins = new ArrayList<>();
591 while (parser.nextTag() == XmlPullParser.START_TAG) {
592 if ("plugin".equals(parser.getName())) {
593 plugins.add(parsePlugin(parser, strict, source));
594 } else {
595 checkUnknownElement(parser, strict);
596 }
597 }
598 pluginConfiguration.plugins(plugins);
599 break;
600 }
601 default: {
602 checkUnknownElement(parser, strict);
603 break;
604 }
605 }
606 pluginConfiguration.location(childName, new InputLocation(line, column, source, locations));
607 }
608 return pluginConfiguration.build();
609 }
610
611 private BuildBase parseBuildBase(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
612 String tagName = parser.getName();
613 BuildBase.Builder buildBase = BuildBase.newBuilder(true);
614 buildBase.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
615 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
616 String name = parser.getAttributeName(i);
617 String value = parser.getAttributeValue(i);
618 if (name.indexOf(':') >= 0) {
619
620 } else {
621 checkUnknownAttribute(parser, name, tagName, strict);
622 }
623 }
624 Set<String> parsed = new HashSet<>();
625 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
626 String childName = unalias(parser.getName());
627 if (!parsed.add(childName)) {
628 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
629 }
630 int line = parser.getLineNumber();
631 int column = parser.getColumnNumber();
632 Map<Object, InputLocation> locations = null;
633 switch (childName) {
634 case "defaultGoal": {
635 buildBase.defaultGoal(interpolatedTrimmed(parser.nextText(), "defaultGoal"));
636 break;
637 }
638 case "resources": {
639 List<Resource> resources = new ArrayList<>();
640 while (parser.nextTag() == XmlPullParser.START_TAG) {
641 if ("resource".equals(parser.getName())) {
642 resources.add(parseResource(parser, strict, source));
643 } else {
644 checkUnknownElement(parser, strict);
645 }
646 }
647 buildBase.resources(resources);
648 break;
649 }
650 case "testResources": {
651 List<Resource> testResources = new ArrayList<>();
652 while (parser.nextTag() == XmlPullParser.START_TAG) {
653 if ("testResource".equals(parser.getName())) {
654 testResources.add(parseResource(parser, strict, source));
655 } else {
656 checkUnknownElement(parser, strict);
657 }
658 }
659 buildBase.testResources(testResources);
660 break;
661 }
662 case "directory": {
663 buildBase.directory(interpolatedTrimmed(parser.nextText(), "directory"));
664 break;
665 }
666 case "finalName": {
667 buildBase.finalName(interpolatedTrimmed(parser.nextText(), "finalName"));
668 break;
669 }
670 case "filters": {
671 List<String> filters = new ArrayList<>();
672 locations = new HashMap<>();
673 while (parser.nextTag() == XmlPullParser.START_TAG) {
674 if ("filter".equals(parser.getName())) {
675 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
676 filters.add(interpolatedTrimmed(parser.nextText(), "filters"));
677 } else {
678 checkUnknownElement(parser, strict);
679 }
680 }
681 buildBase.filters(filters);
682 break;
683 }
684 case "pluginManagement": {
685 buildBase.pluginManagement(parsePluginManagement(parser, strict, source ));
686 break;
687 }
688 case "plugins": {
689 List<Plugin> plugins = new ArrayList<>();
690 while (parser.nextTag() == XmlPullParser.START_TAG) {
691 if ("plugin".equals(parser.getName())) {
692 plugins.add(parsePlugin(parser, strict, source));
693 } else {
694 checkUnknownElement(parser, strict);
695 }
696 }
697 buildBase.plugins(plugins);
698 break;
699 }
700 default: {
701 checkUnknownElement(parser, strict);
702 break;
703 }
704 }
705 buildBase.location(childName, new InputLocation(line, column, source, locations));
706 }
707 return buildBase.build();
708 }
709
710 private Build parseBuild(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
711 String tagName = parser.getName();
712 Build.Builder build = Build.newBuilder(true);
713 build.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
714 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
715 String name = parser.getAttributeName(i);
716 String value = parser.getAttributeValue(i);
717 if (name.indexOf(':') >= 0) {
718
719 } else {
720 checkUnknownAttribute(parser, name, tagName, strict);
721 }
722 }
723 Set<String> parsed = new HashSet<>();
724 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
725 String childName = unalias(parser.getName());
726 if (!parsed.add(childName)) {
727 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
728 }
729 int line = parser.getLineNumber();
730 int column = parser.getColumnNumber();
731 Map<Object, InputLocation> locations = null;
732 switch (childName) {
733 case "sourceDirectory": {
734 build.sourceDirectory(interpolatedTrimmed(parser.nextText(), "sourceDirectory"));
735 break;
736 }
737 case "scriptSourceDirectory": {
738 build.scriptSourceDirectory(interpolatedTrimmed(parser.nextText(), "scriptSourceDirectory"));
739 break;
740 }
741 case "testSourceDirectory": {
742 build.testSourceDirectory(interpolatedTrimmed(parser.nextText(), "testSourceDirectory"));
743 break;
744 }
745 case "outputDirectory": {
746 build.outputDirectory(interpolatedTrimmed(parser.nextText(), "outputDirectory"));
747 break;
748 }
749 case "testOutputDirectory": {
750 build.testOutputDirectory(interpolatedTrimmed(parser.nextText(), "testOutputDirectory"));
751 break;
752 }
753 case "extensions": {
754 List<Extension> extensions = new ArrayList<>();
755 while (parser.nextTag() == XmlPullParser.START_TAG) {
756 if ("extension".equals(parser.getName())) {
757 extensions.add(parseExtension(parser, strict, source));
758 } else {
759 checkUnknownElement(parser, strict);
760 }
761 }
762 build.extensions(extensions);
763 break;
764 }
765 case "defaultGoal": {
766 build.defaultGoal(interpolatedTrimmed(parser.nextText(), "defaultGoal"));
767 break;
768 }
769 case "resources": {
770 List<Resource> resources = new ArrayList<>();
771 while (parser.nextTag() == XmlPullParser.START_TAG) {
772 if ("resource".equals(parser.getName())) {
773 resources.add(parseResource(parser, strict, source));
774 } else {
775 checkUnknownElement(parser, strict);
776 }
777 }
778 build.resources(resources);
779 break;
780 }
781 case "testResources": {
782 List<Resource> testResources = new ArrayList<>();
783 while (parser.nextTag() == XmlPullParser.START_TAG) {
784 if ("testResource".equals(parser.getName())) {
785 testResources.add(parseResource(parser, strict, source));
786 } else {
787 checkUnknownElement(parser, strict);
788 }
789 }
790 build.testResources(testResources);
791 break;
792 }
793 case "directory": {
794 build.directory(interpolatedTrimmed(parser.nextText(), "directory"));
795 break;
796 }
797 case "finalName": {
798 build.finalName(interpolatedTrimmed(parser.nextText(), "finalName"));
799 break;
800 }
801 case "filters": {
802 List<String> filters = new ArrayList<>();
803 locations = new HashMap<>();
804 while (parser.nextTag() == XmlPullParser.START_TAG) {
805 if ("filter".equals(parser.getName())) {
806 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
807 filters.add(interpolatedTrimmed(parser.nextText(), "filters"));
808 } else {
809 checkUnknownElement(parser, strict);
810 }
811 }
812 build.filters(filters);
813 break;
814 }
815 case "pluginManagement": {
816 build.pluginManagement(parsePluginManagement(parser, strict, source ));
817 break;
818 }
819 case "plugins": {
820 List<Plugin> plugins = new ArrayList<>();
821 while (parser.nextTag() == XmlPullParser.START_TAG) {
822 if ("plugin".equals(parser.getName())) {
823 plugins.add(parsePlugin(parser, strict, source));
824 } else {
825 checkUnknownElement(parser, strict);
826 }
827 }
828 build.plugins(plugins);
829 break;
830 }
831 default: {
832 checkUnknownElement(parser, strict);
833 break;
834 }
835 }
836 build.location(childName, new InputLocation(line, column, source, locations));
837 }
838 return build.build();
839 }
840
841 private CiManagement parseCiManagement(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
842 String tagName = parser.getName();
843 CiManagement.Builder ciManagement = CiManagement.newBuilder(true);
844 ciManagement.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
845 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
846 String name = parser.getAttributeName(i);
847 String value = parser.getAttributeValue(i);
848 if (name.indexOf(':') >= 0) {
849
850 } else {
851 checkUnknownAttribute(parser, name, tagName, strict);
852 }
853 }
854 Set<String> parsed = new HashSet<>();
855 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
856 String childName = unalias(parser.getName());
857 if (!parsed.add(childName)) {
858 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
859 }
860 int line = parser.getLineNumber();
861 int column = parser.getColumnNumber();
862 Map<Object, InputLocation> locations = null;
863 switch (childName) {
864 case "system": {
865 ciManagement.system(interpolatedTrimmed(parser.nextText(), "system"));
866 break;
867 }
868 case "url": {
869 ciManagement.url(interpolatedTrimmed(parser.nextText(), "url"));
870 break;
871 }
872 case "notifiers": {
873 List<Notifier> notifiers = new ArrayList<>();
874 while (parser.nextTag() == XmlPullParser.START_TAG) {
875 if ("notifier".equals(parser.getName())) {
876 notifiers.add(parseNotifier(parser, strict, source));
877 } else {
878 checkUnknownElement(parser, strict);
879 }
880 }
881 ciManagement.notifiers(notifiers);
882 break;
883 }
884 default: {
885 checkUnknownElement(parser, strict);
886 break;
887 }
888 }
889 ciManagement.location(childName, new InputLocation(line, column, source, locations));
890 }
891 return ciManagement.build();
892 }
893
894 private Notifier parseNotifier(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
895 String tagName = parser.getName();
896 Notifier.Builder notifier = Notifier.newBuilder(true);
897 notifier.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
898 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
899 String name = parser.getAttributeName(i);
900 String value = parser.getAttributeValue(i);
901 if (name.indexOf(':') >= 0) {
902
903 } else {
904 checkUnknownAttribute(parser, name, tagName, strict);
905 }
906 }
907 Set<String> parsed = new HashSet<>();
908 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
909 String childName = unalias(parser.getName());
910 if (!parsed.add(childName)) {
911 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
912 }
913 int line = parser.getLineNumber();
914 int column = parser.getColumnNumber();
915 Map<Object, InputLocation> locations = null;
916 switch (childName) {
917 case "type": {
918 notifier.type(interpolatedTrimmed(parser.nextText(), "type"));
919 break;
920 }
921 case "sendOnError": {
922 notifier.sendOnError(getBooleanValue(interpolatedTrimmed(parser.nextText(), "sendOnError"), "sendOnError", parser, true));
923 break;
924 }
925 case "sendOnFailure": {
926 notifier.sendOnFailure(getBooleanValue(interpolatedTrimmed(parser.nextText(), "sendOnFailure"), "sendOnFailure", parser, true));
927 break;
928 }
929 case "sendOnSuccess": {
930 notifier.sendOnSuccess(getBooleanValue(interpolatedTrimmed(parser.nextText(), "sendOnSuccess"), "sendOnSuccess", parser, true));
931 break;
932 }
933 case "sendOnWarning": {
934 notifier.sendOnWarning(getBooleanValue(interpolatedTrimmed(parser.nextText(), "sendOnWarning"), "sendOnWarning", parser, true));
935 break;
936 }
937 case "address": {
938 notifier.address(interpolatedTrimmed(parser.nextText(), "address"));
939 break;
940 }
941 case "configuration": {
942 Map<String, String> configuration = new LinkedHashMap<>();
943 locations = new HashMap<>();
944 while (parser.nextTag() == XmlPullParser.START_TAG) {
945 String key = parser.getName();
946 String value = parser.nextText().trim();
947 locations.put(key, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
948 configuration.put(key, value);
949 }
950 notifier.configuration(configuration);
951 break;
952 }
953 default: {
954 checkUnknownElement(parser, strict);
955 break;
956 }
957 }
958 notifier.location(childName, new InputLocation(line, column, source, locations));
959 }
960 return notifier.build();
961 }
962
963 private Contributor parseContributor(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
964 String tagName = parser.getName();
965 Contributor.Builder contributor = Contributor.newBuilder(true);
966 contributor.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
967 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
968 String name = parser.getAttributeName(i);
969 String value = parser.getAttributeValue(i);
970 if (name.indexOf(':') >= 0) {
971
972 } else {
973 checkUnknownAttribute(parser, name, tagName, strict);
974 }
975 }
976 Set<String> parsed = new HashSet<>();
977 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
978 String childName = unalias(parser.getName());
979 if (!parsed.add(childName)) {
980 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
981 }
982 int line = parser.getLineNumber();
983 int column = parser.getColumnNumber();
984 Map<Object, InputLocation> locations = null;
985 switch (childName) {
986 case "name": {
987 contributor.name(interpolatedTrimmed(parser.nextText(), "name"));
988 break;
989 }
990 case "email": {
991 contributor.email(interpolatedTrimmed(parser.nextText(), "email"));
992 break;
993 }
994 case "url": {
995 contributor.url(interpolatedTrimmed(parser.nextText(), "url"));
996 break;
997 }
998 case "organization": {
999 contributor.organization(interpolatedTrimmed(parser.nextText(), "organization"));
1000 break;
1001 }
1002 case "organizationUrl": {
1003 contributor.organizationUrl(interpolatedTrimmed(parser.nextText(), "organizationUrl"));
1004 break;
1005 }
1006 case "roles": {
1007 List<String> roles = new ArrayList<>();
1008 locations = new HashMap<>();
1009 while (parser.nextTag() == XmlPullParser.START_TAG) {
1010 if ("role".equals(parser.getName())) {
1011 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1012 roles.add(interpolatedTrimmed(parser.nextText(), "roles"));
1013 } else {
1014 checkUnknownElement(parser, strict);
1015 }
1016 }
1017 contributor.roles(roles);
1018 break;
1019 }
1020 case "timezone": {
1021 contributor.timezone(interpolatedTrimmed(parser.nextText(), "timezone"));
1022 break;
1023 }
1024 case "properties": {
1025 Map<String, String> properties = new LinkedHashMap<>();
1026 locations = new HashMap<>();
1027 while (parser.nextTag() == XmlPullParser.START_TAG) {
1028 String key = parser.getName();
1029 String value = parser.nextText().trim();
1030 locations.put(key, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1031 properties.put(key, value);
1032 }
1033 contributor.properties(properties);
1034 break;
1035 }
1036 default: {
1037 checkUnknownElement(parser, strict);
1038 break;
1039 }
1040 }
1041 contributor.location(childName, new InputLocation(line, column, source, locations));
1042 }
1043 return contributor.build();
1044 }
1045
1046 private Dependency parseDependency(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1047 String tagName = parser.getName();
1048 Dependency.Builder dependency = Dependency.newBuilder(true);
1049 dependency.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1050 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1051 String name = parser.getAttributeName(i);
1052 String value = parser.getAttributeValue(i);
1053 if (name.indexOf(':') >= 0) {
1054
1055 } else {
1056 checkUnknownAttribute(parser, name, tagName, strict);
1057 }
1058 }
1059 Set<String> parsed = new HashSet<>();
1060 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1061 String childName = unalias(parser.getName());
1062 if (!parsed.add(childName)) {
1063 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1064 }
1065 int line = parser.getLineNumber();
1066 int column = parser.getColumnNumber();
1067 Map<Object, InputLocation> locations = null;
1068 switch (childName) {
1069 case "groupId": {
1070 dependency.groupId(interpolatedTrimmed(parser.nextText(), "groupId"));
1071 break;
1072 }
1073 case "artifactId": {
1074 dependency.artifactId(interpolatedTrimmed(parser.nextText(), "artifactId"));
1075 break;
1076 }
1077 case "version": {
1078 dependency.version(interpolatedTrimmed(parser.nextText(), "version"));
1079 break;
1080 }
1081 case "type": {
1082 dependency.type(interpolatedTrimmed(parser.nextText(), "type"));
1083 break;
1084 }
1085 case "classifier": {
1086 dependency.classifier(interpolatedTrimmed(parser.nextText(), "classifier"));
1087 break;
1088 }
1089 case "scope": {
1090 dependency.scope(interpolatedTrimmed(parser.nextText(), "scope"));
1091 break;
1092 }
1093 case "systemPath": {
1094 dependency.systemPath(interpolatedTrimmed(parser.nextText(), "systemPath"));
1095 break;
1096 }
1097 case "exclusions": {
1098 List<Exclusion> exclusions = new ArrayList<>();
1099 while (parser.nextTag() == XmlPullParser.START_TAG) {
1100 if ("exclusion".equals(parser.getName())) {
1101 exclusions.add(parseExclusion(parser, strict, source));
1102 } else {
1103 checkUnknownElement(parser, strict);
1104 }
1105 }
1106 dependency.exclusions(exclusions);
1107 break;
1108 }
1109 case "optional": {
1110 dependency.optional(interpolatedTrimmed(parser.nextText(), "optional"));
1111 break;
1112 }
1113 default: {
1114 checkUnknownElement(parser, strict);
1115 break;
1116 }
1117 }
1118 dependency.location(childName, new InputLocation(line, column, source, locations));
1119 }
1120 return dependency.build();
1121 }
1122
1123 private Developer parseDeveloper(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1124 String tagName = parser.getName();
1125 Developer.Builder developer = Developer.newBuilder(true);
1126 developer.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1127 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1128 String name = parser.getAttributeName(i);
1129 String value = parser.getAttributeValue(i);
1130 if (name.indexOf(':') >= 0) {
1131
1132 } else {
1133 checkUnknownAttribute(parser, name, tagName, strict);
1134 }
1135 }
1136 Set<String> parsed = new HashSet<>();
1137 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1138 String childName = unalias(parser.getName());
1139 if (!parsed.add(childName)) {
1140 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1141 }
1142 int line = parser.getLineNumber();
1143 int column = parser.getColumnNumber();
1144 Map<Object, InputLocation> locations = null;
1145 switch (childName) {
1146 case "id": {
1147 developer.id(interpolatedTrimmed(parser.nextText(), "id"));
1148 break;
1149 }
1150 case "name": {
1151 developer.name(interpolatedTrimmed(parser.nextText(), "name"));
1152 break;
1153 }
1154 case "email": {
1155 developer.email(interpolatedTrimmed(parser.nextText(), "email"));
1156 break;
1157 }
1158 case "url": {
1159 developer.url(interpolatedTrimmed(parser.nextText(), "url"));
1160 break;
1161 }
1162 case "organization": {
1163 developer.organization(interpolatedTrimmed(parser.nextText(), "organization"));
1164 break;
1165 }
1166 case "organizationUrl": {
1167 developer.organizationUrl(interpolatedTrimmed(parser.nextText(), "organizationUrl"));
1168 break;
1169 }
1170 case "roles": {
1171 List<String> roles = new ArrayList<>();
1172 locations = new HashMap<>();
1173 while (parser.nextTag() == XmlPullParser.START_TAG) {
1174 if ("role".equals(parser.getName())) {
1175 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1176 roles.add(interpolatedTrimmed(parser.nextText(), "roles"));
1177 } else {
1178 checkUnknownElement(parser, strict);
1179 }
1180 }
1181 developer.roles(roles);
1182 break;
1183 }
1184 case "timezone": {
1185 developer.timezone(interpolatedTrimmed(parser.nextText(), "timezone"));
1186 break;
1187 }
1188 case "properties": {
1189 Map<String, String> properties = new LinkedHashMap<>();
1190 locations = new HashMap<>();
1191 while (parser.nextTag() == XmlPullParser.START_TAG) {
1192 String key = parser.getName();
1193 String value = parser.nextText().trim();
1194 locations.put(key, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1195 properties.put(key, value);
1196 }
1197 developer.properties(properties);
1198 break;
1199 }
1200 default: {
1201 checkUnknownElement(parser, strict);
1202 break;
1203 }
1204 }
1205 developer.location(childName, new InputLocation(line, column, source, locations));
1206 }
1207 return developer.build();
1208 }
1209
1210 private Exclusion parseExclusion(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1211 String tagName = parser.getName();
1212 Exclusion.Builder exclusion = Exclusion.newBuilder(true);
1213 exclusion.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1214 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1215 String name = parser.getAttributeName(i);
1216 String value = parser.getAttributeValue(i);
1217 if (name.indexOf(':') >= 0) {
1218
1219 } else {
1220 checkUnknownAttribute(parser, name, tagName, strict);
1221 }
1222 }
1223 Set<String> parsed = new HashSet<>();
1224 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1225 String childName = unalias(parser.getName());
1226 if (!parsed.add(childName)) {
1227 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1228 }
1229 int line = parser.getLineNumber();
1230 int column = parser.getColumnNumber();
1231 Map<Object, InputLocation> locations = null;
1232 switch (childName) {
1233 case "groupId": {
1234 exclusion.groupId(interpolatedTrimmed(parser.nextText(), "groupId"));
1235 break;
1236 }
1237 case "artifactId": {
1238 exclusion.artifactId(interpolatedTrimmed(parser.nextText(), "artifactId"));
1239 break;
1240 }
1241 default: {
1242 checkUnknownElement(parser, strict);
1243 break;
1244 }
1245 }
1246 exclusion.location(childName, new InputLocation(line, column, source, locations));
1247 }
1248 return exclusion.build();
1249 }
1250
1251 private IssueManagement parseIssueManagement(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1252 String tagName = parser.getName();
1253 IssueManagement.Builder issueManagement = IssueManagement.newBuilder(true);
1254 issueManagement.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1255 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1256 String name = parser.getAttributeName(i);
1257 String value = parser.getAttributeValue(i);
1258 if (name.indexOf(':') >= 0) {
1259
1260 } else {
1261 checkUnknownAttribute(parser, name, tagName, strict);
1262 }
1263 }
1264 Set<String> parsed = new HashSet<>();
1265 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1266 String childName = unalias(parser.getName());
1267 if (!parsed.add(childName)) {
1268 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1269 }
1270 int line = parser.getLineNumber();
1271 int column = parser.getColumnNumber();
1272 Map<Object, InputLocation> locations = null;
1273 switch (childName) {
1274 case "system": {
1275 issueManagement.system(interpolatedTrimmed(parser.nextText(), "system"));
1276 break;
1277 }
1278 case "url": {
1279 issueManagement.url(interpolatedTrimmed(parser.nextText(), "url"));
1280 break;
1281 }
1282 default: {
1283 checkUnknownElement(parser, strict);
1284 break;
1285 }
1286 }
1287 issueManagement.location(childName, new InputLocation(line, column, source, locations));
1288 }
1289 return issueManagement.build();
1290 }
1291
1292 private DistributionManagement parseDistributionManagement(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1293 String tagName = parser.getName();
1294 DistributionManagement.Builder distributionManagement = DistributionManagement.newBuilder(true);
1295 distributionManagement.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1296 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1297 String name = parser.getAttributeName(i);
1298 String value = parser.getAttributeValue(i);
1299 if (name.indexOf(':') >= 0) {
1300
1301 } else {
1302 checkUnknownAttribute(parser, name, tagName, strict);
1303 }
1304 }
1305 Set<String> parsed = new HashSet<>();
1306 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1307 String childName = unalias(parser.getName());
1308 if (!parsed.add(childName)) {
1309 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1310 }
1311 int line = parser.getLineNumber();
1312 int column = parser.getColumnNumber();
1313 Map<Object, InputLocation> locations = null;
1314 switch (childName) {
1315 case "repository": {
1316 distributionManagement.repository(parseDeploymentRepository(parser, strict, source ));
1317 break;
1318 }
1319 case "snapshotRepository": {
1320 distributionManagement.snapshotRepository(parseDeploymentRepository(parser, strict, source ));
1321 break;
1322 }
1323 case "site": {
1324 distributionManagement.site(parseSite(parser, strict, source ));
1325 break;
1326 }
1327 case "downloadUrl": {
1328 distributionManagement.downloadUrl(interpolatedTrimmed(parser.nextText(), "downloadUrl"));
1329 break;
1330 }
1331 case "relocation": {
1332 distributionManagement.relocation(parseRelocation(parser, strict, source ));
1333 break;
1334 }
1335 case "status": {
1336 distributionManagement.status(interpolatedTrimmed(parser.nextText(), "status"));
1337 break;
1338 }
1339 default: {
1340 checkUnknownElement(parser, strict);
1341 break;
1342 }
1343 }
1344 distributionManagement.location(childName, new InputLocation(line, column, source, locations));
1345 }
1346 return distributionManagement.build();
1347 }
1348
1349 private License parseLicense(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1350 String tagName = parser.getName();
1351 License.Builder license = License.newBuilder(true);
1352 license.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1353 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1354 String name = parser.getAttributeName(i);
1355 String value = parser.getAttributeValue(i);
1356 if (name.indexOf(':') >= 0) {
1357
1358 } else {
1359 checkUnknownAttribute(parser, name, tagName, strict);
1360 }
1361 }
1362 Set<String> parsed = new HashSet<>();
1363 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1364 String childName = unalias(parser.getName());
1365 if (!parsed.add(childName)) {
1366 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1367 }
1368 int line = parser.getLineNumber();
1369 int column = parser.getColumnNumber();
1370 Map<Object, InputLocation> locations = null;
1371 switch (childName) {
1372 case "name": {
1373 license.name(interpolatedTrimmed(parser.nextText(), "name"));
1374 break;
1375 }
1376 case "url": {
1377 license.url(interpolatedTrimmed(parser.nextText(), "url"));
1378 break;
1379 }
1380 case "distribution": {
1381 license.distribution(interpolatedTrimmed(parser.nextText(), "distribution"));
1382 break;
1383 }
1384 case "comments": {
1385 license.comments(interpolatedTrimmed(parser.nextText(), "comments"));
1386 break;
1387 }
1388 default: {
1389 checkUnknownElement(parser, strict);
1390 break;
1391 }
1392 }
1393 license.location(childName, new InputLocation(line, column, source, locations));
1394 }
1395 return license.build();
1396 }
1397
1398 private MailingList parseMailingList(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1399 String tagName = parser.getName();
1400 MailingList.Builder mailingList = MailingList.newBuilder(true);
1401 mailingList.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1402 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1403 String name = parser.getAttributeName(i);
1404 String value = parser.getAttributeValue(i);
1405 if (name.indexOf(':') >= 0) {
1406
1407 } else {
1408 checkUnknownAttribute(parser, name, tagName, strict);
1409 }
1410 }
1411 Set<String> parsed = new HashSet<>();
1412 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1413 String childName = unalias(parser.getName());
1414 if (!parsed.add(childName)) {
1415 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1416 }
1417 int line = parser.getLineNumber();
1418 int column = parser.getColumnNumber();
1419 Map<Object, InputLocation> locations = null;
1420 switch (childName) {
1421 case "name": {
1422 mailingList.name(interpolatedTrimmed(parser.nextText(), "name"));
1423 break;
1424 }
1425 case "subscribe": {
1426 mailingList.subscribe(interpolatedTrimmed(parser.nextText(), "subscribe"));
1427 break;
1428 }
1429 case "unsubscribe": {
1430 mailingList.unsubscribe(interpolatedTrimmed(parser.nextText(), "unsubscribe"));
1431 break;
1432 }
1433 case "post": {
1434 mailingList.post(interpolatedTrimmed(parser.nextText(), "post"));
1435 break;
1436 }
1437 case "archive": {
1438 mailingList.archive(interpolatedTrimmed(parser.nextText(), "archive"));
1439 break;
1440 }
1441 case "otherArchives": {
1442 List<String> otherArchives = new ArrayList<>();
1443 locations = new HashMap<>();
1444 while (parser.nextTag() == XmlPullParser.START_TAG) {
1445 if ("otherArchive".equals(parser.getName())) {
1446 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1447 otherArchives.add(interpolatedTrimmed(parser.nextText(), "otherArchives"));
1448 } else {
1449 checkUnknownElement(parser, strict);
1450 }
1451 }
1452 mailingList.otherArchives(otherArchives);
1453 break;
1454 }
1455 default: {
1456 checkUnknownElement(parser, strict);
1457 break;
1458 }
1459 }
1460 mailingList.location(childName, new InputLocation(line, column, source, locations));
1461 }
1462 return mailingList.build();
1463 }
1464
1465 private Organization parseOrganization(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1466 String tagName = parser.getName();
1467 Organization.Builder organization = Organization.newBuilder(true);
1468 organization.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1469 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1470 String name = parser.getAttributeName(i);
1471 String value = parser.getAttributeValue(i);
1472 if (name.indexOf(':') >= 0) {
1473
1474 } else {
1475 checkUnknownAttribute(parser, name, tagName, strict);
1476 }
1477 }
1478 Set<String> parsed = new HashSet<>();
1479 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1480 String childName = unalias(parser.getName());
1481 if (!parsed.add(childName)) {
1482 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1483 }
1484 int line = parser.getLineNumber();
1485 int column = parser.getColumnNumber();
1486 Map<Object, InputLocation> locations = null;
1487 switch (childName) {
1488 case "name": {
1489 organization.name(interpolatedTrimmed(parser.nextText(), "name"));
1490 break;
1491 }
1492 case "url": {
1493 organization.url(interpolatedTrimmed(parser.nextText(), "url"));
1494 break;
1495 }
1496 default: {
1497 checkUnknownElement(parser, strict);
1498 break;
1499 }
1500 }
1501 organization.location(childName, new InputLocation(line, column, source, locations));
1502 }
1503 return organization.build();
1504 }
1505
1506 private PatternSet parsePatternSet(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1507 String tagName = parser.getName();
1508 PatternSet.Builder patternSet = PatternSet.newBuilder(true);
1509 patternSet.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1510 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1511 String name = parser.getAttributeName(i);
1512 String value = parser.getAttributeValue(i);
1513 if (name.indexOf(':') >= 0) {
1514
1515 } else {
1516 checkUnknownAttribute(parser, name, tagName, strict);
1517 }
1518 }
1519 Set<String> parsed = new HashSet<>();
1520 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1521 String childName = unalias(parser.getName());
1522 if (!parsed.add(childName)) {
1523 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1524 }
1525 int line = parser.getLineNumber();
1526 int column = parser.getColumnNumber();
1527 Map<Object, InputLocation> locations = null;
1528 switch (childName) {
1529 case "includes": {
1530 List<String> includes = new ArrayList<>();
1531 locations = new HashMap<>();
1532 while (parser.nextTag() == XmlPullParser.START_TAG) {
1533 if ("include".equals(parser.getName())) {
1534 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1535 includes.add(interpolatedTrimmed(parser.nextText(), "includes"));
1536 } else {
1537 checkUnknownElement(parser, strict);
1538 }
1539 }
1540 patternSet.includes(includes);
1541 break;
1542 }
1543 case "excludes": {
1544 List<String> excludes = new ArrayList<>();
1545 locations = new HashMap<>();
1546 while (parser.nextTag() == XmlPullParser.START_TAG) {
1547 if ("exclude".equals(parser.getName())) {
1548 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1549 excludes.add(interpolatedTrimmed(parser.nextText(), "excludes"));
1550 } else {
1551 checkUnknownElement(parser, strict);
1552 }
1553 }
1554 patternSet.excludes(excludes);
1555 break;
1556 }
1557 default: {
1558 checkUnknownElement(parser, strict);
1559 break;
1560 }
1561 }
1562 patternSet.location(childName, new InputLocation(line, column, source, locations));
1563 }
1564 return patternSet.build();
1565 }
1566
1567 private Parent parseParent(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1568 String tagName = parser.getName();
1569 Parent.Builder parent = Parent.newBuilder(true);
1570 parent.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1571 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1572 String name = parser.getAttributeName(i);
1573 String value = parser.getAttributeValue(i);
1574 if (name.indexOf(':') >= 0) {
1575
1576 } else {
1577 checkUnknownAttribute(parser, name, tagName, strict);
1578 }
1579 }
1580 Set<String> parsed = new HashSet<>();
1581 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1582 String childName = unalias(parser.getName());
1583 if (!parsed.add(childName)) {
1584 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1585 }
1586 int line = parser.getLineNumber();
1587 int column = parser.getColumnNumber();
1588 Map<Object, InputLocation> locations = null;
1589 switch (childName) {
1590 case "groupId": {
1591 parent.groupId(interpolatedTrimmed(parser.nextText(), "groupId"));
1592 break;
1593 }
1594 case "artifactId": {
1595 parent.artifactId(interpolatedTrimmed(parser.nextText(), "artifactId"));
1596 break;
1597 }
1598 case "version": {
1599 parent.version(interpolatedTrimmed(parser.nextText(), "version"));
1600 break;
1601 }
1602 case "relativePath": {
1603 parent.relativePath(interpolatedTrimmed(parser.nextText(), "relativePath"));
1604 break;
1605 }
1606 default: {
1607 checkUnknownElement(parser, strict);
1608 break;
1609 }
1610 }
1611 parent.location(childName, new InputLocation(line, column, source, locations));
1612 }
1613 return parent.build();
1614 }
1615
1616 private Scm parseScm(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1617 String tagName = parser.getName();
1618 Scm.Builder scm = Scm.newBuilder(true);
1619 scm.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1620 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1621 String name = parser.getAttributeName(i);
1622 String value = parser.getAttributeValue(i);
1623 if (name.indexOf(':') >= 0) {
1624
1625 } else if ("child.scm.connection.inherit.append.path".equals(name)) {
1626 scm.location(name, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1627 scm.childScmConnectionInheritAppendPath(interpolatedTrimmed(value, "child.scm.connection.inherit.append.path"));
1628 } else if ("child.scm.developerConnection.inherit.append.path".equals(name)) {
1629 scm.location(name, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1630 scm.childScmDeveloperConnectionInheritAppendPath(interpolatedTrimmed(value, "child.scm.developerConnection.inherit.append.path"));
1631 } else if ("child.scm.url.inherit.append.path".equals(name)) {
1632 scm.location(name, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1633 scm.childScmUrlInheritAppendPath(interpolatedTrimmed(value, "child.scm.url.inherit.append.path"));
1634 } else {
1635 checkUnknownAttribute(parser, name, tagName, strict);
1636 }
1637 }
1638 Set<String> parsed = new HashSet<>();
1639 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1640 String childName = unalias(parser.getName());
1641 if (!parsed.add(childName)) {
1642 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1643 }
1644 int line = parser.getLineNumber();
1645 int column = parser.getColumnNumber();
1646 Map<Object, InputLocation> locations = null;
1647 switch (childName) {
1648 case "connection": {
1649 scm.connection(interpolatedTrimmed(parser.nextText(), "connection"));
1650 break;
1651 }
1652 case "developerConnection": {
1653 scm.developerConnection(interpolatedTrimmed(parser.nextText(), "developerConnection"));
1654 break;
1655 }
1656 case "tag": {
1657 scm.tag(interpolatedTrimmed(parser.nextText(), "tag"));
1658 break;
1659 }
1660 case "url": {
1661 scm.url(interpolatedTrimmed(parser.nextText(), "url"));
1662 break;
1663 }
1664 default: {
1665 checkUnknownElement(parser, strict);
1666 break;
1667 }
1668 }
1669 scm.location(childName, new InputLocation(line, column, source, locations));
1670 }
1671 return scm.build();
1672 }
1673
1674 private FileSet parseFileSet(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1675 String tagName = parser.getName();
1676 FileSet.Builder fileSet = FileSet.newBuilder(true);
1677 fileSet.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1678 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1679 String name = parser.getAttributeName(i);
1680 String value = parser.getAttributeValue(i);
1681 if (name.indexOf(':') >= 0) {
1682
1683 } else {
1684 checkUnknownAttribute(parser, name, tagName, strict);
1685 }
1686 }
1687 Set<String> parsed = new HashSet<>();
1688 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1689 String childName = unalias(parser.getName());
1690 if (!parsed.add(childName)) {
1691 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1692 }
1693 int line = parser.getLineNumber();
1694 int column = parser.getColumnNumber();
1695 Map<Object, InputLocation> locations = null;
1696 switch (childName) {
1697 case "directory": {
1698 fileSet.directory(interpolatedTrimmed(parser.nextText(), "directory"));
1699 break;
1700 }
1701 case "includes": {
1702 List<String> includes = new ArrayList<>();
1703 locations = new HashMap<>();
1704 while (parser.nextTag() == XmlPullParser.START_TAG) {
1705 if ("include".equals(parser.getName())) {
1706 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1707 includes.add(interpolatedTrimmed(parser.nextText(), "includes"));
1708 } else {
1709 checkUnknownElement(parser, strict);
1710 }
1711 }
1712 fileSet.includes(includes);
1713 break;
1714 }
1715 case "excludes": {
1716 List<String> excludes = new ArrayList<>();
1717 locations = new HashMap<>();
1718 while (parser.nextTag() == XmlPullParser.START_TAG) {
1719 if ("exclude".equals(parser.getName())) {
1720 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1721 excludes.add(interpolatedTrimmed(parser.nextText(), "excludes"));
1722 } else {
1723 checkUnknownElement(parser, strict);
1724 }
1725 }
1726 fileSet.excludes(excludes);
1727 break;
1728 }
1729 default: {
1730 checkUnknownElement(parser, strict);
1731 break;
1732 }
1733 }
1734 fileSet.location(childName, new InputLocation(line, column, source, locations));
1735 }
1736 return fileSet.build();
1737 }
1738
1739 private Resource parseResource(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1740 String tagName = parser.getName();
1741 Resource.Builder resource = Resource.newBuilder(true);
1742 resource.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1743 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1744 String name = parser.getAttributeName(i);
1745 String value = parser.getAttributeValue(i);
1746 if (name.indexOf(':') >= 0) {
1747
1748 } else {
1749 checkUnknownAttribute(parser, name, tagName, strict);
1750 }
1751 }
1752 Set<String> parsed = new HashSet<>();
1753 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1754 String childName = unalias(parser.getName());
1755 if (!parsed.add(childName)) {
1756 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1757 }
1758 int line = parser.getLineNumber();
1759 int column = parser.getColumnNumber();
1760 Map<Object, InputLocation> locations = null;
1761 switch (childName) {
1762 case "targetPath": {
1763 resource.targetPath(interpolatedTrimmed(parser.nextText(), "targetPath"));
1764 break;
1765 }
1766 case "filtering": {
1767 resource.filtering(interpolatedTrimmed(parser.nextText(), "filtering"));
1768 break;
1769 }
1770 case "directory": {
1771 resource.directory(interpolatedTrimmed(parser.nextText(), "directory"));
1772 break;
1773 }
1774 case "includes": {
1775 List<String> includes = new ArrayList<>();
1776 locations = new HashMap<>();
1777 while (parser.nextTag() == XmlPullParser.START_TAG) {
1778 if ("include".equals(parser.getName())) {
1779 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1780 includes.add(interpolatedTrimmed(parser.nextText(), "includes"));
1781 } else {
1782 checkUnknownElement(parser, strict);
1783 }
1784 }
1785 resource.includes(includes);
1786 break;
1787 }
1788 case "excludes": {
1789 List<String> excludes = new ArrayList<>();
1790 locations = new HashMap<>();
1791 while (parser.nextTag() == XmlPullParser.START_TAG) {
1792 if ("exclude".equals(parser.getName())) {
1793 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1794 excludes.add(interpolatedTrimmed(parser.nextText(), "excludes"));
1795 } else {
1796 checkUnknownElement(parser, strict);
1797 }
1798 }
1799 resource.excludes(excludes);
1800 break;
1801 }
1802 default: {
1803 checkUnknownElement(parser, strict);
1804 break;
1805 }
1806 }
1807 resource.location(childName, new InputLocation(line, column, source, locations));
1808 }
1809 return resource.build();
1810 }
1811
1812 private RepositoryBase parseRepositoryBase(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1813 String tagName = parser.getName();
1814 RepositoryBase.Builder repositoryBase = RepositoryBase.newBuilder(true);
1815 repositoryBase.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1816 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1817 String name = parser.getAttributeName(i);
1818 String value = parser.getAttributeValue(i);
1819 if (name.indexOf(':') >= 0) {
1820
1821 } else {
1822 checkUnknownAttribute(parser, name, tagName, strict);
1823 }
1824 }
1825 Set<String> parsed = new HashSet<>();
1826 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1827 String childName = unalias(parser.getName());
1828 if (!parsed.add(childName)) {
1829 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1830 }
1831 int line = parser.getLineNumber();
1832 int column = parser.getColumnNumber();
1833 Map<Object, InputLocation> locations = null;
1834 switch (childName) {
1835 case "id": {
1836 repositoryBase.id(interpolatedTrimmed(parser.nextText(), "id"));
1837 break;
1838 }
1839 case "name": {
1840 repositoryBase.name(interpolatedTrimmed(parser.nextText(), "name"));
1841 break;
1842 }
1843 case "url": {
1844 repositoryBase.url(interpolatedTrimmed(parser.nextText(), "url"));
1845 break;
1846 }
1847 case "layout": {
1848 repositoryBase.layout(interpolatedTrimmed(parser.nextText(), "layout"));
1849 break;
1850 }
1851 default: {
1852 checkUnknownElement(parser, strict);
1853 break;
1854 }
1855 }
1856 repositoryBase.location(childName, new InputLocation(line, column, source, locations));
1857 }
1858 return repositoryBase.build();
1859 }
1860
1861 private Repository parseRepository(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1862 String tagName = parser.getName();
1863 Repository.Builder repository = Repository.newBuilder(true);
1864 repository.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1865 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1866 String name = parser.getAttributeName(i);
1867 String value = parser.getAttributeValue(i);
1868 if (name.indexOf(':') >= 0) {
1869
1870 } else {
1871 checkUnknownAttribute(parser, name, tagName, strict);
1872 }
1873 }
1874 Set<String> parsed = new HashSet<>();
1875 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1876 String childName = unalias(parser.getName());
1877 if (!parsed.add(childName)) {
1878 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1879 }
1880 int line = parser.getLineNumber();
1881 int column = parser.getColumnNumber();
1882 Map<Object, InputLocation> locations = null;
1883 switch (childName) {
1884 case "releases": {
1885 repository.releases(parseRepositoryPolicy(parser, strict, source ));
1886 break;
1887 }
1888 case "snapshots": {
1889 repository.snapshots(parseRepositoryPolicy(parser, strict, source ));
1890 break;
1891 }
1892 case "id": {
1893 repository.id(interpolatedTrimmed(parser.nextText(), "id"));
1894 break;
1895 }
1896 case "name": {
1897 repository.name(interpolatedTrimmed(parser.nextText(), "name"));
1898 break;
1899 }
1900 case "url": {
1901 repository.url(interpolatedTrimmed(parser.nextText(), "url"));
1902 break;
1903 }
1904 case "layout": {
1905 repository.layout(interpolatedTrimmed(parser.nextText(), "layout"));
1906 break;
1907 }
1908 default: {
1909 checkUnknownElement(parser, strict);
1910 break;
1911 }
1912 }
1913 repository.location(childName, new InputLocation(line, column, source, locations));
1914 }
1915 return repository.build();
1916 }
1917
1918 private DeploymentRepository parseDeploymentRepository(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1919 String tagName = parser.getName();
1920 DeploymentRepository.Builder deploymentRepository = DeploymentRepository.newBuilder(true);
1921 deploymentRepository.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1922 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1923 String name = parser.getAttributeName(i);
1924 String value = parser.getAttributeValue(i);
1925 if (name.indexOf(':') >= 0) {
1926
1927 } else {
1928 checkUnknownAttribute(parser, name, tagName, strict);
1929 }
1930 }
1931 Set<String> parsed = new HashSet<>();
1932 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1933 String childName = unalias(parser.getName());
1934 if (!parsed.add(childName)) {
1935 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1936 }
1937 int line = parser.getLineNumber();
1938 int column = parser.getColumnNumber();
1939 Map<Object, InputLocation> locations = null;
1940 switch (childName) {
1941 case "uniqueVersion": {
1942 deploymentRepository.uniqueVersion(getBooleanValue(interpolatedTrimmed(parser.nextText(), "uniqueVersion"), "uniqueVersion", parser, true));
1943 break;
1944 }
1945 case "releases": {
1946 deploymentRepository.releases(parseRepositoryPolicy(parser, strict, source ));
1947 break;
1948 }
1949 case "snapshots": {
1950 deploymentRepository.snapshots(parseRepositoryPolicy(parser, strict, source ));
1951 break;
1952 }
1953 case "id": {
1954 deploymentRepository.id(interpolatedTrimmed(parser.nextText(), "id"));
1955 break;
1956 }
1957 case "name": {
1958 deploymentRepository.name(interpolatedTrimmed(parser.nextText(), "name"));
1959 break;
1960 }
1961 case "url": {
1962 deploymentRepository.url(interpolatedTrimmed(parser.nextText(), "url"));
1963 break;
1964 }
1965 case "layout": {
1966 deploymentRepository.layout(interpolatedTrimmed(parser.nextText(), "layout"));
1967 break;
1968 }
1969 default: {
1970 checkUnknownElement(parser, strict);
1971 break;
1972 }
1973 }
1974 deploymentRepository.location(childName, new InputLocation(line, column, source, locations));
1975 }
1976 return deploymentRepository.build();
1977 }
1978
1979 private RepositoryPolicy parseRepositoryPolicy(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
1980 String tagName = parser.getName();
1981 RepositoryPolicy.Builder repositoryPolicy = RepositoryPolicy.newBuilder(true);
1982 repositoryPolicy.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
1983 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1984 String name = parser.getAttributeName(i);
1985 String value = parser.getAttributeValue(i);
1986 if (name.indexOf(':') >= 0) {
1987
1988 } else {
1989 checkUnknownAttribute(parser, name, tagName, strict);
1990 }
1991 }
1992 Set<String> parsed = new HashSet<>();
1993 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
1994 String childName = unalias(parser.getName());
1995 if (!parsed.add(childName)) {
1996 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
1997 }
1998 int line = parser.getLineNumber();
1999 int column = parser.getColumnNumber();
2000 Map<Object, InputLocation> locations = null;
2001 switch (childName) {
2002 case "enabled": {
2003 repositoryPolicy.enabled(interpolatedTrimmed(parser.nextText(), "enabled"));
2004 break;
2005 }
2006 case "updatePolicy": {
2007 repositoryPolicy.updatePolicy(interpolatedTrimmed(parser.nextText(), "updatePolicy"));
2008 break;
2009 }
2010 case "checksumPolicy": {
2011 repositoryPolicy.checksumPolicy(interpolatedTrimmed(parser.nextText(), "checksumPolicy"));
2012 break;
2013 }
2014 default: {
2015 checkUnknownElement(parser, strict);
2016 break;
2017 }
2018 }
2019 repositoryPolicy.location(childName, new InputLocation(line, column, source, locations));
2020 }
2021 return repositoryPolicy.build();
2022 }
2023
2024 private Site parseSite(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2025 String tagName = parser.getName();
2026 Site.Builder site = Site.newBuilder(true);
2027 site.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2028 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2029 String name = parser.getAttributeName(i);
2030 String value = parser.getAttributeValue(i);
2031 if (name.indexOf(':') >= 0) {
2032
2033 } else if ("child.site.url.inherit.append.path".equals(name)) {
2034 site.location(name, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2035 site.childSiteUrlInheritAppendPath(interpolatedTrimmed(value, "child.site.url.inherit.append.path"));
2036 } else {
2037 checkUnknownAttribute(parser, name, tagName, strict);
2038 }
2039 }
2040 Set<String> parsed = new HashSet<>();
2041 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2042 String childName = unalias(parser.getName());
2043 if (!parsed.add(childName)) {
2044 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2045 }
2046 int line = parser.getLineNumber();
2047 int column = parser.getColumnNumber();
2048 Map<Object, InputLocation> locations = null;
2049 switch (childName) {
2050 case "id": {
2051 site.id(interpolatedTrimmed(parser.nextText(), "id"));
2052 break;
2053 }
2054 case "name": {
2055 site.name(interpolatedTrimmed(parser.nextText(), "name"));
2056 break;
2057 }
2058 case "url": {
2059 site.url(interpolatedTrimmed(parser.nextText(), "url"));
2060 break;
2061 }
2062 default: {
2063 checkUnknownElement(parser, strict);
2064 break;
2065 }
2066 }
2067 site.location(childName, new InputLocation(line, column, source, locations));
2068 }
2069 return site.build();
2070 }
2071
2072 private ConfigurationContainer parseConfigurationContainer(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2073 String tagName = parser.getName();
2074 ConfigurationContainer.Builder configurationContainer = ConfigurationContainer.newBuilder(true);
2075 configurationContainer.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2076 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2077 String name = parser.getAttributeName(i);
2078 String value = parser.getAttributeValue(i);
2079 if (name.indexOf(':') >= 0) {
2080
2081 } else {
2082 checkUnknownAttribute(parser, name, tagName, strict);
2083 }
2084 }
2085 Set<String> parsed = new HashSet<>();
2086 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2087 String childName = unalias(parser.getName());
2088 if (!parsed.add(childName)) {
2089 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2090 }
2091 int line = parser.getLineNumber();
2092 int column = parser.getColumnNumber();
2093 Map<Object, InputLocation> locations = null;
2094 switch (childName) {
2095 case "inherited": {
2096 configurationContainer.inherited(interpolatedTrimmed(parser.nextText(), "inherited"));
2097 break;
2098 }
2099 case "configuration": {
2100 configurationContainer.configuration(XmlNodeBuilder.build(parser, true));
2101 break;
2102 }
2103 default: {
2104 checkUnknownElement(parser, strict);
2105 break;
2106 }
2107 }
2108 configurationContainer.location(childName, new InputLocation(line, column, source, locations));
2109 }
2110 return configurationContainer.build();
2111 }
2112
2113 private Plugin parsePlugin(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2114 String tagName = parser.getName();
2115 Plugin.Builder plugin = Plugin.newBuilder(true);
2116 plugin.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2117 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2118 String name = parser.getAttributeName(i);
2119 String value = parser.getAttributeValue(i);
2120 if (name.indexOf(':') >= 0) {
2121
2122 } else {
2123 checkUnknownAttribute(parser, name, tagName, strict);
2124 }
2125 }
2126 Set<String> parsed = new HashSet<>();
2127 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2128 String childName = unalias(parser.getName());
2129 if (!parsed.add(childName)) {
2130 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2131 }
2132 int line = parser.getLineNumber();
2133 int column = parser.getColumnNumber();
2134 Map<Object, InputLocation> locations = null;
2135 switch (childName) {
2136 case "groupId": {
2137 plugin.groupId(interpolatedTrimmed(parser.nextText(), "groupId"));
2138 break;
2139 }
2140 case "artifactId": {
2141 plugin.artifactId(interpolatedTrimmed(parser.nextText(), "artifactId"));
2142 break;
2143 }
2144 case "version": {
2145 plugin.version(interpolatedTrimmed(parser.nextText(), "version"));
2146 break;
2147 }
2148 case "extensions": {
2149 plugin.extensions(interpolatedTrimmed(parser.nextText(), "extensions"));
2150 break;
2151 }
2152 case "executions": {
2153 List<PluginExecution> executions = new ArrayList<>();
2154 while (parser.nextTag() == XmlPullParser.START_TAG) {
2155 if ("execution".equals(parser.getName())) {
2156 executions.add(parsePluginExecution(parser, strict, source));
2157 } else {
2158 checkUnknownElement(parser, strict);
2159 }
2160 }
2161 plugin.executions(executions);
2162 break;
2163 }
2164 case "dependencies": {
2165 List<Dependency> dependencies = new ArrayList<>();
2166 while (parser.nextTag() == XmlPullParser.START_TAG) {
2167 if ("dependency".equals(parser.getName())) {
2168 dependencies.add(parseDependency(parser, strict, source));
2169 } else {
2170 checkUnknownElement(parser, strict);
2171 }
2172 }
2173 plugin.dependencies(dependencies);
2174 break;
2175 }
2176 case "inherited": {
2177 plugin.inherited(interpolatedTrimmed(parser.nextText(), "inherited"));
2178 break;
2179 }
2180 case "configuration": {
2181 plugin.configuration(XmlNodeBuilder.build(parser, true));
2182 break;
2183 }
2184 default: {
2185 checkUnknownElement(parser, strict);
2186 break;
2187 }
2188 }
2189 plugin.location(childName, new InputLocation(line, column, source, locations));
2190 }
2191 return plugin.build();
2192 }
2193
2194 private PluginExecution parsePluginExecution(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2195 String tagName = parser.getName();
2196 PluginExecution.Builder pluginExecution = PluginExecution.newBuilder(true);
2197 pluginExecution.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2198 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2199 String name = parser.getAttributeName(i);
2200 String value = parser.getAttributeValue(i);
2201 if (name.indexOf(':') >= 0) {
2202
2203 } else {
2204 checkUnknownAttribute(parser, name, tagName, strict);
2205 }
2206 }
2207 Set<String> parsed = new HashSet<>();
2208 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2209 String childName = unalias(parser.getName());
2210 if (!parsed.add(childName)) {
2211 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2212 }
2213 int line = parser.getLineNumber();
2214 int column = parser.getColumnNumber();
2215 Map<Object, InputLocation> locations = null;
2216 switch (childName) {
2217 case "id": {
2218 pluginExecution.id(interpolatedTrimmed(parser.nextText(), "id"));
2219 break;
2220 }
2221 case "phase": {
2222 pluginExecution.phase(interpolatedTrimmed(parser.nextText(), "phase"));
2223 break;
2224 }
2225 case "goals": {
2226 List<String> goals = new ArrayList<>();
2227 locations = new HashMap<>();
2228 while (parser.nextTag() == XmlPullParser.START_TAG) {
2229 if ("goal".equals(parser.getName())) {
2230 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2231 goals.add(interpolatedTrimmed(parser.nextText(), "goals"));
2232 } else {
2233 checkUnknownElement(parser, strict);
2234 }
2235 }
2236 pluginExecution.goals(goals);
2237 break;
2238 }
2239 case "inherited": {
2240 pluginExecution.inherited(interpolatedTrimmed(parser.nextText(), "inherited"));
2241 break;
2242 }
2243 case "configuration": {
2244 pluginExecution.configuration(XmlNodeBuilder.build(parser, true));
2245 break;
2246 }
2247 default: {
2248 checkUnknownElement(parser, strict);
2249 break;
2250 }
2251 }
2252 pluginExecution.location(childName, new InputLocation(line, column, source, locations));
2253 }
2254 return pluginExecution.build();
2255 }
2256
2257 private DependencyManagement parseDependencyManagement(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2258 String tagName = parser.getName();
2259 DependencyManagement.Builder dependencyManagement = DependencyManagement.newBuilder(true);
2260 dependencyManagement.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2261 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2262 String name = parser.getAttributeName(i);
2263 String value = parser.getAttributeValue(i);
2264 if (name.indexOf(':') >= 0) {
2265
2266 } else {
2267 checkUnknownAttribute(parser, name, tagName, strict);
2268 }
2269 }
2270 Set<String> parsed = new HashSet<>();
2271 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2272 String childName = unalias(parser.getName());
2273 if (!parsed.add(childName)) {
2274 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2275 }
2276 int line = parser.getLineNumber();
2277 int column = parser.getColumnNumber();
2278 Map<Object, InputLocation> locations = null;
2279 switch (childName) {
2280 case "dependencies": {
2281 List<Dependency> dependencies = new ArrayList<>();
2282 while (parser.nextTag() == XmlPullParser.START_TAG) {
2283 if ("dependency".equals(parser.getName())) {
2284 dependencies.add(parseDependency(parser, strict, source));
2285 } else {
2286 checkUnknownElement(parser, strict);
2287 }
2288 }
2289 dependencyManagement.dependencies(dependencies);
2290 break;
2291 }
2292 default: {
2293 checkUnknownElement(parser, strict);
2294 break;
2295 }
2296 }
2297 dependencyManagement.location(childName, new InputLocation(line, column, source, locations));
2298 }
2299 return dependencyManagement.build();
2300 }
2301
2302 private PluginManagement parsePluginManagement(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2303 String tagName = parser.getName();
2304 PluginManagement.Builder pluginManagement = PluginManagement.newBuilder(true);
2305 pluginManagement.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2306 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2307 String name = parser.getAttributeName(i);
2308 String value = parser.getAttributeValue(i);
2309 if (name.indexOf(':') >= 0) {
2310
2311 } else {
2312 checkUnknownAttribute(parser, name, tagName, strict);
2313 }
2314 }
2315 Set<String> parsed = new HashSet<>();
2316 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2317 String childName = unalias(parser.getName());
2318 if (!parsed.add(childName)) {
2319 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2320 }
2321 int line = parser.getLineNumber();
2322 int column = parser.getColumnNumber();
2323 Map<Object, InputLocation> locations = null;
2324 switch (childName) {
2325 case "plugins": {
2326 List<Plugin> plugins = new ArrayList<>();
2327 while (parser.nextTag() == XmlPullParser.START_TAG) {
2328 if ("plugin".equals(parser.getName())) {
2329 plugins.add(parsePlugin(parser, strict, source));
2330 } else {
2331 checkUnknownElement(parser, strict);
2332 }
2333 }
2334 pluginManagement.plugins(plugins);
2335 break;
2336 }
2337 default: {
2338 checkUnknownElement(parser, strict);
2339 break;
2340 }
2341 }
2342 pluginManagement.location(childName, new InputLocation(line, column, source, locations));
2343 }
2344 return pluginManagement.build();
2345 }
2346
2347 private Reporting parseReporting(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2348 String tagName = parser.getName();
2349 Reporting.Builder reporting = Reporting.newBuilder(true);
2350 reporting.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2351 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2352 String name = parser.getAttributeName(i);
2353 String value = parser.getAttributeValue(i);
2354 if (name.indexOf(':') >= 0) {
2355
2356 } else {
2357 checkUnknownAttribute(parser, name, tagName, strict);
2358 }
2359 }
2360 Set<String> parsed = new HashSet<>();
2361 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2362 String childName = unalias(parser.getName());
2363 if (!parsed.add(childName)) {
2364 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2365 }
2366 int line = parser.getLineNumber();
2367 int column = parser.getColumnNumber();
2368 Map<Object, InputLocation> locations = null;
2369 switch (childName) {
2370 case "excludeDefaults": {
2371 reporting.excludeDefaults(interpolatedTrimmed(parser.nextText(), "excludeDefaults"));
2372 break;
2373 }
2374 case "outputDirectory": {
2375 reporting.outputDirectory(interpolatedTrimmed(parser.nextText(), "outputDirectory"));
2376 break;
2377 }
2378 case "plugins": {
2379 List<ReportPlugin> plugins = new ArrayList<>();
2380 while (parser.nextTag() == XmlPullParser.START_TAG) {
2381 if ("plugin".equals(parser.getName())) {
2382 plugins.add(parseReportPlugin(parser, strict, source));
2383 } else {
2384 checkUnknownElement(parser, strict);
2385 }
2386 }
2387 reporting.plugins(plugins);
2388 break;
2389 }
2390 default: {
2391 checkUnknownElement(parser, strict);
2392 break;
2393 }
2394 }
2395 reporting.location(childName, new InputLocation(line, column, source, locations));
2396 }
2397 return reporting.build();
2398 }
2399
2400 private Profile parseProfile(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2401 String tagName = parser.getName();
2402 Profile.Builder profile = Profile.newBuilder(true);
2403 profile.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2404 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2405 String name = parser.getAttributeName(i);
2406 String value = parser.getAttributeValue(i);
2407 if (name.indexOf(':') >= 0) {
2408
2409 } else {
2410 checkUnknownAttribute(parser, name, tagName, strict);
2411 }
2412 }
2413 Set<String> parsed = new HashSet<>();
2414 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2415 String childName = unalias(parser.getName());
2416 if (!parsed.add(childName)) {
2417 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2418 }
2419 int line = parser.getLineNumber();
2420 int column = parser.getColumnNumber();
2421 Map<Object, InputLocation> locations = null;
2422 switch (childName) {
2423 case "id": {
2424 profile.id(interpolatedTrimmed(parser.nextText(), "id"));
2425 break;
2426 }
2427 case "activation": {
2428 profile.activation(parseActivation(parser, strict, source ));
2429 break;
2430 }
2431 case "build": {
2432 profile.build(parseBuildBase(parser, strict, source ));
2433 break;
2434 }
2435 case "modules": {
2436 List<String> modules = new ArrayList<>();
2437 locations = new HashMap<>();
2438 while (parser.nextTag() == XmlPullParser.START_TAG) {
2439 if ("module".equals(parser.getName())) {
2440 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2441 modules.add(interpolatedTrimmed(parser.nextText(), "modules"));
2442 } else {
2443 checkUnknownElement(parser, strict);
2444 }
2445 }
2446 profile.modules(modules);
2447 break;
2448 }
2449 case "distributionManagement": {
2450 profile.distributionManagement(parseDistributionManagement(parser, strict, source ));
2451 break;
2452 }
2453 case "properties": {
2454 Map<String, String> properties = new LinkedHashMap<>();
2455 locations = new HashMap<>();
2456 while (parser.nextTag() == XmlPullParser.START_TAG) {
2457 String key = parser.getName();
2458 String value = parser.nextText().trim();
2459 locations.put(key, new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2460 properties.put(key, value);
2461 }
2462 profile.properties(properties);
2463 break;
2464 }
2465 case "dependencyManagement": {
2466 profile.dependencyManagement(parseDependencyManagement(parser, strict, source ));
2467 break;
2468 }
2469 case "dependencies": {
2470 List<Dependency> dependencies = new ArrayList<>();
2471 while (parser.nextTag() == XmlPullParser.START_TAG) {
2472 if ("dependency".equals(parser.getName())) {
2473 dependencies.add(parseDependency(parser, strict, source));
2474 } else {
2475 checkUnknownElement(parser, strict);
2476 }
2477 }
2478 profile.dependencies(dependencies);
2479 break;
2480 }
2481 case "repositories": {
2482 List<Repository> repositories = new ArrayList<>();
2483 while (parser.nextTag() == XmlPullParser.START_TAG) {
2484 if ("repository".equals(parser.getName())) {
2485 repositories.add(parseRepository(parser, strict, source));
2486 } else {
2487 checkUnknownElement(parser, strict);
2488 }
2489 }
2490 profile.repositories(repositories);
2491 break;
2492 }
2493 case "pluginRepositories": {
2494 List<Repository> pluginRepositories = new ArrayList<>();
2495 while (parser.nextTag() == XmlPullParser.START_TAG) {
2496 if ("pluginRepository".equals(parser.getName())) {
2497 pluginRepositories.add(parseRepository(parser, strict, source));
2498 } else {
2499 checkUnknownElement(parser, strict);
2500 }
2501 }
2502 profile.pluginRepositories(pluginRepositories);
2503 break;
2504 }
2505 case "reporting": {
2506 profile.reporting(parseReporting(parser, strict, source ));
2507 break;
2508 }
2509 default: {
2510 checkUnknownElement(parser, strict);
2511 break;
2512 }
2513 }
2514 profile.location(childName, new InputLocation(line, column, source, locations));
2515 }
2516 return profile.build();
2517 }
2518
2519 private Activation parseActivation(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2520 String tagName = parser.getName();
2521 Activation.Builder activation = Activation.newBuilder(true);
2522 activation.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2523 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2524 String name = parser.getAttributeName(i);
2525 String value = parser.getAttributeValue(i);
2526 if (name.indexOf(':') >= 0) {
2527
2528 } else {
2529 checkUnknownAttribute(parser, name, tagName, strict);
2530 }
2531 }
2532 Set<String> parsed = new HashSet<>();
2533 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2534 String childName = unalias(parser.getName());
2535 if (!parsed.add(childName)) {
2536 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2537 }
2538 int line = parser.getLineNumber();
2539 int column = parser.getColumnNumber();
2540 Map<Object, InputLocation> locations = null;
2541 switch (childName) {
2542 case "activeByDefault": {
2543 activation.activeByDefault(getBooleanValue(interpolatedTrimmed(parser.nextText(), "activeByDefault"), "activeByDefault", parser, false));
2544 break;
2545 }
2546 case "jdk": {
2547 activation.jdk(interpolatedTrimmed(parser.nextText(), "jdk"));
2548 break;
2549 }
2550 case "os": {
2551 activation.os(parseActivationOS(parser, strict, source ));
2552 break;
2553 }
2554 case "property": {
2555 activation.property(parseActivationProperty(parser, strict, source ));
2556 break;
2557 }
2558 case "file": {
2559 activation.file(parseActivationFile(parser, strict, source ));
2560 break;
2561 }
2562 default: {
2563 checkUnknownElement(parser, strict);
2564 break;
2565 }
2566 }
2567 activation.location(childName, new InputLocation(line, column, source, locations));
2568 }
2569 return activation.build();
2570 }
2571
2572 private ActivationProperty parseActivationProperty(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2573 String tagName = parser.getName();
2574 ActivationProperty.Builder activationProperty = ActivationProperty.newBuilder(true);
2575 activationProperty.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2576 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2577 String name = parser.getAttributeName(i);
2578 String value = parser.getAttributeValue(i);
2579 if (name.indexOf(':') >= 0) {
2580
2581 } else {
2582 checkUnknownAttribute(parser, name, tagName, strict);
2583 }
2584 }
2585 Set<String> parsed = new HashSet<>();
2586 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2587 String childName = unalias(parser.getName());
2588 if (!parsed.add(childName)) {
2589 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2590 }
2591 int line = parser.getLineNumber();
2592 int column = parser.getColumnNumber();
2593 Map<Object, InputLocation> locations = null;
2594 switch (childName) {
2595 case "name": {
2596 activationProperty.name(interpolatedTrimmed(parser.nextText(), "name"));
2597 break;
2598 }
2599 case "value": {
2600 activationProperty.value(interpolatedTrimmed(parser.nextText(), "value"));
2601 break;
2602 }
2603 default: {
2604 checkUnknownElement(parser, strict);
2605 break;
2606 }
2607 }
2608 activationProperty.location(childName, new InputLocation(line, column, source, locations));
2609 }
2610 return activationProperty.build();
2611 }
2612
2613 private ActivationOS parseActivationOS(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2614 String tagName = parser.getName();
2615 ActivationOS.Builder activationOS = ActivationOS.newBuilder(true);
2616 activationOS.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2617 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2618 String name = parser.getAttributeName(i);
2619 String value = parser.getAttributeValue(i);
2620 if (name.indexOf(':') >= 0) {
2621
2622 } else {
2623 checkUnknownAttribute(parser, name, tagName, strict);
2624 }
2625 }
2626 Set<String> parsed = new HashSet<>();
2627 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2628 String childName = unalias(parser.getName());
2629 if (!parsed.add(childName)) {
2630 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2631 }
2632 int line = parser.getLineNumber();
2633 int column = parser.getColumnNumber();
2634 Map<Object, InputLocation> locations = null;
2635 switch (childName) {
2636 case "name": {
2637 activationOS.name(interpolatedTrimmed(parser.nextText(), "name"));
2638 break;
2639 }
2640 case "family": {
2641 activationOS.family(interpolatedTrimmed(parser.nextText(), "family"));
2642 break;
2643 }
2644 case "arch": {
2645 activationOS.arch(interpolatedTrimmed(parser.nextText(), "arch"));
2646 break;
2647 }
2648 case "version": {
2649 activationOS.version(interpolatedTrimmed(parser.nextText(), "version"));
2650 break;
2651 }
2652 default: {
2653 checkUnknownElement(parser, strict);
2654 break;
2655 }
2656 }
2657 activationOS.location(childName, new InputLocation(line, column, source, locations));
2658 }
2659 return activationOS.build();
2660 }
2661
2662 private ActivationFile parseActivationFile(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2663 String tagName = parser.getName();
2664 ActivationFile.Builder activationFile = ActivationFile.newBuilder(true);
2665 activationFile.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2666 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2667 String name = parser.getAttributeName(i);
2668 String value = parser.getAttributeValue(i);
2669 if (name.indexOf(':') >= 0) {
2670
2671 } else {
2672 checkUnknownAttribute(parser, name, tagName, strict);
2673 }
2674 }
2675 Set<String> parsed = new HashSet<>();
2676 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2677 String childName = unalias(parser.getName());
2678 if (!parsed.add(childName)) {
2679 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2680 }
2681 int line = parser.getLineNumber();
2682 int column = parser.getColumnNumber();
2683 Map<Object, InputLocation> locations = null;
2684 switch (childName) {
2685 case "missing": {
2686 activationFile.missing(interpolatedTrimmed(parser.nextText(), "missing"));
2687 break;
2688 }
2689 case "exists": {
2690 activationFile.exists(interpolatedTrimmed(parser.nextText(), "exists"));
2691 break;
2692 }
2693 default: {
2694 checkUnknownElement(parser, strict);
2695 break;
2696 }
2697 }
2698 activationFile.location(childName, new InputLocation(line, column, source, locations));
2699 }
2700 return activationFile.build();
2701 }
2702
2703 private ReportPlugin parseReportPlugin(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2704 String tagName = parser.getName();
2705 ReportPlugin.Builder reportPlugin = ReportPlugin.newBuilder(true);
2706 reportPlugin.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2707 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2708 String name = parser.getAttributeName(i);
2709 String value = parser.getAttributeValue(i);
2710 if (name.indexOf(':') >= 0) {
2711
2712 } else {
2713 checkUnknownAttribute(parser, name, tagName, strict);
2714 }
2715 }
2716 Set<String> parsed = new HashSet<>();
2717 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2718 String childName = unalias(parser.getName());
2719 if (!parsed.add(childName)) {
2720 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2721 }
2722 int line = parser.getLineNumber();
2723 int column = parser.getColumnNumber();
2724 Map<Object, InputLocation> locations = null;
2725 switch (childName) {
2726 case "groupId": {
2727 reportPlugin.groupId(interpolatedTrimmed(parser.nextText(), "groupId"));
2728 break;
2729 }
2730 case "artifactId": {
2731 reportPlugin.artifactId(interpolatedTrimmed(parser.nextText(), "artifactId"));
2732 break;
2733 }
2734 case "version": {
2735 reportPlugin.version(interpolatedTrimmed(parser.nextText(), "version"));
2736 break;
2737 }
2738 case "reportSets": {
2739 List<ReportSet> reportSets = new ArrayList<>();
2740 while (parser.nextTag() == XmlPullParser.START_TAG) {
2741 if ("reportSet".equals(parser.getName())) {
2742 reportSets.add(parseReportSet(parser, strict, source));
2743 } else {
2744 checkUnknownElement(parser, strict);
2745 }
2746 }
2747 reportPlugin.reportSets(reportSets);
2748 break;
2749 }
2750 case "inherited": {
2751 reportPlugin.inherited(interpolatedTrimmed(parser.nextText(), "inherited"));
2752 break;
2753 }
2754 case "configuration": {
2755 reportPlugin.configuration(XmlNodeBuilder.build(parser, true));
2756 break;
2757 }
2758 default: {
2759 checkUnknownElement(parser, strict);
2760 break;
2761 }
2762 }
2763 reportPlugin.location(childName, new InputLocation(line, column, source, locations));
2764 }
2765 return reportPlugin.build();
2766 }
2767
2768 private ReportSet parseReportSet(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2769 String tagName = parser.getName();
2770 ReportSet.Builder reportSet = ReportSet.newBuilder(true);
2771 reportSet.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2772 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2773 String name = parser.getAttributeName(i);
2774 String value = parser.getAttributeValue(i);
2775 if (name.indexOf(':') >= 0) {
2776
2777 } else {
2778 checkUnknownAttribute(parser, name, tagName, strict);
2779 }
2780 }
2781 Set<String> parsed = new HashSet<>();
2782 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2783 String childName = unalias(parser.getName());
2784 if (!parsed.add(childName)) {
2785 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2786 }
2787 int line = parser.getLineNumber();
2788 int column = parser.getColumnNumber();
2789 Map<Object, InputLocation> locations = null;
2790 switch (childName) {
2791 case "id": {
2792 reportSet.id(interpolatedTrimmed(parser.nextText(), "id"));
2793 break;
2794 }
2795 case "reports": {
2796 List<String> reports = new ArrayList<>();
2797 locations = new HashMap<>();
2798 while (parser.nextTag() == XmlPullParser.START_TAG) {
2799 if ("report".equals(parser.getName())) {
2800 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2801 reports.add(interpolatedTrimmed(parser.nextText(), "reports"));
2802 } else {
2803 checkUnknownElement(parser, strict);
2804 }
2805 }
2806 reportSet.reports(reports);
2807 break;
2808 }
2809 case "inherited": {
2810 reportSet.inherited(interpolatedTrimmed(parser.nextText(), "inherited"));
2811 break;
2812 }
2813 case "configuration": {
2814 reportSet.configuration(XmlNodeBuilder.build(parser, true));
2815 break;
2816 }
2817 default: {
2818 checkUnknownElement(parser, strict);
2819 break;
2820 }
2821 }
2822 reportSet.location(childName, new InputLocation(line, column, source, locations));
2823 }
2824 return reportSet.build();
2825 }
2826
2827 private Prerequisites parsePrerequisites(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2828 String tagName = parser.getName();
2829 Prerequisites.Builder prerequisites = Prerequisites.newBuilder(true);
2830 prerequisites.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2831 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2832 String name = parser.getAttributeName(i);
2833 String value = parser.getAttributeValue(i);
2834 if (name.indexOf(':') >= 0) {
2835
2836 } else {
2837 checkUnknownAttribute(parser, name, tagName, strict);
2838 }
2839 }
2840 Set<String> parsed = new HashSet<>();
2841 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2842 String childName = unalias(parser.getName());
2843 if (!parsed.add(childName)) {
2844 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2845 }
2846 int line = parser.getLineNumber();
2847 int column = parser.getColumnNumber();
2848 Map<Object, InputLocation> locations = null;
2849 switch (childName) {
2850 case "maven": {
2851 prerequisites.maven(interpolatedTrimmed(parser.nextText(), "maven"));
2852 break;
2853 }
2854 default: {
2855 checkUnknownElement(parser, strict);
2856 break;
2857 }
2858 }
2859 prerequisites.location(childName, new InputLocation(line, column, source, locations));
2860 }
2861 return prerequisites.build();
2862 }
2863
2864 private Relocation parseRelocation(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2865 String tagName = parser.getName();
2866 Relocation.Builder relocation = Relocation.newBuilder(true);
2867 relocation.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2868 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2869 String name = parser.getAttributeName(i);
2870 String value = parser.getAttributeValue(i);
2871 if (name.indexOf(':') >= 0) {
2872
2873 } else {
2874 checkUnknownAttribute(parser, name, tagName, strict);
2875 }
2876 }
2877 Set<String> parsed = new HashSet<>();
2878 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2879 String childName = unalias(parser.getName());
2880 if (!parsed.add(childName)) {
2881 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2882 }
2883 int line = parser.getLineNumber();
2884 int column = parser.getColumnNumber();
2885 Map<Object, InputLocation> locations = null;
2886 switch (childName) {
2887 case "groupId": {
2888 relocation.groupId(interpolatedTrimmed(parser.nextText(), "groupId"));
2889 break;
2890 }
2891 case "artifactId": {
2892 relocation.artifactId(interpolatedTrimmed(parser.nextText(), "artifactId"));
2893 break;
2894 }
2895 case "version": {
2896 relocation.version(interpolatedTrimmed(parser.nextText(), "version"));
2897 break;
2898 }
2899 case "message": {
2900 relocation.message(interpolatedTrimmed(parser.nextText(), "message"));
2901 break;
2902 }
2903 default: {
2904 checkUnknownElement(parser, strict);
2905 break;
2906 }
2907 }
2908 relocation.location(childName, new InputLocation(line, column, source, locations));
2909 }
2910 return relocation.build();
2911 }
2912
2913 private Extension parseExtension(XmlPullParser parser, boolean strict, InputSource source) throws IOException, XmlPullParserException {
2914 String tagName = parser.getName();
2915 Extension.Builder extension = Extension.newBuilder(true);
2916 extension.location("", new InputLocation(parser.getLineNumber(), parser.getColumnNumber(), source));
2917 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2918 String name = parser.getAttributeName(i);
2919 String value = parser.getAttributeValue(i);
2920 if (name.indexOf(':') >= 0) {
2921
2922 } else {
2923 checkUnknownAttribute(parser, name, tagName, strict);
2924 }
2925 }
2926 Set<String> parsed = new HashSet<>();
2927 while ((strict ? parser.nextTag() : nextTag(parser)) == XmlPullParser.START_TAG) {
2928 String childName = unalias(parser.getName());
2929 if (!parsed.add(childName)) {
2930 throw new XmlPullParserException("Duplicated tag: '" + childName + "'", parser, null);
2931 }
2932 int line = parser.getLineNumber();
2933 int column = parser.getColumnNumber();
2934 Map<Object, InputLocation> locations = null;
2935 switch (childName) {
2936 case "groupId": {
2937 extension.groupId(interpolatedTrimmed(parser.nextText(), "groupId"));
2938 break;
2939 }
2940 case "artifactId": {
2941 extension.artifactId(interpolatedTrimmed(parser.nextText(), "artifactId"));
2942 break;
2943 }
2944 case "version": {
2945 extension.version(interpolatedTrimmed(parser.nextText(), "version"));
2946 break;
2947 }
2948 default: {
2949 checkUnknownElement(parser, strict);
2950 break;
2951 }
2952 }
2953 extension.location(childName, new InputLocation(line, column, source, locations));
2954 }
2955 return extension.build();
2956 }
2957
2958
2959 private String unalias(String tagName) {
2960 switch (tagName) {
2961 case "organisation":
2962 return "organization";
2963 case "organisationUrl":
2964 return "organizationUrl";
2965 default:
2966 return tagName;
2967 }
2968 }
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981 private void checkUnknownAttribute(XmlPullParser parser, String attribute, String tagName, boolean strict) throws XmlPullParserException, IOException {
2982
2983 if (strict) {
2984 throw new XmlPullParserException("Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null);
2985 }
2986 }
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997 private void checkUnknownElement(XmlPullParser parser, boolean strict) throws XmlPullParserException, IOException {
2998 if (strict) {
2999 throw new XmlPullParserException("Unrecognised tag: '" + parser.getName() + "'", parser, null);
3000 }
3001
3002 for (int unrecognizedTagCount = 1; unrecognizedTagCount > 0;) {
3003 int eventType = parser.next();
3004 if (eventType == XmlPullParser.START_TAG) {
3005 unrecognizedTagCount++;
3006 } else if (eventType == XmlPullParser.END_TAG) {
3007 unrecognizedTagCount--;
3008 }
3009 }
3010 }
3011
3012
3013
3014
3015
3016
3017
3018 private String getTrimmedValue(String s) {
3019 if (s != null) {
3020 s = s.trim();
3021 }
3022 return s;
3023 }
3024
3025
3026
3027
3028
3029
3030
3031
3032 private String interpolatedTrimmed(String value, String context) {
3033 return getTrimmedValue(contentTransformer.transform(value, context));
3034 }
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045 private int nextTag(XmlPullParser parser) throws IOException, XmlPullParserException {
3046 int eventType = parser.next();
3047 if (eventType == XmlPullParser.TEXT) {
3048 eventType = parser.next();
3049 }
3050 if (eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG) {
3051 throw new XmlPullParserException("expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null);
3052 }
3053 return eventType;
3054 }
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067 private boolean getBooleanValue(String s, String attribute, XmlPullParser parser, boolean defaultValue) throws XmlPullParserException {
3068 if (s != null && s.length() != 0) {
3069 return Boolean.valueOf(s).booleanValue();
3070 }
3071 return defaultValue;
3072 }
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085 private int getIntegerValue(String s, String attribute, XmlPullParser parser, boolean strict, int defaultValue) throws XmlPullParserException {
3086 if (s != null) {
3087 try {
3088 return Integer.valueOf(s).intValue();
3089 } catch (NumberFormatException nfe) {
3090 if (strict) {
3091 throw new XmlPullParserException("Unable to parse element '" + attribute + "', must be an integer", parser, nfe);
3092 }
3093 }
3094 }
3095 return defaultValue;
3096 }
3097
3098 public static interface ContentTransformer {
3099
3100
3101
3102
3103
3104
3105
3106 String transform(String source, String fieldName);
3107 }
3108
3109 }