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.Collections;
13 import java.util.Date;
14 import java.util.HashMap;
15 import java.util.HashSet;
16 import java.util.LinkedHashMap;
17 import java.util.List;
18 import java.util.Map;
19 import java.util.Set;
20 import org.apache.maven.api.annotations.Generated;
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.apache.maven.internal.xml.XmlNodeStaxBuilder;
69 import org.apache.maven.api.xml.XmlNode;
70 import javax.xml.stream.XMLInputFactory;
71 import javax.xml.stream.XMLStreamException;
72 import javax.xml.stream.XMLStreamReader;
73 import javax.xml.transform.stream.StreamSource;
74
75 import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
76 import static javax.xml.XMLConstants.XML_NS_URI;
77
78 @Generated
79 public class MavenStaxReader {
80
81 private static final Map<String, String> DEFAULT_ENTITIES;
82 static {
83 Map<String, String> entities = new HashMap<>();
84 entities.put("nbsp", "\u00a0");
85 entities.put("iexcl", "\u00a1");
86 entities.put("cent", "\u00a2");
87 entities.put("pound", "\u00a3");
88 entities.put("curren", "\u00a4");
89 entities.put("yen", "\u00a5");
90 entities.put("brvbar", "\u00a6");
91 entities.put("sect", "\u00a7");
92 entities.put("uml", "\u00a8");
93 entities.put("copy", "\u00a9");
94 entities.put("ordf", "\u00aa");
95 entities.put("laquo", "\u00ab");
96 entities.put("not", "\u00ac");
97 entities.put("shy", "\u00ad");
98 entities.put("reg", "\u00ae");
99 entities.put("macr", "\u00af");
100 entities.put("deg", "\u00b0");
101 entities.put("plusmn", "\u00b1");
102 entities.put("sup2", "\u00b2");
103 entities.put("sup3", "\u00b3");
104 entities.put("acute", "\u00b4");
105 entities.put("micro", "\u00b5");
106 entities.put("para", "\u00b6");
107 entities.put("middot", "\u00b7");
108 entities.put("cedil", "\u00b8");
109 entities.put("sup1", "\u00b9");
110 entities.put("ordm", "\u00ba");
111 entities.put("raquo", "\u00bb");
112 entities.put("frac14", "\u00bc");
113 entities.put("frac12", "\u00bd");
114 entities.put("frac34", "\u00be");
115 entities.put("iquest", "\u00bf");
116 entities.put("Agrave", "\u00c0");
117 entities.put("Aacute", "\u00c1");
118 entities.put("Acirc", "\u00c2");
119 entities.put("Atilde", "\u00c3");
120 entities.put("Auml", "\u00c4");
121 entities.put("Aring", "\u00c5");
122 entities.put("AElig", "\u00c6");
123 entities.put("Ccedil", "\u00c7");
124 entities.put("Egrave", "\u00c8");
125 entities.put("Eacute", "\u00c9");
126 entities.put("Ecirc", "\u00ca");
127 entities.put("Euml", "\u00cb");
128 entities.put("Igrave", "\u00cc");
129 entities.put("Iacute", "\u00cd");
130 entities.put("Icirc", "\u00ce");
131 entities.put("Iuml", "\u00cf");
132 entities.put("ETH", "\u00d0");
133 entities.put("Ntilde", "\u00d1");
134 entities.put("Ograve", "\u00d2");
135 entities.put("Oacute", "\u00d3");
136 entities.put("Ocirc", "\u00d4");
137 entities.put("Otilde", "\u00d5");
138 entities.put("Ouml", "\u00d6");
139 entities.put("times", "\u00d7");
140 entities.put("Oslash", "\u00d8");
141 entities.put("Ugrave", "\u00d9");
142 entities.put("Uacute", "\u00da");
143 entities.put("Ucirc", "\u00db");
144 entities.put("Uuml", "\u00dc");
145 entities.put("Yacute", "\u00dd");
146 entities.put("THORN", "\u00de");
147 entities.put("szlig", "\u00df");
148 entities.put("agrave", "\u00e0");
149 entities.put("aacute", "\u00e1");
150 entities.put("acirc", "\u00e2");
151 entities.put("atilde", "\u00e3");
152 entities.put("auml", "\u00e4");
153 entities.put("aring", "\u00e5");
154 entities.put("aelig", "\u00e6");
155 entities.put("ccedil", "\u00e7");
156 entities.put("egrave", "\u00e8");
157 entities.put("eacute", "\u00e9");
158 entities.put("ecirc", "\u00ea");
159 entities.put("euml", "\u00eb");
160 entities.put("igrave", "\u00ec");
161 entities.put("iacute", "\u00ed");
162 entities.put("icirc", "\u00ee");
163 entities.put("iuml", "\u00ef");
164 entities.put("eth", "\u00f0");
165 entities.put("ntilde", "\u00f1");
166 entities.put("ograve", "\u00f2");
167 entities.put("oacute", "\u00f3");
168 entities.put("ocirc", "\u00f4");
169 entities.put("otilde", "\u00f5");
170 entities.put("ouml", "\u00f6");
171 entities.put("divide", "\u00f7");
172 entities.put("oslash", "\u00f8");
173 entities.put("ugrave", "\u00f9");
174 entities.put("uacute", "\u00fa");
175 entities.put("ucirc", "\u00fb");
176 entities.put("uuml", "\u00fc");
177 entities.put("yacute", "\u00fd");
178 entities.put("thorn", "\u00fe");
179 entities.put("yuml", "\u00ff");
180
181
182
183
184
185 entities.put("OElig", "\u0152");
186 entities.put("oelig", "\u0153");
187 entities.put("Scaron", "\u0160");
188 entities.put("scaron", "\u0161");
189 entities.put("Yuml", "\u0178");
190 entities.put("circ", "\u02c6");
191 entities.put("tilde", "\u02dc");
192 entities.put("ensp", "\u2002");
193 entities.put("emsp", "\u2003");
194 entities.put("thinsp", "\u2009");
195 entities.put("zwnj", "\u200c");
196 entities.put("zwj", "\u200d");
197 entities.put("lrm", "\u200e");
198 entities.put("rlm", "\u200f");
199 entities.put("ndash", "\u2013");
200 entities.put("mdash", "\u2014");
201 entities.put("lsquo", "\u2018");
202 entities.put("rsquo", "\u2019");
203 entities.put("sbquo", "\u201a");
204 entities.put("ldquo", "\u201c");
205 entities.put("rdquo", "\u201d");
206 entities.put("bdquo", "\u201e");
207 entities.put("dagger", "\u2020");
208 entities.put("Dagger", "\u2021");
209 entities.put("permil", "\u2030");
210 entities.put("lsaquo", "\u2039");
211 entities.put("rsaquo", "\u203a");
212 entities.put("euro", "\u20ac");
213
214
215
216
217
218 entities.put("fnof", "\u0192");
219 entities.put("Alpha", "\u0391");
220 entities.put("Beta", "\u0392");
221 entities.put("Gamma", "\u0393");
222 entities.put("Delta", "\u0394");
223 entities.put("Epsilon", "\u0395");
224 entities.put("Zeta", "\u0396");
225 entities.put("Eta", "\u0397");
226 entities.put("Theta", "\u0398");
227 entities.put("Iota", "\u0399");
228 entities.put("Kappa", "\u039a");
229 entities.put("Lambda", "\u039b");
230 entities.put("Mu", "\u039c");
231 entities.put("Nu", "\u039d");
232 entities.put("Xi", "\u039e");
233 entities.put("Omicron", "\u039f");
234 entities.put("Pi", "\u03a0");
235 entities.put("Rho", "\u03a1");
236 entities.put("Sigma", "\u03a3");
237 entities.put("Tau", "\u03a4");
238 entities.put("Upsilon", "\u03a5");
239 entities.put("Phi", "\u03a6");
240 entities.put("Chi", "\u03a7");
241 entities.put("Psi", "\u03a8");
242 entities.put("Omega", "\u03a9");
243 entities.put("alpha", "\u03b1");
244 entities.put("beta", "\u03b2");
245 entities.put("gamma", "\u03b3");
246 entities.put("delta", "\u03b4");
247 entities.put("epsilon", "\u03b5");
248 entities.put("zeta", "\u03b6");
249 entities.put("eta", "\u03b7");
250 entities.put("theta", "\u03b8");
251 entities.put("iota", "\u03b9");
252 entities.put("kappa", "\u03ba");
253 entities.put("lambda", "\u03bb");
254 entities.put("mu", "\u03bc");
255 entities.put("nu", "\u03bd");
256 entities.put("xi", "\u03be");
257 entities.put("omicron", "\u03bf");
258 entities.put("pi", "\u03c0");
259 entities.put("rho", "\u03c1");
260 entities.put("sigmaf", "\u03c2");
261 entities.put("sigma", "\u03c3");
262 entities.put("tau", "\u03c4");
263 entities.put("upsilon", "\u03c5");
264 entities.put("phi", "\u03c6");
265 entities.put("chi", "\u03c7");
266 entities.put("psi", "\u03c8");
267 entities.put("omega", "\u03c9");
268 entities.put("thetasym", "\u03d1");
269 entities.put("upsih", "\u03d2");
270 entities.put("piv", "\u03d6");
271 entities.put("bull", "\u2022");
272 entities.put("hellip", "\u2026");
273 entities.put("prime", "\u2032");
274 entities.put("Prime", "\u2033");
275 entities.put("oline", "\u203e");
276 entities.put("frasl", "\u2044");
277 entities.put("weierp", "\u2118");
278 entities.put("image", "\u2111");
279 entities.put("real", "\u211c");
280 entities.put("trade", "\u2122");
281 entities.put("alefsym", "\u2135");
282 entities.put("larr", "\u2190");
283 entities.put("uarr", "\u2191");
284 entities.put("rarr", "\u2192");
285 entities.put("darr", "\u2193");
286 entities.put("harr", "\u2194");
287 entities.put("crarr", "\u21b5");
288 entities.put("lArr", "\u21d0");
289 entities.put("uArr", "\u21d1");
290 entities.put("rArr", "\u21d2");
291 entities.put("dArr", "\u21d3");
292 entities.put("hArr", "\u21d4");
293 entities.put("forall", "\u2200");
294 entities.put("part", "\u2202");
295 entities.put("exist", "\u2203");
296 entities.put("empty", "\u2205");
297 entities.put("nabla", "\u2207");
298 entities.put("isin", "\u2208");
299 entities.put("notin", "\u2209");
300 entities.put("ni", "\u220b");
301 entities.put("prod", "\u220f");
302 entities.put("sum", "\u2211");
303 entities.put("minus", "\u2212");
304 entities.put("lowast", "\u2217");
305 entities.put("radic", "\u221a");
306 entities.put("prop", "\u221d");
307 entities.put("infin", "\u221e");
308 entities.put("ang", "\u2220");
309 entities.put("and", "\u2227");
310 entities.put("or", "\u2228");
311 entities.put("cap", "\u2229");
312 entities.put("cup", "\u222a");
313 entities.put("int", "\u222b");
314 entities.put("there4", "\u2234");
315 entities.put("sim", "\u223c");
316 entities.put("cong", "\u2245");
317 entities.put("asymp", "\u2248");
318 entities.put("ne", "\u2260");
319 entities.put("equiv", "\u2261");
320 entities.put("le", "\u2264");
321 entities.put("ge", "\u2265");
322 entities.put("sub", "\u2282");
323 entities.put("sup", "\u2283");
324 entities.put("nsub", "\u2284");
325 entities.put("sube", "\u2286");
326 entities.put("supe", "\u2287");
327 entities.put("oplus", "\u2295");
328 entities.put("otimes", "\u2297");
329 entities.put("perp", "\u22a5");
330 entities.put("sdot", "\u22c5");
331 entities.put("lceil", "\u2308");
332 entities.put("rceil", "\u2309");
333 entities.put("lfloor", "\u230a");
334 entities.put("rfloor", "\u230b");
335 entities.put("lang", "\u2329");
336 entities.put("rang", "\u232a");
337 entities.put("loz", "\u25ca");
338 entities.put("spades", "\u2660");
339 entities.put("clubs", "\u2663");
340 entities.put("hearts", "\u2665");
341 entities.put("diams", "\u2666");
342 DEFAULT_ENTITIES = Collections.unmodifiableMap(entities);
343 }
344
345 static class InputFactoryHolder {
346 static XMLInputFactory XML_INPUT_FACTORY;
347 static {
348 XMLInputFactory factory = XMLInputFactory.newFactory();
349 factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
350 XML_INPUT_FACTORY = factory;
351 }
352 }
353
354 private boolean addDefaultEntities = true;
355 private boolean addLocationInformation = true;
356
357 private final ContentTransformer contentTransformer;
358
359 public MavenStaxReader() {
360 this((s, f) -> s);
361 }
362
363 public MavenStaxReader(ContentTransformer contentTransformer) {
364 this.contentTransformer = contentTransformer;
365 }
366
367
368
369
370
371
372 public XMLInputFactory getXMLInputFactory() {
373 return InputFactoryHolder.XML_INPUT_FACTORY;
374 }
375
376
377
378
379
380
381 public boolean getAddDefaultEntities() {
382 return addDefaultEntities;
383 }
384
385
386
387
388
389
390 public void setAddDefaultEntities(boolean addDefaultEntities) {
391 this.addDefaultEntities = addDefaultEntities;
392 }
393
394
395
396
397
398
399 public boolean getAddLocationInformation() {
400 return addLocationInformation;
401 }
402
403
404
405
406
407
408 public void setAddLocationInformation(boolean addLocationInformation) {
409 this.addLocationInformation = addLocationInformation;
410 }
411
412 public Model read(Reader reader) throws XMLStreamException {
413 return read(reader, true, null);
414 }
415
416
417
418
419
420
421
422
423 public Model read(Reader reader, boolean strict, InputSource source) throws XMLStreamException {
424 StreamSource streamSource = new StreamSource(reader, source != null ? source.getLocation() : null);
425 XMLInputFactory factory = getXMLInputFactory();
426 XMLStreamReader parser = factory.createXMLStreamReader(streamSource);
427 return read(parser, strict, source);
428 }
429
430 public Model read(InputStream in) throws XMLStreamException {
431 return read(in, true, null);
432 }
433
434
435
436
437
438
439
440
441
442
443 public Model read(InputStream in, boolean strict, InputSource source) throws XMLStreamException {
444 StreamSource streamSource = new StreamSource(in, source != null ? source.getLocation() : null);
445 XMLInputFactory factory = getXMLInputFactory();
446 XMLStreamReader parser = factory.createXMLStreamReader(streamSource);
447 return read(parser, strict, source);
448 }
449
450
451
452
453
454
455
456
457
458
459 public Model read(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
460 Model model = null;
461 int eventType = parser.getEventType();
462 boolean parsed = false;
463 while (eventType != XMLStreamReader.END_DOCUMENT) {
464 if (eventType == XMLStreamReader.START_ELEMENT) {
465 if (strict && ! "project".equals(parser.getLocalName())) {
466 throw new XMLStreamException("Expected root element 'project' but found '" + parser.getName() + "'", parser.getLocation(), null);
467 } else if (parsed) {
468
469 throw new XMLStreamException("Duplicated tag: 'project'", parser.getLocation(), null);
470 }
471 model = parseModel(parser, strict, source);
472 parsed = true;
473 }
474 eventType = parser.next();
475 }
476 if (parsed) {
477 return model;
478 }
479 throw new XMLStreamException("Expected root element 'project' but found no element at all: invalid XML document", parser.getLocation(), null);
480 }
481
482 private Model parseModel(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
483 String tagName = parser.getLocalName();
484 Model.Builder model = Model.newBuilder(true);
485 if (addLocationInformation) {
486 model.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
487 }
488 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
489 String name = parser.getAttributeLocalName(i);
490 String ns = parser.getAttributeNamespace(i);
491 String value = parser.getAttributeValue(i);
492 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
493
494 } else if ("xmlns".equals(name)) {
495
496 } else if ("child.project.url.inherit.append.path".equals(name)) {
497 if (addLocationInformation) {
498 model.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
499 }
500 model.childProjectUrlInheritAppendPath(interpolatedTrimmed(value, "child.project.url.inherit.append.path"));
501 } else if ("root".equals(name)) {
502 if (addLocationInformation) {
503 model.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
504 }
505 model.root(getBooleanValue(interpolatedTrimmed(value, "root"), "root", parser, false));
506 } else if ("preserve.model.version".equals(name)) {
507 if (addLocationInformation) {
508 model.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
509 }
510 model.preserveModelVersion(getBooleanValue(interpolatedTrimmed(value, "preserve.model.version"), "preserve.model.version", parser, false));
511 } else {
512 checkUnknownAttribute(parser, name, tagName, strict);
513 }
514 }
515 Set<String> parsed = new HashSet<>();
516 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
517 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
518 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
519 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
520 Map<Object, InputLocation> locations = null;
521 switch (childName) {
522 case "modelVersion": {
523 model.modelVersion(interpolatedTrimmed(nextText(parser, strict), "modelVersion"));
524 break;
525 }
526 case "parent": {
527 model.parent(parseParent(parser, strict, source));
528 break;
529 }
530 case "groupId": {
531 model.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
532 break;
533 }
534 case "artifactId": {
535 model.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
536 break;
537 }
538 case "version": {
539 model.version(interpolatedTrimmed(nextText(parser, strict), "version"));
540 break;
541 }
542 case "packaging": {
543 model.packaging(interpolatedTrimmed(nextText(parser, strict), "packaging"));
544 break;
545 }
546 case "name": {
547 model.name(interpolatedTrimmed(nextText(parser, strict), "name"));
548 break;
549 }
550 case "description": {
551 model.description(interpolatedTrimmed(nextText(parser, strict), "description"));
552 break;
553 }
554 case "url": {
555 model.url(interpolatedTrimmed(nextText(parser, strict), "url"));
556 break;
557 }
558 case "inceptionYear": {
559 model.inceptionYear(interpolatedTrimmed(nextText(parser, strict), "inceptionYear"));
560 break;
561 }
562 case "organization": {
563 model.organization(parseOrganization(parser, strict, source));
564 break;
565 }
566 case "licenses": {
567 List<License> licenses = new ArrayList<>();
568 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
569 if ("license".equals(parser.getLocalName())) {
570 licenses.add(parseLicense(parser, strict, source));
571 } else {
572 checkUnknownElement(parser, strict);
573 }
574 }
575 model.licenses(licenses);
576 break;
577 }
578 case "developers": {
579 List<Developer> developers = new ArrayList<>();
580 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
581 if ("developer".equals(parser.getLocalName())) {
582 developers.add(parseDeveloper(parser, strict, source));
583 } else {
584 checkUnknownElement(parser, strict);
585 }
586 }
587 model.developers(developers);
588 break;
589 }
590 case "contributors": {
591 List<Contributor> contributors = new ArrayList<>();
592 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
593 if ("contributor".equals(parser.getLocalName())) {
594 contributors.add(parseContributor(parser, strict, source));
595 } else {
596 checkUnknownElement(parser, strict);
597 }
598 }
599 model.contributors(contributors);
600 break;
601 }
602 case "mailingLists": {
603 List<MailingList> mailingLists = new ArrayList<>();
604 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
605 if ("mailingList".equals(parser.getLocalName())) {
606 mailingLists.add(parseMailingList(parser, strict, source));
607 } else {
608 checkUnknownElement(parser, strict);
609 }
610 }
611 model.mailingLists(mailingLists);
612 break;
613 }
614 case "prerequisites": {
615 model.prerequisites(parsePrerequisites(parser, strict, source));
616 break;
617 }
618 case "modules": {
619 List<String> modules = new ArrayList<>();
620 locations = new HashMap<>();
621 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
622 if ("module".equals(parser.getLocalName())) {
623 if (addLocationInformation) {
624 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
625 }
626 modules.add(interpolatedTrimmed(nextText(parser, strict), "modules"));
627 } else {
628 checkUnknownElement(parser, strict);
629 }
630 }
631 model.modules(modules);
632 break;
633 }
634 case "subprojects": {
635 List<String> subprojects = new ArrayList<>();
636 locations = new HashMap<>();
637 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
638 if ("subproject".equals(parser.getLocalName())) {
639 if (addLocationInformation) {
640 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
641 }
642 subprojects.add(interpolatedTrimmed(nextText(parser, strict), "subprojects"));
643 } else {
644 checkUnknownElement(parser, strict);
645 }
646 }
647 model.subprojects(subprojects);
648 break;
649 }
650 case "scm": {
651 model.scm(parseScm(parser, strict, source));
652 break;
653 }
654 case "issueManagement": {
655 model.issueManagement(parseIssueManagement(parser, strict, source));
656 break;
657 }
658 case "ciManagement": {
659 model.ciManagement(parseCiManagement(parser, strict, source));
660 break;
661 }
662 case "distributionManagement": {
663 model.distributionManagement(parseDistributionManagement(parser, strict, source));
664 break;
665 }
666 case "properties": {
667 Map<String, String> properties = new LinkedHashMap<>();
668 locations = new HashMap<>();
669 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
670 String key = parser.getLocalName();
671 String value = nextText(parser, strict).trim();
672 if (addLocationInformation) {
673 locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
674 }
675 properties.put(key, value);
676 }
677 model.properties(properties);
678 break;
679 }
680 case "dependencyManagement": {
681 model.dependencyManagement(parseDependencyManagement(parser, strict, source));
682 break;
683 }
684 case "dependencies": {
685 List<Dependency> dependencies = new ArrayList<>();
686 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
687 if ("dependency".equals(parser.getLocalName())) {
688 dependencies.add(parseDependency(parser, strict, source));
689 } else {
690 checkUnknownElement(parser, strict);
691 }
692 }
693 model.dependencies(dependencies);
694 break;
695 }
696 case "repositories": {
697 List<Repository> repositories = new ArrayList<>();
698 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
699 if ("repository".equals(parser.getLocalName())) {
700 repositories.add(parseRepository(parser, strict, source));
701 } else {
702 checkUnknownElement(parser, strict);
703 }
704 }
705 model.repositories(repositories);
706 break;
707 }
708 case "pluginRepositories": {
709 List<Repository> pluginRepositories = new ArrayList<>();
710 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
711 if ("pluginRepository".equals(parser.getLocalName())) {
712 pluginRepositories.add(parseRepository(parser, strict, source));
713 } else {
714 checkUnknownElement(parser, strict);
715 }
716 }
717 model.pluginRepositories(pluginRepositories);
718 break;
719 }
720 case "build": {
721 model.build(parseBuild(parser, strict, source));
722 break;
723 }
724 case "reporting": {
725 model.reporting(parseReporting(parser, strict, source));
726 break;
727 }
728 case "profiles": {
729 List<Profile> profiles = new ArrayList<>();
730 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
731 if ("profile".equals(parser.getLocalName())) {
732 profiles.add(parseProfile(parser, strict, source));
733 } else {
734 checkUnknownElement(parser, strict);
735 }
736 }
737 model.profiles(profiles);
738 break;
739 }
740 default: {
741 checkUnknownElement(parser, strict);
742 break;
743 }
744 }
745 if (addLocationInformation) {
746 model.location(childName, new InputLocation(line, column, source, locations));
747 }
748 }
749 model.namespaceUri(parser.getNamespaceURI());
750 model.modelEncoding(parser.getEncoding());
751 return model.build();
752 }
753
754 private ModelBase parseModelBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
755 String tagName = parser.getLocalName();
756 ModelBase.Builder modelBase = ModelBase.newBuilder(true);
757 if (addLocationInformation) {
758 modelBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
759 }
760 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
761 String name = parser.getAttributeLocalName(i);
762 String ns = parser.getAttributeNamespace(i);
763 String value = parser.getAttributeValue(i);
764 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
765
766 } else {
767 checkUnknownAttribute(parser, name, tagName, strict);
768 }
769 }
770 Set<String> parsed = new HashSet<>();
771 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
772 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
773 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
774 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
775 Map<Object, InputLocation> locations = null;
776 switch (childName) {
777 case "modules": {
778 List<String> modules = new ArrayList<>();
779 locations = new HashMap<>();
780 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
781 if ("module".equals(parser.getLocalName())) {
782 if (addLocationInformation) {
783 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
784 }
785 modules.add(interpolatedTrimmed(nextText(parser, strict), "modules"));
786 } else {
787 checkUnknownElement(parser, strict);
788 }
789 }
790 modelBase.modules(modules);
791 break;
792 }
793 case "subprojects": {
794 List<String> subprojects = new ArrayList<>();
795 locations = new HashMap<>();
796 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
797 if ("subproject".equals(parser.getLocalName())) {
798 if (addLocationInformation) {
799 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
800 }
801 subprojects.add(interpolatedTrimmed(nextText(parser, strict), "subprojects"));
802 } else {
803 checkUnknownElement(parser, strict);
804 }
805 }
806 modelBase.subprojects(subprojects);
807 break;
808 }
809 case "distributionManagement": {
810 modelBase.distributionManagement(parseDistributionManagement(parser, strict, source));
811 break;
812 }
813 case "properties": {
814 Map<String, String> properties = new LinkedHashMap<>();
815 locations = new HashMap<>();
816 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
817 String key = parser.getLocalName();
818 String value = nextText(parser, strict).trim();
819 if (addLocationInformation) {
820 locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
821 }
822 properties.put(key, value);
823 }
824 modelBase.properties(properties);
825 break;
826 }
827 case "dependencyManagement": {
828 modelBase.dependencyManagement(parseDependencyManagement(parser, strict, source));
829 break;
830 }
831 case "dependencies": {
832 List<Dependency> dependencies = new ArrayList<>();
833 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
834 if ("dependency".equals(parser.getLocalName())) {
835 dependencies.add(parseDependency(parser, strict, source));
836 } else {
837 checkUnknownElement(parser, strict);
838 }
839 }
840 modelBase.dependencies(dependencies);
841 break;
842 }
843 case "repositories": {
844 List<Repository> repositories = new ArrayList<>();
845 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
846 if ("repository".equals(parser.getLocalName())) {
847 repositories.add(parseRepository(parser, strict, source));
848 } else {
849 checkUnknownElement(parser, strict);
850 }
851 }
852 modelBase.repositories(repositories);
853 break;
854 }
855 case "pluginRepositories": {
856 List<Repository> pluginRepositories = new ArrayList<>();
857 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
858 if ("pluginRepository".equals(parser.getLocalName())) {
859 pluginRepositories.add(parseRepository(parser, strict, source));
860 } else {
861 checkUnknownElement(parser, strict);
862 }
863 }
864 modelBase.pluginRepositories(pluginRepositories);
865 break;
866 }
867 case "reporting": {
868 modelBase.reporting(parseReporting(parser, strict, source));
869 break;
870 }
871 default: {
872 checkUnknownElement(parser, strict);
873 break;
874 }
875 }
876 if (addLocationInformation) {
877 modelBase.location(childName, new InputLocation(line, column, source, locations));
878 }
879 }
880 return modelBase.build();
881 }
882
883 private PluginContainer parsePluginContainer(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
884 String tagName = parser.getLocalName();
885 PluginContainer.Builder pluginContainer = PluginContainer.newBuilder(true);
886 if (addLocationInformation) {
887 pluginContainer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
888 }
889 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
890 String name = parser.getAttributeLocalName(i);
891 String ns = parser.getAttributeNamespace(i);
892 String value = parser.getAttributeValue(i);
893 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
894
895 } else {
896 checkUnknownAttribute(parser, name, tagName, strict);
897 }
898 }
899 Set<String> parsed = new HashSet<>();
900 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
901 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
902 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
903 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
904 Map<Object, InputLocation> locations = null;
905 switch (childName) {
906 case "plugins": {
907 List<Plugin> plugins = new ArrayList<>();
908 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
909 if ("plugin".equals(parser.getLocalName())) {
910 plugins.add(parsePlugin(parser, strict, source));
911 } else {
912 checkUnknownElement(parser, strict);
913 }
914 }
915 pluginContainer.plugins(plugins);
916 break;
917 }
918 default: {
919 checkUnknownElement(parser, strict);
920 break;
921 }
922 }
923 if (addLocationInformation) {
924 pluginContainer.location(childName, new InputLocation(line, column, source, locations));
925 }
926 }
927 return pluginContainer.build();
928 }
929
930 private PluginConfiguration parsePluginConfiguration(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
931 String tagName = parser.getLocalName();
932 PluginConfiguration.Builder pluginConfiguration = PluginConfiguration.newBuilder(true);
933 if (addLocationInformation) {
934 pluginConfiguration.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
935 }
936 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
937 String name = parser.getAttributeLocalName(i);
938 String ns = parser.getAttributeNamespace(i);
939 String value = parser.getAttributeValue(i);
940 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
941
942 } else {
943 checkUnknownAttribute(parser, name, tagName, strict);
944 }
945 }
946 Set<String> parsed = new HashSet<>();
947 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
948 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
949 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
950 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
951 Map<Object, InputLocation> locations = null;
952 switch (childName) {
953 case "pluginManagement": {
954 pluginConfiguration.pluginManagement(parsePluginManagement(parser, strict, source));
955 break;
956 }
957 case "plugins": {
958 List<Plugin> plugins = new ArrayList<>();
959 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
960 if ("plugin".equals(parser.getLocalName())) {
961 plugins.add(parsePlugin(parser, strict, source));
962 } else {
963 checkUnknownElement(parser, strict);
964 }
965 }
966 pluginConfiguration.plugins(plugins);
967 break;
968 }
969 default: {
970 checkUnknownElement(parser, strict);
971 break;
972 }
973 }
974 if (addLocationInformation) {
975 pluginConfiguration.location(childName, new InputLocation(line, column, source, locations));
976 }
977 }
978 return pluginConfiguration.build();
979 }
980
981 private BuildBase parseBuildBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
982 String tagName = parser.getLocalName();
983 BuildBase.Builder buildBase = BuildBase.newBuilder(true);
984 if (addLocationInformation) {
985 buildBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
986 }
987 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
988 String name = parser.getAttributeLocalName(i);
989 String ns = parser.getAttributeNamespace(i);
990 String value = parser.getAttributeValue(i);
991 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
992
993 } else {
994 checkUnknownAttribute(parser, name, tagName, strict);
995 }
996 }
997 Set<String> parsed = new HashSet<>();
998 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
999 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1000 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1001 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1002 Map<Object, InputLocation> locations = null;
1003 switch (childName) {
1004 case "defaultGoal": {
1005 buildBase.defaultGoal(interpolatedTrimmed(nextText(parser, strict), "defaultGoal"));
1006 break;
1007 }
1008 case "resources": {
1009 List<Resource> resources = new ArrayList<>();
1010 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1011 if ("resource".equals(parser.getLocalName())) {
1012 resources.add(parseResource(parser, strict, source));
1013 } else {
1014 checkUnknownElement(parser, strict);
1015 }
1016 }
1017 buildBase.resources(resources);
1018 break;
1019 }
1020 case "testResources": {
1021 List<Resource> testResources = new ArrayList<>();
1022 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1023 if ("testResource".equals(parser.getLocalName())) {
1024 testResources.add(parseResource(parser, strict, source));
1025 } else {
1026 checkUnknownElement(parser, strict);
1027 }
1028 }
1029 buildBase.testResources(testResources);
1030 break;
1031 }
1032 case "directory": {
1033 buildBase.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
1034 break;
1035 }
1036 case "finalName": {
1037 buildBase.finalName(interpolatedTrimmed(nextText(parser, strict), "finalName"));
1038 break;
1039 }
1040 case "filters": {
1041 List<String> filters = new ArrayList<>();
1042 locations = new HashMap<>();
1043 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1044 if ("filter".equals(parser.getLocalName())) {
1045 if (addLocationInformation) {
1046 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1047 }
1048 filters.add(interpolatedTrimmed(nextText(parser, strict), "filters"));
1049 } else {
1050 checkUnknownElement(parser, strict);
1051 }
1052 }
1053 buildBase.filters(filters);
1054 break;
1055 }
1056 case "pluginManagement": {
1057 buildBase.pluginManagement(parsePluginManagement(parser, strict, source));
1058 break;
1059 }
1060 case "plugins": {
1061 List<Plugin> plugins = new ArrayList<>();
1062 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1063 if ("plugin".equals(parser.getLocalName())) {
1064 plugins.add(parsePlugin(parser, strict, source));
1065 } else {
1066 checkUnknownElement(parser, strict);
1067 }
1068 }
1069 buildBase.plugins(plugins);
1070 break;
1071 }
1072 default: {
1073 checkUnknownElement(parser, strict);
1074 break;
1075 }
1076 }
1077 if (addLocationInformation) {
1078 buildBase.location(childName, new InputLocation(line, column, source, locations));
1079 }
1080 }
1081 return buildBase.build();
1082 }
1083
1084 private Build parseBuild(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1085 String tagName = parser.getLocalName();
1086 Build.Builder build = Build.newBuilder(true);
1087 if (addLocationInformation) {
1088 build.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1089 }
1090 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1091 String name = parser.getAttributeLocalName(i);
1092 String ns = parser.getAttributeNamespace(i);
1093 String value = parser.getAttributeValue(i);
1094 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1095
1096 } else {
1097 checkUnknownAttribute(parser, name, tagName, strict);
1098 }
1099 }
1100 Set<String> parsed = new HashSet<>();
1101 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1102 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1103 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1104 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1105 Map<Object, InputLocation> locations = null;
1106 switch (childName) {
1107 case "sourceDirectory": {
1108 build.sourceDirectory(interpolatedTrimmed(nextText(parser, strict), "sourceDirectory"));
1109 break;
1110 }
1111 case "scriptSourceDirectory": {
1112 build.scriptSourceDirectory(interpolatedTrimmed(nextText(parser, strict), "scriptSourceDirectory"));
1113 break;
1114 }
1115 case "testSourceDirectory": {
1116 build.testSourceDirectory(interpolatedTrimmed(nextText(parser, strict), "testSourceDirectory"));
1117 break;
1118 }
1119 case "outputDirectory": {
1120 build.outputDirectory(interpolatedTrimmed(nextText(parser, strict), "outputDirectory"));
1121 break;
1122 }
1123 case "testOutputDirectory": {
1124 build.testOutputDirectory(interpolatedTrimmed(nextText(parser, strict), "testOutputDirectory"));
1125 break;
1126 }
1127 case "extensions": {
1128 List<Extension> extensions = new ArrayList<>();
1129 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1130 if ("extension".equals(parser.getLocalName())) {
1131 extensions.add(parseExtension(parser, strict, source));
1132 } else {
1133 checkUnknownElement(parser, strict);
1134 }
1135 }
1136 build.extensions(extensions);
1137 break;
1138 }
1139 case "defaultGoal": {
1140 build.defaultGoal(interpolatedTrimmed(nextText(parser, strict), "defaultGoal"));
1141 break;
1142 }
1143 case "resources": {
1144 List<Resource> resources = new ArrayList<>();
1145 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1146 if ("resource".equals(parser.getLocalName())) {
1147 resources.add(parseResource(parser, strict, source));
1148 } else {
1149 checkUnknownElement(parser, strict);
1150 }
1151 }
1152 build.resources(resources);
1153 break;
1154 }
1155 case "testResources": {
1156 List<Resource> testResources = new ArrayList<>();
1157 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1158 if ("testResource".equals(parser.getLocalName())) {
1159 testResources.add(parseResource(parser, strict, source));
1160 } else {
1161 checkUnknownElement(parser, strict);
1162 }
1163 }
1164 build.testResources(testResources);
1165 break;
1166 }
1167 case "directory": {
1168 build.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
1169 break;
1170 }
1171 case "finalName": {
1172 build.finalName(interpolatedTrimmed(nextText(parser, strict), "finalName"));
1173 break;
1174 }
1175 case "filters": {
1176 List<String> filters = new ArrayList<>();
1177 locations = new HashMap<>();
1178 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1179 if ("filter".equals(parser.getLocalName())) {
1180 if (addLocationInformation) {
1181 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1182 }
1183 filters.add(interpolatedTrimmed(nextText(parser, strict), "filters"));
1184 } else {
1185 checkUnknownElement(parser, strict);
1186 }
1187 }
1188 build.filters(filters);
1189 break;
1190 }
1191 case "pluginManagement": {
1192 build.pluginManagement(parsePluginManagement(parser, strict, source));
1193 break;
1194 }
1195 case "plugins": {
1196 List<Plugin> plugins = new ArrayList<>();
1197 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1198 if ("plugin".equals(parser.getLocalName())) {
1199 plugins.add(parsePlugin(parser, strict, source));
1200 } else {
1201 checkUnknownElement(parser, strict);
1202 }
1203 }
1204 build.plugins(plugins);
1205 break;
1206 }
1207 default: {
1208 checkUnknownElement(parser, strict);
1209 break;
1210 }
1211 }
1212 if (addLocationInformation) {
1213 build.location(childName, new InputLocation(line, column, source, locations));
1214 }
1215 }
1216 return build.build();
1217 }
1218
1219 private CiManagement parseCiManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1220 String tagName = parser.getLocalName();
1221 CiManagement.Builder ciManagement = CiManagement.newBuilder(true);
1222 if (addLocationInformation) {
1223 ciManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1224 }
1225 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1226 String name = parser.getAttributeLocalName(i);
1227 String ns = parser.getAttributeNamespace(i);
1228 String value = parser.getAttributeValue(i);
1229 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1230
1231 } else {
1232 checkUnknownAttribute(parser, name, tagName, strict);
1233 }
1234 }
1235 Set<String> parsed = new HashSet<>();
1236 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1237 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1238 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1239 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1240 Map<Object, InputLocation> locations = null;
1241 switch (childName) {
1242 case "system": {
1243 ciManagement.system(interpolatedTrimmed(nextText(parser, strict), "system"));
1244 break;
1245 }
1246 case "url": {
1247 ciManagement.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1248 break;
1249 }
1250 case "notifiers": {
1251 List<Notifier> notifiers = new ArrayList<>();
1252 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1253 if ("notifier".equals(parser.getLocalName())) {
1254 notifiers.add(parseNotifier(parser, strict, source));
1255 } else {
1256 checkUnknownElement(parser, strict);
1257 }
1258 }
1259 ciManagement.notifiers(notifiers);
1260 break;
1261 }
1262 default: {
1263 checkUnknownElement(parser, strict);
1264 break;
1265 }
1266 }
1267 if (addLocationInformation) {
1268 ciManagement.location(childName, new InputLocation(line, column, source, locations));
1269 }
1270 }
1271 return ciManagement.build();
1272 }
1273
1274 private Notifier parseNotifier(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1275 String tagName = parser.getLocalName();
1276 Notifier.Builder notifier = Notifier.newBuilder(true);
1277 if (addLocationInformation) {
1278 notifier.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1279 }
1280 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1281 String name = parser.getAttributeLocalName(i);
1282 String ns = parser.getAttributeNamespace(i);
1283 String value = parser.getAttributeValue(i);
1284 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1285
1286 } else {
1287 checkUnknownAttribute(parser, name, tagName, strict);
1288 }
1289 }
1290 Set<String> parsed = new HashSet<>();
1291 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1292 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1293 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1294 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1295 Map<Object, InputLocation> locations = null;
1296 switch (childName) {
1297 case "type": {
1298 notifier.type(interpolatedTrimmed(nextText(parser, strict), "type"));
1299 break;
1300 }
1301 case "sendOnError": {
1302 notifier.sendOnError(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnError"), "sendOnError", parser, true));
1303 break;
1304 }
1305 case "sendOnFailure": {
1306 notifier.sendOnFailure(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnFailure"), "sendOnFailure", parser, true));
1307 break;
1308 }
1309 case "sendOnSuccess": {
1310 notifier.sendOnSuccess(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnSuccess"), "sendOnSuccess", parser, true));
1311 break;
1312 }
1313 case "sendOnWarning": {
1314 notifier.sendOnWarning(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "sendOnWarning"), "sendOnWarning", parser, true));
1315 break;
1316 }
1317 case "address": {
1318 notifier.address(interpolatedTrimmed(nextText(parser, strict), "address"));
1319 break;
1320 }
1321 case "configuration": {
1322 Map<String, String> configuration = new LinkedHashMap<>();
1323 locations = new HashMap<>();
1324 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1325 String key = parser.getLocalName();
1326 String value = nextText(parser, strict).trim();
1327 if (addLocationInformation) {
1328 locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1329 }
1330 configuration.put(key, value);
1331 }
1332 notifier.configuration(configuration);
1333 break;
1334 }
1335 default: {
1336 checkUnknownElement(parser, strict);
1337 break;
1338 }
1339 }
1340 if (addLocationInformation) {
1341 notifier.location(childName, new InputLocation(line, column, source, locations));
1342 }
1343 }
1344 return notifier.build();
1345 }
1346
1347 private Contributor parseContributor(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1348 String tagName = parser.getLocalName();
1349 Contributor.Builder contributor = Contributor.newBuilder(true);
1350 if (addLocationInformation) {
1351 contributor.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1352 }
1353 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1354 String name = parser.getAttributeLocalName(i);
1355 String ns = parser.getAttributeNamespace(i);
1356 String value = parser.getAttributeValue(i);
1357 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1358
1359 } else {
1360 checkUnknownAttribute(parser, name, tagName, strict);
1361 }
1362 }
1363 Set<String> parsed = new HashSet<>();
1364 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1365 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1366 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1367 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1368 Map<Object, InputLocation> locations = null;
1369 switch (childName) {
1370 case "name": {
1371 contributor.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1372 break;
1373 }
1374 case "email": {
1375 contributor.email(interpolatedTrimmed(nextText(parser, strict), "email"));
1376 break;
1377 }
1378 case "url": {
1379 contributor.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1380 break;
1381 }
1382 case "organization": {
1383 contributor.organization(interpolatedTrimmed(nextText(parser, strict), "organization"));
1384 break;
1385 }
1386 case "organizationUrl": {
1387 contributor.organizationUrl(interpolatedTrimmed(nextText(parser, strict), "organizationUrl"));
1388 break;
1389 }
1390 case "roles": {
1391 List<String> roles = new ArrayList<>();
1392 locations = new HashMap<>();
1393 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1394 if ("role".equals(parser.getLocalName())) {
1395 if (addLocationInformation) {
1396 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1397 }
1398 roles.add(interpolatedTrimmed(nextText(parser, strict), "roles"));
1399 } else {
1400 checkUnknownElement(parser, strict);
1401 }
1402 }
1403 contributor.roles(roles);
1404 break;
1405 }
1406 case "timezone": {
1407 contributor.timezone(interpolatedTrimmed(nextText(parser, strict), "timezone"));
1408 break;
1409 }
1410 case "properties": {
1411 Map<String, String> properties = new LinkedHashMap<>();
1412 locations = new HashMap<>();
1413 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1414 String key = parser.getLocalName();
1415 String value = nextText(parser, strict).trim();
1416 if (addLocationInformation) {
1417 locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1418 }
1419 properties.put(key, value);
1420 }
1421 contributor.properties(properties);
1422 break;
1423 }
1424 default: {
1425 checkUnknownElement(parser, strict);
1426 break;
1427 }
1428 }
1429 if (addLocationInformation) {
1430 contributor.location(childName, new InputLocation(line, column, source, locations));
1431 }
1432 }
1433 return contributor.build();
1434 }
1435
1436 private Dependency parseDependency(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1437 String tagName = parser.getLocalName();
1438 Dependency.Builder dependency = Dependency.newBuilder(true);
1439 if (addLocationInformation) {
1440 dependency.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1441 }
1442 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1443 String name = parser.getAttributeLocalName(i);
1444 String ns = parser.getAttributeNamespace(i);
1445 String value = parser.getAttributeValue(i);
1446 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1447
1448 } else {
1449 checkUnknownAttribute(parser, name, tagName, strict);
1450 }
1451 }
1452 Set<String> parsed = new HashSet<>();
1453 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1454 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1455 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1456 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1457 Map<Object, InputLocation> locations = null;
1458 switch (childName) {
1459 case "groupId": {
1460 dependency.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
1461 break;
1462 }
1463 case "artifactId": {
1464 dependency.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
1465 break;
1466 }
1467 case "version": {
1468 dependency.version(interpolatedTrimmed(nextText(parser, strict), "version"));
1469 break;
1470 }
1471 case "type": {
1472 dependency.type(interpolatedTrimmed(nextText(parser, strict), "type"));
1473 break;
1474 }
1475 case "classifier": {
1476 dependency.classifier(interpolatedTrimmed(nextText(parser, strict), "classifier"));
1477 break;
1478 }
1479 case "scope": {
1480 dependency.scope(interpolatedTrimmed(nextText(parser, strict), "scope"));
1481 break;
1482 }
1483 case "systemPath": {
1484 dependency.systemPath(interpolatedTrimmed(nextText(parser, strict), "systemPath"));
1485 break;
1486 }
1487 case "exclusions": {
1488 List<Exclusion> exclusions = new ArrayList<>();
1489 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1490 if ("exclusion".equals(parser.getLocalName())) {
1491 exclusions.add(parseExclusion(parser, strict, source));
1492 } else {
1493 checkUnknownElement(parser, strict);
1494 }
1495 }
1496 dependency.exclusions(exclusions);
1497 break;
1498 }
1499 case "optional": {
1500 dependency.optional(interpolatedTrimmed(nextText(parser, strict), "optional"));
1501 break;
1502 }
1503 default: {
1504 checkUnknownElement(parser, strict);
1505 break;
1506 }
1507 }
1508 if (addLocationInformation) {
1509 dependency.location(childName, new InputLocation(line, column, source, locations));
1510 }
1511 }
1512 return dependency.build();
1513 }
1514
1515 private Developer parseDeveloper(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1516 String tagName = parser.getLocalName();
1517 Developer.Builder developer = Developer.newBuilder(true);
1518 if (addLocationInformation) {
1519 developer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1520 }
1521 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1522 String name = parser.getAttributeLocalName(i);
1523 String ns = parser.getAttributeNamespace(i);
1524 String value = parser.getAttributeValue(i);
1525 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1526
1527 } else {
1528 checkUnknownAttribute(parser, name, tagName, strict);
1529 }
1530 }
1531 Set<String> parsed = new HashSet<>();
1532 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1533 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1534 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1535 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1536 Map<Object, InputLocation> locations = null;
1537 switch (childName) {
1538 case "id": {
1539 developer.id(interpolatedTrimmed(nextText(parser, strict), "id"));
1540 break;
1541 }
1542 case "name": {
1543 developer.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1544 break;
1545 }
1546 case "email": {
1547 developer.email(interpolatedTrimmed(nextText(parser, strict), "email"));
1548 break;
1549 }
1550 case "url": {
1551 developer.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1552 break;
1553 }
1554 case "organization": {
1555 developer.organization(interpolatedTrimmed(nextText(parser, strict), "organization"));
1556 break;
1557 }
1558 case "organizationUrl": {
1559 developer.organizationUrl(interpolatedTrimmed(nextText(parser, strict), "organizationUrl"));
1560 break;
1561 }
1562 case "roles": {
1563 List<String> roles = new ArrayList<>();
1564 locations = new HashMap<>();
1565 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1566 if ("role".equals(parser.getLocalName())) {
1567 if (addLocationInformation) {
1568 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1569 }
1570 roles.add(interpolatedTrimmed(nextText(parser, strict), "roles"));
1571 } else {
1572 checkUnknownElement(parser, strict);
1573 }
1574 }
1575 developer.roles(roles);
1576 break;
1577 }
1578 case "timezone": {
1579 developer.timezone(interpolatedTrimmed(nextText(parser, strict), "timezone"));
1580 break;
1581 }
1582 case "properties": {
1583 Map<String, String> properties = new LinkedHashMap<>();
1584 locations = new HashMap<>();
1585 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1586 String key = parser.getLocalName();
1587 String value = nextText(parser, strict).trim();
1588 if (addLocationInformation) {
1589 locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1590 }
1591 properties.put(key, value);
1592 }
1593 developer.properties(properties);
1594 break;
1595 }
1596 default: {
1597 checkUnknownElement(parser, strict);
1598 break;
1599 }
1600 }
1601 if (addLocationInformation) {
1602 developer.location(childName, new InputLocation(line, column, source, locations));
1603 }
1604 }
1605 return developer.build();
1606 }
1607
1608 private Exclusion parseExclusion(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1609 String tagName = parser.getLocalName();
1610 Exclusion.Builder exclusion = Exclusion.newBuilder(true);
1611 if (addLocationInformation) {
1612 exclusion.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1613 }
1614 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1615 String name = parser.getAttributeLocalName(i);
1616 String ns = parser.getAttributeNamespace(i);
1617 String value = parser.getAttributeValue(i);
1618 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1619
1620 } else {
1621 checkUnknownAttribute(parser, name, tagName, strict);
1622 }
1623 }
1624 Set<String> parsed = new HashSet<>();
1625 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1626 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1627 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1628 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1629 Map<Object, InputLocation> locations = null;
1630 switch (childName) {
1631 case "groupId": {
1632 exclusion.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
1633 break;
1634 }
1635 case "artifactId": {
1636 exclusion.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
1637 break;
1638 }
1639 default: {
1640 checkUnknownElement(parser, strict);
1641 break;
1642 }
1643 }
1644 if (addLocationInformation) {
1645 exclusion.location(childName, new InputLocation(line, column, source, locations));
1646 }
1647 }
1648 return exclusion.build();
1649 }
1650
1651 private IssueManagement parseIssueManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1652 String tagName = parser.getLocalName();
1653 IssueManagement.Builder issueManagement = IssueManagement.newBuilder(true);
1654 if (addLocationInformation) {
1655 issueManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1656 }
1657 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1658 String name = parser.getAttributeLocalName(i);
1659 String ns = parser.getAttributeNamespace(i);
1660 String value = parser.getAttributeValue(i);
1661 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1662
1663 } else {
1664 checkUnknownAttribute(parser, name, tagName, strict);
1665 }
1666 }
1667 Set<String> parsed = new HashSet<>();
1668 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1669 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1670 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1671 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1672 Map<Object, InputLocation> locations = null;
1673 switch (childName) {
1674 case "system": {
1675 issueManagement.system(interpolatedTrimmed(nextText(parser, strict), "system"));
1676 break;
1677 }
1678 case "url": {
1679 issueManagement.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1680 break;
1681 }
1682 default: {
1683 checkUnknownElement(parser, strict);
1684 break;
1685 }
1686 }
1687 if (addLocationInformation) {
1688 issueManagement.location(childName, new InputLocation(line, column, source, locations));
1689 }
1690 }
1691 return issueManagement.build();
1692 }
1693
1694 private DistributionManagement parseDistributionManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1695 String tagName = parser.getLocalName();
1696 DistributionManagement.Builder distributionManagement = DistributionManagement.newBuilder(true);
1697 if (addLocationInformation) {
1698 distributionManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1699 }
1700 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1701 String name = parser.getAttributeLocalName(i);
1702 String ns = parser.getAttributeNamespace(i);
1703 String value = parser.getAttributeValue(i);
1704 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1705
1706 } else {
1707 checkUnknownAttribute(parser, name, tagName, strict);
1708 }
1709 }
1710 Set<String> parsed = new HashSet<>();
1711 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1712 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1713 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1714 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1715 Map<Object, InputLocation> locations = null;
1716 switch (childName) {
1717 case "repository": {
1718 distributionManagement.repository(parseDeploymentRepository(parser, strict, source));
1719 break;
1720 }
1721 case "snapshotRepository": {
1722 distributionManagement.snapshotRepository(parseDeploymentRepository(parser, strict, source));
1723 break;
1724 }
1725 case "site": {
1726 distributionManagement.site(parseSite(parser, strict, source));
1727 break;
1728 }
1729 case "downloadUrl": {
1730 distributionManagement.downloadUrl(interpolatedTrimmed(nextText(parser, strict), "downloadUrl"));
1731 break;
1732 }
1733 case "relocation": {
1734 distributionManagement.relocation(parseRelocation(parser, strict, source));
1735 break;
1736 }
1737 case "status": {
1738 distributionManagement.status(interpolatedTrimmed(nextText(parser, strict), "status"));
1739 break;
1740 }
1741 default: {
1742 checkUnknownElement(parser, strict);
1743 break;
1744 }
1745 }
1746 if (addLocationInformation) {
1747 distributionManagement.location(childName, new InputLocation(line, column, source, locations));
1748 }
1749 }
1750 return distributionManagement.build();
1751 }
1752
1753 private License parseLicense(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1754 String tagName = parser.getLocalName();
1755 License.Builder license = License.newBuilder(true);
1756 if (addLocationInformation) {
1757 license.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1758 }
1759 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1760 String name = parser.getAttributeLocalName(i);
1761 String ns = parser.getAttributeNamespace(i);
1762 String value = parser.getAttributeValue(i);
1763 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1764
1765 } else {
1766 checkUnknownAttribute(parser, name, tagName, strict);
1767 }
1768 }
1769 Set<String> parsed = new HashSet<>();
1770 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1771 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1772 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1773 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1774 Map<Object, InputLocation> locations = null;
1775 switch (childName) {
1776 case "name": {
1777 license.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1778 break;
1779 }
1780 case "url": {
1781 license.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1782 break;
1783 }
1784 case "distribution": {
1785 license.distribution(interpolatedTrimmed(nextText(parser, strict), "distribution"));
1786 break;
1787 }
1788 case "comments": {
1789 license.comments(interpolatedTrimmed(nextText(parser, strict), "comments"));
1790 break;
1791 }
1792 default: {
1793 checkUnknownElement(parser, strict);
1794 break;
1795 }
1796 }
1797 if (addLocationInformation) {
1798 license.location(childName, new InputLocation(line, column, source, locations));
1799 }
1800 }
1801 return license.build();
1802 }
1803
1804 private MailingList parseMailingList(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1805 String tagName = parser.getLocalName();
1806 MailingList.Builder mailingList = MailingList.newBuilder(true);
1807 if (addLocationInformation) {
1808 mailingList.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1809 }
1810 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1811 String name = parser.getAttributeLocalName(i);
1812 String ns = parser.getAttributeNamespace(i);
1813 String value = parser.getAttributeValue(i);
1814 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1815
1816 } else {
1817 checkUnknownAttribute(parser, name, tagName, strict);
1818 }
1819 }
1820 Set<String> parsed = new HashSet<>();
1821 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1822 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1823 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1824 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1825 Map<Object, InputLocation> locations = null;
1826 switch (childName) {
1827 case "name": {
1828 mailingList.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1829 break;
1830 }
1831 case "subscribe": {
1832 mailingList.subscribe(interpolatedTrimmed(nextText(parser, strict), "subscribe"));
1833 break;
1834 }
1835 case "unsubscribe": {
1836 mailingList.unsubscribe(interpolatedTrimmed(nextText(parser, strict), "unsubscribe"));
1837 break;
1838 }
1839 case "post": {
1840 mailingList.post(interpolatedTrimmed(nextText(parser, strict), "post"));
1841 break;
1842 }
1843 case "archive": {
1844 mailingList.archive(interpolatedTrimmed(nextText(parser, strict), "archive"));
1845 break;
1846 }
1847 case "otherArchives": {
1848 List<String> otherArchives = new ArrayList<>();
1849 locations = new HashMap<>();
1850 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1851 if ("otherArchive".equals(parser.getLocalName())) {
1852 if (addLocationInformation) {
1853 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1854 }
1855 otherArchives.add(interpolatedTrimmed(nextText(parser, strict), "otherArchives"));
1856 } else {
1857 checkUnknownElement(parser, strict);
1858 }
1859 }
1860 mailingList.otherArchives(otherArchives);
1861 break;
1862 }
1863 default: {
1864 checkUnknownElement(parser, strict);
1865 break;
1866 }
1867 }
1868 if (addLocationInformation) {
1869 mailingList.location(childName, new InputLocation(line, column, source, locations));
1870 }
1871 }
1872 return mailingList.build();
1873 }
1874
1875 private Organization parseOrganization(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1876 String tagName = parser.getLocalName();
1877 Organization.Builder organization = Organization.newBuilder(true);
1878 if (addLocationInformation) {
1879 organization.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1880 }
1881 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1882 String name = parser.getAttributeLocalName(i);
1883 String ns = parser.getAttributeNamespace(i);
1884 String value = parser.getAttributeValue(i);
1885 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1886
1887 } else {
1888 checkUnknownAttribute(parser, name, tagName, strict);
1889 }
1890 }
1891 Set<String> parsed = new HashSet<>();
1892 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1893 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1894 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1895 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1896 Map<Object, InputLocation> locations = null;
1897 switch (childName) {
1898 case "name": {
1899 organization.name(interpolatedTrimmed(nextText(parser, strict), "name"));
1900 break;
1901 }
1902 case "url": {
1903 organization.url(interpolatedTrimmed(nextText(parser, strict), "url"));
1904 break;
1905 }
1906 default: {
1907 checkUnknownElement(parser, strict);
1908 break;
1909 }
1910 }
1911 if (addLocationInformation) {
1912 organization.location(childName, new InputLocation(line, column, source, locations));
1913 }
1914 }
1915 return organization.build();
1916 }
1917
1918 private PatternSet parsePatternSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1919 String tagName = parser.getLocalName();
1920 PatternSet.Builder patternSet = PatternSet.newBuilder(true);
1921 if (addLocationInformation) {
1922 patternSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1923 }
1924 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1925 String name = parser.getAttributeLocalName(i);
1926 String ns = parser.getAttributeNamespace(i);
1927 String value = parser.getAttributeValue(i);
1928 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1929
1930 } else {
1931 checkUnknownAttribute(parser, name, tagName, strict);
1932 }
1933 }
1934 Set<String> parsed = new HashSet<>();
1935 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
1936 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
1937 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
1938 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
1939 Map<Object, InputLocation> locations = null;
1940 switch (childName) {
1941 case "includes": {
1942 List<String> includes = new ArrayList<>();
1943 locations = new HashMap<>();
1944 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1945 if ("include".equals(parser.getLocalName())) {
1946 if (addLocationInformation) {
1947 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1948 }
1949 includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
1950 } else {
1951 checkUnknownElement(parser, strict);
1952 }
1953 }
1954 patternSet.includes(includes);
1955 break;
1956 }
1957 case "excludes": {
1958 List<String> excludes = new ArrayList<>();
1959 locations = new HashMap<>();
1960 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
1961 if ("exclude".equals(parser.getLocalName())) {
1962 if (addLocationInformation) {
1963 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1964 }
1965 excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
1966 } else {
1967 checkUnknownElement(parser, strict);
1968 }
1969 }
1970 patternSet.excludes(excludes);
1971 break;
1972 }
1973 default: {
1974 checkUnknownElement(parser, strict);
1975 break;
1976 }
1977 }
1978 if (addLocationInformation) {
1979 patternSet.location(childName, new InputLocation(line, column, source, locations));
1980 }
1981 }
1982 return patternSet.build();
1983 }
1984
1985 private Parent parseParent(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
1986 String tagName = parser.getLocalName();
1987 Parent.Builder parent = Parent.newBuilder(true);
1988 if (addLocationInformation) {
1989 parent.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
1990 }
1991 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
1992 String name = parser.getAttributeLocalName(i);
1993 String ns = parser.getAttributeNamespace(i);
1994 String value = parser.getAttributeValue(i);
1995 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
1996
1997 } else {
1998 checkUnknownAttribute(parser, name, tagName, strict);
1999 }
2000 }
2001 Set<String> parsed = new HashSet<>();
2002 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2003 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2004 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2005 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2006 Map<Object, InputLocation> locations = null;
2007 switch (childName) {
2008 case "groupId": {
2009 parent.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
2010 break;
2011 }
2012 case "artifactId": {
2013 parent.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
2014 break;
2015 }
2016 case "version": {
2017 parent.version(interpolatedTrimmed(nextText(parser, strict), "version"));
2018 break;
2019 }
2020 case "relativePath": {
2021 parent.relativePath(interpolatedTrimmed(nextText(parser, strict), "relativePath"));
2022 break;
2023 }
2024 default: {
2025 checkUnknownElement(parser, strict);
2026 break;
2027 }
2028 }
2029 if (addLocationInformation) {
2030 parent.location(childName, new InputLocation(line, column, source, locations));
2031 }
2032 }
2033 return parent.build();
2034 }
2035
2036 private Scm parseScm(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2037 String tagName = parser.getLocalName();
2038 Scm.Builder scm = Scm.newBuilder(true);
2039 if (addLocationInformation) {
2040 scm.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2041 }
2042 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2043 String name = parser.getAttributeLocalName(i);
2044 String ns = parser.getAttributeNamespace(i);
2045 String value = parser.getAttributeValue(i);
2046 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2047
2048 } else if ("child.scm.connection.inherit.append.path".equals(name)) {
2049 if (addLocationInformation) {
2050 scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2051 }
2052 scm.childScmConnectionInheritAppendPath(interpolatedTrimmed(value, "child.scm.connection.inherit.append.path"));
2053 } else if ("child.scm.developerConnection.inherit.append.path".equals(name)) {
2054 if (addLocationInformation) {
2055 scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2056 }
2057 scm.childScmDeveloperConnectionInheritAppendPath(interpolatedTrimmed(value, "child.scm.developerConnection.inherit.append.path"));
2058 } else if ("child.scm.url.inherit.append.path".equals(name)) {
2059 if (addLocationInformation) {
2060 scm.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2061 }
2062 scm.childScmUrlInheritAppendPath(interpolatedTrimmed(value, "child.scm.url.inherit.append.path"));
2063 } else {
2064 checkUnknownAttribute(parser, name, tagName, strict);
2065 }
2066 }
2067 Set<String> parsed = new HashSet<>();
2068 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2069 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2070 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2071 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2072 Map<Object, InputLocation> locations = null;
2073 switch (childName) {
2074 case "connection": {
2075 scm.connection(interpolatedTrimmed(nextText(parser, strict), "connection"));
2076 break;
2077 }
2078 case "developerConnection": {
2079 scm.developerConnection(interpolatedTrimmed(nextText(parser, strict), "developerConnection"));
2080 break;
2081 }
2082 case "tag": {
2083 scm.tag(interpolatedTrimmed(nextText(parser, strict), "tag"));
2084 break;
2085 }
2086 case "url": {
2087 scm.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2088 break;
2089 }
2090 default: {
2091 checkUnknownElement(parser, strict);
2092 break;
2093 }
2094 }
2095 if (addLocationInformation) {
2096 scm.location(childName, new InputLocation(line, column, source, locations));
2097 }
2098 }
2099 return scm.build();
2100 }
2101
2102 private FileSet parseFileSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2103 String tagName = parser.getLocalName();
2104 FileSet.Builder fileSet = FileSet.newBuilder(true);
2105 if (addLocationInformation) {
2106 fileSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2107 }
2108 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2109 String name = parser.getAttributeLocalName(i);
2110 String ns = parser.getAttributeNamespace(i);
2111 String value = parser.getAttributeValue(i);
2112 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2113
2114 } else {
2115 checkUnknownAttribute(parser, name, tagName, strict);
2116 }
2117 }
2118 Set<String> parsed = new HashSet<>();
2119 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2120 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2121 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2122 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2123 Map<Object, InputLocation> locations = null;
2124 switch (childName) {
2125 case "directory": {
2126 fileSet.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
2127 break;
2128 }
2129 case "includes": {
2130 List<String> includes = new ArrayList<>();
2131 locations = new HashMap<>();
2132 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2133 if ("include".equals(parser.getLocalName())) {
2134 if (addLocationInformation) {
2135 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2136 }
2137 includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
2138 } else {
2139 checkUnknownElement(parser, strict);
2140 }
2141 }
2142 fileSet.includes(includes);
2143 break;
2144 }
2145 case "excludes": {
2146 List<String> excludes = new ArrayList<>();
2147 locations = new HashMap<>();
2148 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2149 if ("exclude".equals(parser.getLocalName())) {
2150 if (addLocationInformation) {
2151 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2152 }
2153 excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
2154 } else {
2155 checkUnknownElement(parser, strict);
2156 }
2157 }
2158 fileSet.excludes(excludes);
2159 break;
2160 }
2161 default: {
2162 checkUnknownElement(parser, strict);
2163 break;
2164 }
2165 }
2166 if (addLocationInformation) {
2167 fileSet.location(childName, new InputLocation(line, column, source, locations));
2168 }
2169 }
2170 return fileSet.build();
2171 }
2172
2173 private Resource parseResource(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2174 String tagName = parser.getLocalName();
2175 Resource.Builder resource = Resource.newBuilder(true);
2176 if (addLocationInformation) {
2177 resource.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2178 }
2179 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2180 String name = parser.getAttributeLocalName(i);
2181 String ns = parser.getAttributeNamespace(i);
2182 String value = parser.getAttributeValue(i);
2183 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2184
2185 } else {
2186 checkUnknownAttribute(parser, name, tagName, strict);
2187 }
2188 }
2189 Set<String> parsed = new HashSet<>();
2190 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2191 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2192 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2193 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2194 Map<Object, InputLocation> locations = null;
2195 switch (childName) {
2196 case "targetPath": {
2197 resource.targetPath(interpolatedTrimmed(nextText(parser, strict), "targetPath"));
2198 break;
2199 }
2200 case "filtering": {
2201 resource.filtering(interpolatedTrimmed(nextText(parser, strict), "filtering"));
2202 break;
2203 }
2204 case "directory": {
2205 resource.directory(interpolatedTrimmed(nextText(parser, strict), "directory"));
2206 break;
2207 }
2208 case "includes": {
2209 List<String> includes = new ArrayList<>();
2210 locations = new HashMap<>();
2211 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2212 if ("include".equals(parser.getLocalName())) {
2213 if (addLocationInformation) {
2214 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2215 }
2216 includes.add(interpolatedTrimmed(nextText(parser, strict), "includes"));
2217 } else {
2218 checkUnknownElement(parser, strict);
2219 }
2220 }
2221 resource.includes(includes);
2222 break;
2223 }
2224 case "excludes": {
2225 List<String> excludes = new ArrayList<>();
2226 locations = new HashMap<>();
2227 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2228 if ("exclude".equals(parser.getLocalName())) {
2229 if (addLocationInformation) {
2230 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2231 }
2232 excludes.add(interpolatedTrimmed(nextText(parser, strict), "excludes"));
2233 } else {
2234 checkUnknownElement(parser, strict);
2235 }
2236 }
2237 resource.excludes(excludes);
2238 break;
2239 }
2240 default: {
2241 checkUnknownElement(parser, strict);
2242 break;
2243 }
2244 }
2245 if (addLocationInformation) {
2246 resource.location(childName, new InputLocation(line, column, source, locations));
2247 }
2248 }
2249 return resource.build();
2250 }
2251
2252 private RepositoryBase parseRepositoryBase(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2253 String tagName = parser.getLocalName();
2254 RepositoryBase.Builder repositoryBase = RepositoryBase.newBuilder(true);
2255 if (addLocationInformation) {
2256 repositoryBase.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2257 }
2258 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2259 String name = parser.getAttributeLocalName(i);
2260 String ns = parser.getAttributeNamespace(i);
2261 String value = parser.getAttributeValue(i);
2262 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2263
2264 } else {
2265 checkUnknownAttribute(parser, name, tagName, strict);
2266 }
2267 }
2268 Set<String> parsed = new HashSet<>();
2269 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2270 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2271 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2272 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2273 Map<Object, InputLocation> locations = null;
2274 switch (childName) {
2275 case "id": {
2276 repositoryBase.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2277 break;
2278 }
2279 case "name": {
2280 repositoryBase.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2281 break;
2282 }
2283 case "url": {
2284 repositoryBase.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2285 break;
2286 }
2287 case "layout": {
2288 repositoryBase.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
2289 break;
2290 }
2291 default: {
2292 checkUnknownElement(parser, strict);
2293 break;
2294 }
2295 }
2296 if (addLocationInformation) {
2297 repositoryBase.location(childName, new InputLocation(line, column, source, locations));
2298 }
2299 }
2300 return repositoryBase.build();
2301 }
2302
2303 private Repository parseRepository(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2304 String tagName = parser.getLocalName();
2305 Repository.Builder repository = Repository.newBuilder(true);
2306 if (addLocationInformation) {
2307 repository.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2308 }
2309 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2310 String name = parser.getAttributeLocalName(i);
2311 String ns = parser.getAttributeNamespace(i);
2312 String value = parser.getAttributeValue(i);
2313 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2314
2315 } else {
2316 checkUnknownAttribute(parser, name, tagName, strict);
2317 }
2318 }
2319 Set<String> parsed = new HashSet<>();
2320 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2321 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2322 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2323 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2324 Map<Object, InputLocation> locations = null;
2325 switch (childName) {
2326 case "releases": {
2327 repository.releases(parseRepositoryPolicy(parser, strict, source));
2328 break;
2329 }
2330 case "snapshots": {
2331 repository.snapshots(parseRepositoryPolicy(parser, strict, source));
2332 break;
2333 }
2334 case "id": {
2335 repository.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2336 break;
2337 }
2338 case "name": {
2339 repository.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2340 break;
2341 }
2342 case "url": {
2343 repository.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2344 break;
2345 }
2346 case "layout": {
2347 repository.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
2348 break;
2349 }
2350 default: {
2351 checkUnknownElement(parser, strict);
2352 break;
2353 }
2354 }
2355 if (addLocationInformation) {
2356 repository.location(childName, new InputLocation(line, column, source, locations));
2357 }
2358 }
2359 return repository.build();
2360 }
2361
2362 private DeploymentRepository parseDeploymentRepository(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2363 String tagName = parser.getLocalName();
2364 DeploymentRepository.Builder deploymentRepository = DeploymentRepository.newBuilder(true);
2365 if (addLocationInformation) {
2366 deploymentRepository.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2367 }
2368 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2369 String name = parser.getAttributeLocalName(i);
2370 String ns = parser.getAttributeNamespace(i);
2371 String value = parser.getAttributeValue(i);
2372 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2373
2374 } else {
2375 checkUnknownAttribute(parser, name, tagName, strict);
2376 }
2377 }
2378 Set<String> parsed = new HashSet<>();
2379 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2380 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2381 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2382 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2383 Map<Object, InputLocation> locations = null;
2384 switch (childName) {
2385 case "uniqueVersion": {
2386 deploymentRepository.uniqueVersion(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "uniqueVersion"), "uniqueVersion", parser, true));
2387 break;
2388 }
2389 case "releases": {
2390 deploymentRepository.releases(parseRepositoryPolicy(parser, strict, source));
2391 break;
2392 }
2393 case "snapshots": {
2394 deploymentRepository.snapshots(parseRepositoryPolicy(parser, strict, source));
2395 break;
2396 }
2397 case "id": {
2398 deploymentRepository.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2399 break;
2400 }
2401 case "name": {
2402 deploymentRepository.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2403 break;
2404 }
2405 case "url": {
2406 deploymentRepository.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2407 break;
2408 }
2409 case "layout": {
2410 deploymentRepository.layout(interpolatedTrimmed(nextText(parser, strict), "layout"));
2411 break;
2412 }
2413 default: {
2414 checkUnknownElement(parser, strict);
2415 break;
2416 }
2417 }
2418 if (addLocationInformation) {
2419 deploymentRepository.location(childName, new InputLocation(line, column, source, locations));
2420 }
2421 }
2422 return deploymentRepository.build();
2423 }
2424
2425 private RepositoryPolicy parseRepositoryPolicy(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2426 String tagName = parser.getLocalName();
2427 RepositoryPolicy.Builder repositoryPolicy = RepositoryPolicy.newBuilder(true);
2428 if (addLocationInformation) {
2429 repositoryPolicy.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2430 }
2431 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2432 String name = parser.getAttributeLocalName(i);
2433 String ns = parser.getAttributeNamespace(i);
2434 String value = parser.getAttributeValue(i);
2435 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2436
2437 } else {
2438 checkUnknownAttribute(parser, name, tagName, strict);
2439 }
2440 }
2441 Set<String> parsed = new HashSet<>();
2442 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2443 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2444 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2445 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2446 Map<Object, InputLocation> locations = null;
2447 switch (childName) {
2448 case "enabled": {
2449 repositoryPolicy.enabled(interpolatedTrimmed(nextText(parser, strict), "enabled"));
2450 break;
2451 }
2452 case "updatePolicy": {
2453 repositoryPolicy.updatePolicy(interpolatedTrimmed(nextText(parser, strict), "updatePolicy"));
2454 break;
2455 }
2456 case "checksumPolicy": {
2457 repositoryPolicy.checksumPolicy(interpolatedTrimmed(nextText(parser, strict), "checksumPolicy"));
2458 break;
2459 }
2460 default: {
2461 checkUnknownElement(parser, strict);
2462 break;
2463 }
2464 }
2465 if (addLocationInformation) {
2466 repositoryPolicy.location(childName, new InputLocation(line, column, source, locations));
2467 }
2468 }
2469 return repositoryPolicy.build();
2470 }
2471
2472 private Site parseSite(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2473 String tagName = parser.getLocalName();
2474 Site.Builder site = Site.newBuilder(true);
2475 if (addLocationInformation) {
2476 site.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2477 }
2478 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2479 String name = parser.getAttributeLocalName(i);
2480 String ns = parser.getAttributeNamespace(i);
2481 String value = parser.getAttributeValue(i);
2482 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2483
2484 } else if ("child.site.url.inherit.append.path".equals(name)) {
2485 if (addLocationInformation) {
2486 site.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2487 }
2488 site.childSiteUrlInheritAppendPath(interpolatedTrimmed(value, "child.site.url.inherit.append.path"));
2489 } else {
2490 checkUnknownAttribute(parser, name, tagName, strict);
2491 }
2492 }
2493 Set<String> parsed = new HashSet<>();
2494 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2495 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2496 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2497 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2498 Map<Object, InputLocation> locations = null;
2499 switch (childName) {
2500 case "id": {
2501 site.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2502 break;
2503 }
2504 case "name": {
2505 site.name(interpolatedTrimmed(nextText(parser, strict), "name"));
2506 break;
2507 }
2508 case "url": {
2509 site.url(interpolatedTrimmed(nextText(parser, strict), "url"));
2510 break;
2511 }
2512 default: {
2513 checkUnknownElement(parser, strict);
2514 break;
2515 }
2516 }
2517 if (addLocationInformation) {
2518 site.location(childName, new InputLocation(line, column, source, locations));
2519 }
2520 }
2521 return site.build();
2522 }
2523
2524 private ConfigurationContainer parseConfigurationContainer(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2525 String tagName = parser.getLocalName();
2526 ConfigurationContainer.Builder configurationContainer = ConfigurationContainer.newBuilder(true);
2527 if (addLocationInformation) {
2528 configurationContainer.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2529 }
2530 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2531 String name = parser.getAttributeLocalName(i);
2532 String ns = parser.getAttributeNamespace(i);
2533 String value = parser.getAttributeValue(i);
2534 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2535
2536 } else {
2537 checkUnknownAttribute(parser, name, tagName, strict);
2538 }
2539 }
2540 Set<String> parsed = new HashSet<>();
2541 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2542 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2543 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2544 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2545 Map<Object, InputLocation> locations = null;
2546 switch (childName) {
2547 case "inherited": {
2548 configurationContainer.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
2549 break;
2550 }
2551 case "configuration": {
2552 configurationContainer.configuration(buildXmlNode(parser, source));
2553 break;
2554 }
2555 default: {
2556 checkUnknownElement(parser, strict);
2557 break;
2558 }
2559 }
2560 if (addLocationInformation) {
2561 configurationContainer.location(childName, new InputLocation(line, column, source, locations));
2562 }
2563 }
2564 return configurationContainer.build();
2565 }
2566
2567 private Plugin parsePlugin(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2568 String tagName = parser.getLocalName();
2569 Plugin.Builder plugin = Plugin.newBuilder(true);
2570 if (addLocationInformation) {
2571 plugin.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2572 }
2573 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2574 String name = parser.getAttributeLocalName(i);
2575 String ns = parser.getAttributeNamespace(i);
2576 String value = parser.getAttributeValue(i);
2577 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2578
2579 } else {
2580 checkUnknownAttribute(parser, name, tagName, strict);
2581 }
2582 }
2583 Set<String> parsed = new HashSet<>();
2584 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2585 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2586 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2587 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2588 Map<Object, InputLocation> locations = null;
2589 switch (childName) {
2590 case "groupId": {
2591 plugin.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
2592 break;
2593 }
2594 case "artifactId": {
2595 plugin.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
2596 break;
2597 }
2598 case "version": {
2599 plugin.version(interpolatedTrimmed(nextText(parser, strict), "version"));
2600 break;
2601 }
2602 case "extensions": {
2603 plugin.extensions(interpolatedTrimmed(nextText(parser, strict), "extensions"));
2604 break;
2605 }
2606 case "executions": {
2607 List<PluginExecution> executions = new ArrayList<>();
2608 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2609 if ("execution".equals(parser.getLocalName())) {
2610 executions.add(parsePluginExecution(parser, strict, source));
2611 } else {
2612 checkUnknownElement(parser, strict);
2613 }
2614 }
2615 plugin.executions(executions);
2616 break;
2617 }
2618 case "dependencies": {
2619 List<Dependency> dependencies = new ArrayList<>();
2620 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2621 if ("dependency".equals(parser.getLocalName())) {
2622 dependencies.add(parseDependency(parser, strict, source));
2623 } else {
2624 checkUnknownElement(parser, strict);
2625 }
2626 }
2627 plugin.dependencies(dependencies);
2628 break;
2629 }
2630 case "inherited": {
2631 plugin.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
2632 break;
2633 }
2634 case "configuration": {
2635 plugin.configuration(buildXmlNode(parser, source));
2636 break;
2637 }
2638 default: {
2639 checkUnknownElement(parser, strict);
2640 break;
2641 }
2642 }
2643 if (addLocationInformation) {
2644 plugin.location(childName, new InputLocation(line, column, source, locations));
2645 }
2646 }
2647 return plugin.build();
2648 }
2649
2650 private PluginExecution parsePluginExecution(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2651 String tagName = parser.getLocalName();
2652 PluginExecution.Builder pluginExecution = PluginExecution.newBuilder(true);
2653 if (addLocationInformation) {
2654 pluginExecution.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2655 }
2656 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2657 String name = parser.getAttributeLocalName(i);
2658 String ns = parser.getAttributeNamespace(i);
2659 String value = parser.getAttributeValue(i);
2660 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2661
2662 } else {
2663 checkUnknownAttribute(parser, name, tagName, strict);
2664 }
2665 }
2666 Set<String> parsed = new HashSet<>();
2667 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2668 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2669 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2670 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2671 Map<Object, InputLocation> locations = null;
2672 switch (childName) {
2673 case "id": {
2674 pluginExecution.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2675 break;
2676 }
2677 case "phase": {
2678 pluginExecution.phase(interpolatedTrimmed(nextText(parser, strict), "phase"));
2679 break;
2680 }
2681 case "goals": {
2682 List<String> goals = new ArrayList<>();
2683 locations = new HashMap<>();
2684 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2685 if ("goal".equals(parser.getLocalName())) {
2686 if (addLocationInformation) {
2687 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2688 }
2689 goals.add(interpolatedTrimmed(nextText(parser, strict), "goals"));
2690 } else {
2691 checkUnknownElement(parser, strict);
2692 }
2693 }
2694 pluginExecution.goals(goals);
2695 break;
2696 }
2697 case "inherited": {
2698 pluginExecution.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
2699 break;
2700 }
2701 case "configuration": {
2702 pluginExecution.configuration(buildXmlNode(parser, source));
2703 break;
2704 }
2705 default: {
2706 checkUnknownElement(parser, strict);
2707 break;
2708 }
2709 }
2710 if (addLocationInformation) {
2711 pluginExecution.location(childName, new InputLocation(line, column, source, locations));
2712 }
2713 }
2714 return pluginExecution.build();
2715 }
2716
2717 private DependencyManagement parseDependencyManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2718 String tagName = parser.getLocalName();
2719 DependencyManagement.Builder dependencyManagement = DependencyManagement.newBuilder(true);
2720 if (addLocationInformation) {
2721 dependencyManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2722 }
2723 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2724 String name = parser.getAttributeLocalName(i);
2725 String ns = parser.getAttributeNamespace(i);
2726 String value = parser.getAttributeValue(i);
2727 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2728
2729 } else {
2730 checkUnknownAttribute(parser, name, tagName, strict);
2731 }
2732 }
2733 Set<String> parsed = new HashSet<>();
2734 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2735 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2736 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2737 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2738 Map<Object, InputLocation> locations = null;
2739 switch (childName) {
2740 case "dependencies": {
2741 List<Dependency> dependencies = new ArrayList<>();
2742 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2743 if ("dependency".equals(parser.getLocalName())) {
2744 dependencies.add(parseDependency(parser, strict, source));
2745 } else {
2746 checkUnknownElement(parser, strict);
2747 }
2748 }
2749 dependencyManagement.dependencies(dependencies);
2750 break;
2751 }
2752 default: {
2753 checkUnknownElement(parser, strict);
2754 break;
2755 }
2756 }
2757 if (addLocationInformation) {
2758 dependencyManagement.location(childName, new InputLocation(line, column, source, locations));
2759 }
2760 }
2761 return dependencyManagement.build();
2762 }
2763
2764 private PluginManagement parsePluginManagement(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2765 String tagName = parser.getLocalName();
2766 PluginManagement.Builder pluginManagement = PluginManagement.newBuilder(true);
2767 if (addLocationInformation) {
2768 pluginManagement.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2769 }
2770 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2771 String name = parser.getAttributeLocalName(i);
2772 String ns = parser.getAttributeNamespace(i);
2773 String value = parser.getAttributeValue(i);
2774 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2775
2776 } else {
2777 checkUnknownAttribute(parser, name, tagName, strict);
2778 }
2779 }
2780 Set<String> parsed = new HashSet<>();
2781 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2782 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2783 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2784 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2785 Map<Object, InputLocation> locations = null;
2786 switch (childName) {
2787 case "plugins": {
2788 List<Plugin> plugins = new ArrayList<>();
2789 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2790 if ("plugin".equals(parser.getLocalName())) {
2791 plugins.add(parsePlugin(parser, strict, source));
2792 } else {
2793 checkUnknownElement(parser, strict);
2794 }
2795 }
2796 pluginManagement.plugins(plugins);
2797 break;
2798 }
2799 default: {
2800 checkUnknownElement(parser, strict);
2801 break;
2802 }
2803 }
2804 if (addLocationInformation) {
2805 pluginManagement.location(childName, new InputLocation(line, column, source, locations));
2806 }
2807 }
2808 return pluginManagement.build();
2809 }
2810
2811 private Reporting parseReporting(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2812 String tagName = parser.getLocalName();
2813 Reporting.Builder reporting = Reporting.newBuilder(true);
2814 if (addLocationInformation) {
2815 reporting.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2816 }
2817 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2818 String name = parser.getAttributeLocalName(i);
2819 String ns = parser.getAttributeNamespace(i);
2820 String value = parser.getAttributeValue(i);
2821 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2822
2823 } else {
2824 checkUnknownAttribute(parser, name, tagName, strict);
2825 }
2826 }
2827 Set<String> parsed = new HashSet<>();
2828 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2829 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2830 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2831 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2832 Map<Object, InputLocation> locations = null;
2833 switch (childName) {
2834 case "excludeDefaults": {
2835 reporting.excludeDefaults(interpolatedTrimmed(nextText(parser, strict), "excludeDefaults"));
2836 break;
2837 }
2838 case "outputDirectory": {
2839 reporting.outputDirectory(interpolatedTrimmed(nextText(parser, strict), "outputDirectory"));
2840 break;
2841 }
2842 case "plugins": {
2843 List<ReportPlugin> plugins = new ArrayList<>();
2844 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2845 if ("plugin".equals(parser.getLocalName())) {
2846 plugins.add(parseReportPlugin(parser, strict, source));
2847 } else {
2848 checkUnknownElement(parser, strict);
2849 }
2850 }
2851 reporting.plugins(plugins);
2852 break;
2853 }
2854 default: {
2855 checkUnknownElement(parser, strict);
2856 break;
2857 }
2858 }
2859 if (addLocationInformation) {
2860 reporting.location(childName, new InputLocation(line, column, source, locations));
2861 }
2862 }
2863 return reporting.build();
2864 }
2865
2866 private Profile parseProfile(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
2867 String tagName = parser.getLocalName();
2868 Profile.Builder profile = Profile.newBuilder(true);
2869 if (addLocationInformation) {
2870 profile.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2871 }
2872 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
2873 String name = parser.getAttributeLocalName(i);
2874 String ns = parser.getAttributeNamespace(i);
2875 String value = parser.getAttributeValue(i);
2876 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
2877
2878 } else {
2879 checkUnknownAttribute(parser, name, tagName, strict);
2880 }
2881 }
2882 Set<String> parsed = new HashSet<>();
2883 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
2884 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
2885 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
2886 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
2887 Map<Object, InputLocation> locations = null;
2888 switch (childName) {
2889 case "id": {
2890 profile.id(interpolatedTrimmed(nextText(parser, strict), "id"));
2891 break;
2892 }
2893 case "activation": {
2894 profile.activation(parseActivation(parser, strict, source));
2895 break;
2896 }
2897 case "build": {
2898 profile.build(parseBuildBase(parser, strict, source));
2899 break;
2900 }
2901 case "modules": {
2902 List<String> modules = new ArrayList<>();
2903 locations = new HashMap<>();
2904 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2905 if ("module".equals(parser.getLocalName())) {
2906 if (addLocationInformation) {
2907 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2908 }
2909 modules.add(interpolatedTrimmed(nextText(parser, strict), "modules"));
2910 } else {
2911 checkUnknownElement(parser, strict);
2912 }
2913 }
2914 profile.modules(modules);
2915 break;
2916 }
2917 case "subprojects": {
2918 List<String> subprojects = new ArrayList<>();
2919 locations = new HashMap<>();
2920 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2921 if ("subproject".equals(parser.getLocalName())) {
2922 if (addLocationInformation) {
2923 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2924 }
2925 subprojects.add(interpolatedTrimmed(nextText(parser, strict), "subprojects"));
2926 } else {
2927 checkUnknownElement(parser, strict);
2928 }
2929 }
2930 profile.subprojects(subprojects);
2931 break;
2932 }
2933 case "distributionManagement": {
2934 profile.distributionManagement(parseDistributionManagement(parser, strict, source));
2935 break;
2936 }
2937 case "properties": {
2938 Map<String, String> properties = new LinkedHashMap<>();
2939 locations = new HashMap<>();
2940 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2941 String key = parser.getLocalName();
2942 String value = nextText(parser, strict).trim();
2943 if (addLocationInformation) {
2944 locations.put(key, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
2945 }
2946 properties.put(key, value);
2947 }
2948 profile.properties(properties);
2949 break;
2950 }
2951 case "dependencyManagement": {
2952 profile.dependencyManagement(parseDependencyManagement(parser, strict, source));
2953 break;
2954 }
2955 case "dependencies": {
2956 List<Dependency> dependencies = new ArrayList<>();
2957 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2958 if ("dependency".equals(parser.getLocalName())) {
2959 dependencies.add(parseDependency(parser, strict, source));
2960 } else {
2961 checkUnknownElement(parser, strict);
2962 }
2963 }
2964 profile.dependencies(dependencies);
2965 break;
2966 }
2967 case "repositories": {
2968 List<Repository> repositories = new ArrayList<>();
2969 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2970 if ("repository".equals(parser.getLocalName())) {
2971 repositories.add(parseRepository(parser, strict, source));
2972 } else {
2973 checkUnknownElement(parser, strict);
2974 }
2975 }
2976 profile.repositories(repositories);
2977 break;
2978 }
2979 case "pluginRepositories": {
2980 List<Repository> pluginRepositories = new ArrayList<>();
2981 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
2982 if ("pluginRepository".equals(parser.getLocalName())) {
2983 pluginRepositories.add(parseRepository(parser, strict, source));
2984 } else {
2985 checkUnknownElement(parser, strict);
2986 }
2987 }
2988 profile.pluginRepositories(pluginRepositories);
2989 break;
2990 }
2991 case "reporting": {
2992 profile.reporting(parseReporting(parser, strict, source));
2993 break;
2994 }
2995 default: {
2996 checkUnknownElement(parser, strict);
2997 break;
2998 }
2999 }
3000 if (addLocationInformation) {
3001 profile.location(childName, new InputLocation(line, column, source, locations));
3002 }
3003 }
3004 return profile.build();
3005 }
3006
3007 private Activation parseActivation(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3008 String tagName = parser.getLocalName();
3009 Activation.Builder activation = Activation.newBuilder(true);
3010 if (addLocationInformation) {
3011 activation.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3012 }
3013 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3014 String name = parser.getAttributeLocalName(i);
3015 String ns = parser.getAttributeNamespace(i);
3016 String value = parser.getAttributeValue(i);
3017 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3018
3019 } else {
3020 checkUnknownAttribute(parser, name, tagName, strict);
3021 }
3022 }
3023 Set<String> parsed = new HashSet<>();
3024 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3025 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3026 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3027 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3028 Map<Object, InputLocation> locations = null;
3029 switch (childName) {
3030 case "activeByDefault": {
3031 activation.activeByDefault(getBooleanValue(interpolatedTrimmed(nextText(parser, strict), "activeByDefault"), "activeByDefault", parser, false));
3032 break;
3033 }
3034 case "jdk": {
3035 activation.jdk(interpolatedTrimmed(nextText(parser, strict), "jdk"));
3036 break;
3037 }
3038 case "os": {
3039 activation.os(parseActivationOS(parser, strict, source));
3040 break;
3041 }
3042 case "property": {
3043 activation.property(parseActivationProperty(parser, strict, source));
3044 break;
3045 }
3046 case "file": {
3047 activation.file(parseActivationFile(parser, strict, source));
3048 break;
3049 }
3050 case "packaging": {
3051 activation.packaging(interpolatedTrimmed(nextText(parser, strict), "packaging"));
3052 break;
3053 }
3054 case "condition": {
3055 activation.condition(interpolatedTrimmed(nextText(parser, strict), "condition"));
3056 break;
3057 }
3058 default: {
3059 checkUnknownElement(parser, strict);
3060 break;
3061 }
3062 }
3063 if (addLocationInformation) {
3064 activation.location(childName, new InputLocation(line, column, source, locations));
3065 }
3066 }
3067 return activation.build();
3068 }
3069
3070 private ActivationProperty parseActivationProperty(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3071 String tagName = parser.getLocalName();
3072 ActivationProperty.Builder activationProperty = ActivationProperty.newBuilder(true);
3073 if (addLocationInformation) {
3074 activationProperty.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3075 }
3076 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3077 String name = parser.getAttributeLocalName(i);
3078 String ns = parser.getAttributeNamespace(i);
3079 String value = parser.getAttributeValue(i);
3080 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3081
3082 } else {
3083 checkUnknownAttribute(parser, name, tagName, strict);
3084 }
3085 }
3086 Set<String> parsed = new HashSet<>();
3087 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3088 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3089 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3090 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3091 Map<Object, InputLocation> locations = null;
3092 switch (childName) {
3093 case "name": {
3094 activationProperty.name(interpolatedTrimmed(nextText(parser, strict), "name"));
3095 break;
3096 }
3097 case "value": {
3098 activationProperty.value(interpolatedTrimmed(nextText(parser, strict), "value"));
3099 break;
3100 }
3101 default: {
3102 checkUnknownElement(parser, strict);
3103 break;
3104 }
3105 }
3106 if (addLocationInformation) {
3107 activationProperty.location(childName, new InputLocation(line, column, source, locations));
3108 }
3109 }
3110 return activationProperty.build();
3111 }
3112
3113 private ActivationOS parseActivationOS(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3114 String tagName = parser.getLocalName();
3115 ActivationOS.Builder activationOS = ActivationOS.newBuilder(true);
3116 if (addLocationInformation) {
3117 activationOS.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3118 }
3119 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3120 String name = parser.getAttributeLocalName(i);
3121 String ns = parser.getAttributeNamespace(i);
3122 String value = parser.getAttributeValue(i);
3123 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3124
3125 } else {
3126 checkUnknownAttribute(parser, name, tagName, strict);
3127 }
3128 }
3129 Set<String> parsed = new HashSet<>();
3130 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3131 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3132 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3133 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3134 Map<Object, InputLocation> locations = null;
3135 switch (childName) {
3136 case "name": {
3137 activationOS.name(interpolatedTrimmed(nextText(parser, strict), "name"));
3138 break;
3139 }
3140 case "family": {
3141 activationOS.family(interpolatedTrimmed(nextText(parser, strict), "family"));
3142 break;
3143 }
3144 case "arch": {
3145 activationOS.arch(interpolatedTrimmed(nextText(parser, strict), "arch"));
3146 break;
3147 }
3148 case "version": {
3149 activationOS.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3150 break;
3151 }
3152 default: {
3153 checkUnknownElement(parser, strict);
3154 break;
3155 }
3156 }
3157 if (addLocationInformation) {
3158 activationOS.location(childName, new InputLocation(line, column, source, locations));
3159 }
3160 }
3161 return activationOS.build();
3162 }
3163
3164 private ActivationFile parseActivationFile(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3165 String tagName = parser.getLocalName();
3166 ActivationFile.Builder activationFile = ActivationFile.newBuilder(true);
3167 if (addLocationInformation) {
3168 activationFile.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3169 }
3170 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3171 String name = parser.getAttributeLocalName(i);
3172 String ns = parser.getAttributeNamespace(i);
3173 String value = parser.getAttributeValue(i);
3174 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3175
3176 } else {
3177 checkUnknownAttribute(parser, name, tagName, strict);
3178 }
3179 }
3180 Set<String> parsed = new HashSet<>();
3181 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3182 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3183 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3184 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3185 Map<Object, InputLocation> locations = null;
3186 switch (childName) {
3187 case "missing": {
3188 activationFile.missing(interpolatedTrimmed(nextText(parser, strict), "missing"));
3189 break;
3190 }
3191 case "exists": {
3192 activationFile.exists(interpolatedTrimmed(nextText(parser, strict), "exists"));
3193 break;
3194 }
3195 default: {
3196 checkUnknownElement(parser, strict);
3197 break;
3198 }
3199 }
3200 if (addLocationInformation) {
3201 activationFile.location(childName, new InputLocation(line, column, source, locations));
3202 }
3203 }
3204 return activationFile.build();
3205 }
3206
3207 private ReportPlugin parseReportPlugin(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3208 String tagName = parser.getLocalName();
3209 ReportPlugin.Builder reportPlugin = ReportPlugin.newBuilder(true);
3210 if (addLocationInformation) {
3211 reportPlugin.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3212 }
3213 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3214 String name = parser.getAttributeLocalName(i);
3215 String ns = parser.getAttributeNamespace(i);
3216 String value = parser.getAttributeValue(i);
3217 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3218
3219 } else {
3220 checkUnknownAttribute(parser, name, tagName, strict);
3221 }
3222 }
3223 Set<String> parsed = new HashSet<>();
3224 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3225 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3226 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3227 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3228 Map<Object, InputLocation> locations = null;
3229 switch (childName) {
3230 case "groupId": {
3231 reportPlugin.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
3232 break;
3233 }
3234 case "artifactId": {
3235 reportPlugin.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
3236 break;
3237 }
3238 case "version": {
3239 reportPlugin.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3240 break;
3241 }
3242 case "reportSets": {
3243 List<ReportSet> reportSets = new ArrayList<>();
3244 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
3245 if ("reportSet".equals(parser.getLocalName())) {
3246 reportSets.add(parseReportSet(parser, strict, source));
3247 } else {
3248 checkUnknownElement(parser, strict);
3249 }
3250 }
3251 reportPlugin.reportSets(reportSets);
3252 break;
3253 }
3254 case "inherited": {
3255 reportPlugin.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
3256 break;
3257 }
3258 case "configuration": {
3259 reportPlugin.configuration(buildXmlNode(parser, source));
3260 break;
3261 }
3262 default: {
3263 checkUnknownElement(parser, strict);
3264 break;
3265 }
3266 }
3267 if (addLocationInformation) {
3268 reportPlugin.location(childName, new InputLocation(line, column, source, locations));
3269 }
3270 }
3271 return reportPlugin.build();
3272 }
3273
3274 private ReportSet parseReportSet(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3275 String tagName = parser.getLocalName();
3276 ReportSet.Builder reportSet = ReportSet.newBuilder(true);
3277 if (addLocationInformation) {
3278 reportSet.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3279 }
3280 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3281 String name = parser.getAttributeLocalName(i);
3282 String ns = parser.getAttributeNamespace(i);
3283 String value = parser.getAttributeValue(i);
3284 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3285
3286 } else {
3287 checkUnknownAttribute(parser, name, tagName, strict);
3288 }
3289 }
3290 Set<String> parsed = new HashSet<>();
3291 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3292 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3293 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3294 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3295 Map<Object, InputLocation> locations = null;
3296 switch (childName) {
3297 case "id": {
3298 reportSet.id(interpolatedTrimmed(nextText(parser, strict), "id"));
3299 break;
3300 }
3301 case "reports": {
3302 List<String> reports = new ArrayList<>();
3303 locations = new HashMap<>();
3304 while (parser.nextTag() == XMLStreamReader.START_ELEMENT) {
3305 if ("report".equals(parser.getLocalName())) {
3306 if (addLocationInformation) {
3307 locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3308 }
3309 reports.add(interpolatedTrimmed(nextText(parser, strict), "reports"));
3310 } else {
3311 checkUnknownElement(parser, strict);
3312 }
3313 }
3314 reportSet.reports(reports);
3315 break;
3316 }
3317 case "inherited": {
3318 reportSet.inherited(interpolatedTrimmed(nextText(parser, strict), "inherited"));
3319 break;
3320 }
3321 case "configuration": {
3322 reportSet.configuration(buildXmlNode(parser, source));
3323 break;
3324 }
3325 default: {
3326 checkUnknownElement(parser, strict);
3327 break;
3328 }
3329 }
3330 if (addLocationInformation) {
3331 reportSet.location(childName, new InputLocation(line, column, source, locations));
3332 }
3333 }
3334 return reportSet.build();
3335 }
3336
3337 private Prerequisites parsePrerequisites(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3338 String tagName = parser.getLocalName();
3339 Prerequisites.Builder prerequisites = Prerequisites.newBuilder(true);
3340 if (addLocationInformation) {
3341 prerequisites.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3342 }
3343 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3344 String name = parser.getAttributeLocalName(i);
3345 String ns = parser.getAttributeNamespace(i);
3346 String value = parser.getAttributeValue(i);
3347 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3348
3349 } else {
3350 checkUnknownAttribute(parser, name, tagName, strict);
3351 }
3352 }
3353 Set<String> parsed = new HashSet<>();
3354 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3355 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3356 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3357 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3358 Map<Object, InputLocation> locations = null;
3359 switch (childName) {
3360 case "maven": {
3361 prerequisites.maven(interpolatedTrimmed(nextText(parser, strict), "maven"));
3362 break;
3363 }
3364 default: {
3365 checkUnknownElement(parser, strict);
3366 break;
3367 }
3368 }
3369 if (addLocationInformation) {
3370 prerequisites.location(childName, new InputLocation(line, column, source, locations));
3371 }
3372 }
3373 return prerequisites.build();
3374 }
3375
3376 private Relocation parseRelocation(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3377 String tagName = parser.getLocalName();
3378 Relocation.Builder relocation = Relocation.newBuilder(true);
3379 if (addLocationInformation) {
3380 relocation.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3381 }
3382 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3383 String name = parser.getAttributeLocalName(i);
3384 String ns = parser.getAttributeNamespace(i);
3385 String value = parser.getAttributeValue(i);
3386 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3387
3388 } else {
3389 checkUnknownAttribute(parser, name, tagName, strict);
3390 }
3391 }
3392 Set<String> parsed = new HashSet<>();
3393 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3394 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3395 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3396 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3397 Map<Object, InputLocation> locations = null;
3398 switch (childName) {
3399 case "groupId": {
3400 relocation.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
3401 break;
3402 }
3403 case "artifactId": {
3404 relocation.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
3405 break;
3406 }
3407 case "version": {
3408 relocation.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3409 break;
3410 }
3411 case "message": {
3412 relocation.message(interpolatedTrimmed(nextText(parser, strict), "message"));
3413 break;
3414 }
3415 default: {
3416 checkUnknownElement(parser, strict);
3417 break;
3418 }
3419 }
3420 if (addLocationInformation) {
3421 relocation.location(childName, new InputLocation(line, column, source, locations));
3422 }
3423 }
3424 return relocation.build();
3425 }
3426
3427 private Extension parseExtension(XMLStreamReader parser, boolean strict, InputSource source) throws XMLStreamException {
3428 String tagName = parser.getLocalName();
3429 Extension.Builder extension = Extension.newBuilder(true);
3430 if (addLocationInformation) {
3431 extension.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source));
3432 }
3433 for (int i = parser.getAttributeCount() - 1; i >= 0; i--) {
3434 String name = parser.getAttributeLocalName(i);
3435 String ns = parser.getAttributeNamespace(i);
3436 String value = parser.getAttributeValue(i);
3437 if (W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(ns) || XML_NS_URI.equals(ns)) {
3438
3439 } else {
3440 checkUnknownAttribute(parser, name, tagName, strict);
3441 }
3442 }
3443 Set<String> parsed = new HashSet<>();
3444 while ((strict ? parser.nextTag() : nextTag(parser)) == XMLStreamReader.START_ELEMENT) {
3445 String childName = checkDuplicate(parser.getLocalName(), parser, parsed);
3446 int line = addLocationInformation ? parser.getLocation().getLineNumber() : -1;
3447 int column = addLocationInformation ? parser.getLocation().getColumnNumber() : -1;
3448 Map<Object, InputLocation> locations = null;
3449 switch (childName) {
3450 case "groupId": {
3451 extension.groupId(interpolatedTrimmed(nextText(parser, strict), "groupId"));
3452 break;
3453 }
3454 case "artifactId": {
3455 extension.artifactId(interpolatedTrimmed(nextText(parser, strict), "artifactId"));
3456 break;
3457 }
3458 case "version": {
3459 extension.version(interpolatedTrimmed(nextText(parser, strict), "version"));
3460 break;
3461 }
3462 case "configuration": {
3463 extension.configuration(buildXmlNode(parser, source));
3464 break;
3465 }
3466 default: {
3467 checkUnknownElement(parser, strict);
3468 break;
3469 }
3470 }
3471 if (addLocationInformation) {
3472 extension.location(childName, new InputLocation(line, column, source, locations));
3473 }
3474 }
3475 return extension.build();
3476 }
3477
3478
3479 private String checkDuplicate(String tagName, XMLStreamReader parser, Set<String> parsed) throws XMLStreamException {
3480 switch (tagName) {
3481 case "organisation":
3482 tagName = "organization";
3483 break;
3484 case "organisationUrl":
3485 tagName = "organizationUrl";
3486 break;
3487 }
3488 if (!parsed.add(tagName)) {
3489 throw new XMLStreamException("Duplicated tag: '" + tagName + "'", parser.getLocation(), null);
3490 }
3491 return tagName;
3492 }
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505 private void checkUnknownAttribute(XMLStreamReader parser, String attribute, String tagName, boolean strict) throws XMLStreamException {
3506
3507 if (strict) {
3508 throw new XMLStreamException("Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser.getLocation(), null);
3509 }
3510 }
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521 private void checkUnknownElement(XMLStreamReader parser, boolean strict) throws XMLStreamException {
3522 if (strict) {
3523 throw new XMLStreamException("Unrecognised tag: '" + parser.getName() + "'", parser.getLocation(), null);
3524 }
3525
3526 for (int unrecognizedTagCount = 1; unrecognizedTagCount > 0;) {
3527 int eventType = nextTag(parser);
3528 if (eventType == XMLStreamReader.START_ELEMENT) {
3529 unrecognizedTagCount++;
3530 } else if (eventType == XMLStreamReader.END_ELEMENT) {
3531 unrecognizedTagCount--;
3532 }
3533 }
3534 }
3535
3536
3537
3538
3539
3540
3541
3542 private String getTrimmedValue(String s) {
3543 if (s != null) {
3544 s = s.trim();
3545 }
3546 return s;
3547 }
3548
3549
3550
3551
3552
3553
3554
3555
3556 private String interpolatedTrimmed(String value, String context) {
3557 return getTrimmedValue(contentTransformer.transform(value, context));
3558 }
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569 private int nextTag(XMLStreamReader parser) throws XMLStreamException {
3570 while (true) {
3571 int next = parser.next();
3572 switch (next) {
3573 case XMLStreamReader.SPACE:
3574 case XMLStreamReader.COMMENT:
3575 case XMLStreamReader.PROCESSING_INSTRUCTION:
3576 case XMLStreamReader.CDATA:
3577 case XMLStreamReader.CHARACTERS:
3578 continue;
3579 case XMLStreamReader.START_ELEMENT:
3580 case XMLStreamReader.END_ELEMENT:
3581 return next;
3582 }
3583 }
3584 }
3585
3586 private String nextText(XMLStreamReader parser, boolean strict) throws XMLStreamException {
3587 int eventType = parser.getEventType();
3588 if (eventType != XMLStreamReader.START_ELEMENT) {
3589 throw new XMLStreamException("parser must be on START_ELEMENT to read next text", parser.getLocation(), null);
3590 }
3591 eventType = parser.next();
3592 StringBuilder result = new StringBuilder();
3593 while (true) {
3594 if (eventType == XMLStreamReader.CHARACTERS || eventType == XMLStreamReader.CDATA) {
3595 result.append(parser.getText());
3596 } else if (eventType == XMLStreamReader.ENTITY_REFERENCE) {
3597 String val = null;
3598 if (strict) {
3599 throw new XMLStreamException("Entities are not supported in strict mode", parser.getLocation(), null);
3600 } else if (addDefaultEntities) {
3601 val = DEFAULT_ENTITIES.get(parser.getLocalName());
3602 }
3603 if (val != null) {
3604 result.append(val);
3605 } else {
3606 result.append("&").append(parser.getLocalName()).append(";");
3607 }
3608 } else if (eventType != XMLStreamReader.COMMENT) {
3609 break;
3610 }
3611 eventType = parser.next();
3612 }
3613 if (eventType != XMLStreamReader.END_ELEMENT) {
3614 throw new XMLStreamException(
3615 "TEXT must be immediately followed by END_ELEMENT and not " + eventType , parser.getLocation(), null);
3616 }
3617 return result.toString();
3618 }
3619
3620 private XmlNode buildXmlNode(XMLStreamReader parser, InputSource source) throws XMLStreamException {
3621 return XmlNodeStaxBuilder.build(parser,
3622 addLocationInformation
3623 ? p -> new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), source)
3624 : null);
3625 }
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638 private boolean getBooleanValue(String s, String attribute, XMLStreamReader parser, boolean defaultValue) throws XMLStreamException {
3639 if (s != null && s.length() != 0) {
3640 return Boolean.valueOf(s).booleanValue();
3641 }
3642 return defaultValue;
3643 }
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656 private int getIntegerValue(String s, String attribute, XMLStreamReader parser, boolean strict, int defaultValue) throws XMLStreamException {
3657 if (s != null) {
3658 try {
3659 return Integer.valueOf(s).intValue();
3660 } catch (NumberFormatException nfe) {
3661 if (strict) {
3662 throw new XMLStreamException("Unable to parse element '" + attribute + "', must be an integer", parser.getLocation(), nfe);
3663 }
3664 }
3665 }
3666 return defaultValue;
3667 }
3668
3669 public static interface ContentTransformer {
3670
3671
3672
3673
3674
3675
3676
3677 String transform(String source, String fieldName);
3678 }
3679
3680 }