1 | |
package org.apache.maven.plugins.shade.pom; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
import java.io.OutputStream; |
29 | |
import java.io.OutputStreamWriter; |
30 | |
import java.io.Writer; |
31 | |
import java.util.ArrayList; |
32 | |
import java.util.Collection; |
33 | |
import java.util.Iterator; |
34 | |
import java.util.ListIterator; |
35 | |
import java.util.Map; |
36 | |
|
37 | |
import org.apache.maven.model.ActivationFile; |
38 | |
import org.apache.maven.model.ActivationOS; |
39 | |
import org.apache.maven.model.ActivationProperty; |
40 | |
import org.apache.maven.model.Build; |
41 | |
import org.apache.maven.model.BuildBase; |
42 | |
import org.apache.maven.model.CiManagement; |
43 | |
import org.apache.maven.model.ConfigurationContainer; |
44 | |
import org.apache.maven.model.Contributor; |
45 | |
import org.apache.maven.model.Dependency; |
46 | |
import org.apache.maven.model.DependencyManagement; |
47 | |
import org.apache.maven.model.DeploymentRepository; |
48 | |
import org.apache.maven.model.Developer; |
49 | |
import org.apache.maven.model.DistributionManagement; |
50 | |
import org.apache.maven.model.Exclusion; |
51 | |
import org.apache.maven.model.Extension; |
52 | |
import org.apache.maven.model.FileSet; |
53 | |
import org.apache.maven.model.IssueManagement; |
54 | |
import org.apache.maven.model.License; |
55 | |
import org.apache.maven.model.MailingList; |
56 | |
import org.apache.maven.model.Model; |
57 | |
import org.apache.maven.model.ModelBase; |
58 | |
import org.apache.maven.model.Notifier; |
59 | |
import org.apache.maven.model.Organization; |
60 | |
import org.apache.maven.model.Parent; |
61 | |
import org.apache.maven.model.PatternSet; |
62 | |
import org.apache.maven.model.Plugin; |
63 | |
import org.apache.maven.model.PluginConfiguration; |
64 | |
import org.apache.maven.model.PluginContainer; |
65 | |
import org.apache.maven.model.PluginExecution; |
66 | |
import org.apache.maven.model.PluginManagement; |
67 | |
import org.apache.maven.model.Prerequisites; |
68 | |
import org.apache.maven.model.Profile; |
69 | |
import org.apache.maven.model.Relocation; |
70 | |
import org.apache.maven.model.ReportPlugin; |
71 | |
import org.apache.maven.model.ReportSet; |
72 | |
import org.apache.maven.model.Reporting; |
73 | |
import org.apache.maven.model.Repository; |
74 | |
import org.apache.maven.model.RepositoryBase; |
75 | |
import org.apache.maven.model.RepositoryPolicy; |
76 | |
import org.apache.maven.model.Resource; |
77 | |
import org.apache.maven.model.Scm; |
78 | |
import org.apache.maven.model.Site; |
79 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
80 | |
import org.jdom.Content; |
81 | |
import org.jdom.DefaultJDOMFactory; |
82 | |
import org.jdom.Document; |
83 | |
import org.jdom.Element; |
84 | |
import org.jdom.Text; |
85 | |
import org.jdom.output.Format; |
86 | |
import org.jdom.output.XMLOutputter; |
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
public class MavenJDOMWriter |
94 | |
{ |
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
private DefaultJDOMFactory factory; |
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
private String lineSeparator; |
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
public MavenJDOMWriter() |
115 | 0 | { |
116 | 0 | factory = new DefaultJDOMFactory(); |
117 | 0 | lineSeparator = "\n"; |
118 | 0 | } |
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
protected Element findAndReplaceProperties( Counter counter, Element parent, String name, Map props ) |
133 | |
{ |
134 | 0 | boolean shouldExist = props != null && !props.isEmpty(); |
135 | 0 | Element element = updateElement( counter, parent, name, shouldExist ); |
136 | 0 | if ( shouldExist ) |
137 | |
{ |
138 | 0 | Iterator it = props.keySet().iterator(); |
139 | 0 | Counter innerCounter = new Counter( counter.getDepth() + 1 ); |
140 | 0 | while ( it.hasNext() ) |
141 | |
{ |
142 | 0 | String key = (String) it.next(); |
143 | 0 | findAndReplaceSimpleElement( innerCounter, element, key, (String) props.get( key ), null ); |
144 | 0 | } |
145 | 0 | ArrayList lst = new ArrayList( props.keySet() ); |
146 | 0 | it = element.getChildren().iterator(); |
147 | 0 | while ( it.hasNext() ) |
148 | |
{ |
149 | 0 | Element elem = (Element) it.next(); |
150 | 0 | String key = elem.getName(); |
151 | 0 | if ( !lst.contains( key ) ) |
152 | |
{ |
153 | 0 | it.remove(); |
154 | |
} |
155 | 0 | } |
156 | |
} |
157 | 0 | return element; |
158 | |
} |
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
protected Element findAndReplaceSimpleElement( Counter counter, Element parent, String name, String text, |
170 | |
String defaultValue ) |
171 | |
{ |
172 | 0 | if ( defaultValue != null && text != null && defaultValue.equals( text ) ) |
173 | |
{ |
174 | 0 | Element element = parent.getChild( name, parent.getNamespace() ); |
175 | |
|
176 | 0 | if ( ( element != null && defaultValue.equals( element.getText() ) ) || element == null ) |
177 | |
{ |
178 | 0 | return element; |
179 | |
} |
180 | |
} |
181 | 0 | boolean shouldExist = text != null && text.trim().length() > 0; |
182 | 0 | Element element = updateElement( counter, parent, name, shouldExist ); |
183 | 0 | if ( shouldExist ) |
184 | |
{ |
185 | 0 | element.setText( text ); |
186 | |
} |
187 | 0 | return element; |
188 | |
} |
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | |
|
199 | |
protected Element findAndReplaceSimpleLists( Counter counter, Element parent, java.util.Collection list, |
200 | |
String parentName, String childName ) |
201 | |
{ |
202 | 0 | boolean shouldExist = list != null && list.size() > 0; |
203 | 0 | Element element = updateElement( counter, parent, parentName, shouldExist ); |
204 | 0 | if ( shouldExist ) |
205 | |
{ |
206 | 0 | Iterator it = list.iterator(); |
207 | 0 | Iterator elIt = element.getChildren( childName, element.getNamespace() ).iterator(); |
208 | 0 | if ( !elIt.hasNext() ) |
209 | 0 | elIt = null; |
210 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
211 | 0 | while ( it.hasNext() ) |
212 | |
{ |
213 | 0 | String value = (String) it.next(); |
214 | |
Element el; |
215 | 0 | if ( elIt != null && elIt.hasNext() ) |
216 | |
{ |
217 | 0 | el = (Element) elIt.next(); |
218 | 0 | if ( !elIt.hasNext() ) |
219 | 0 | elIt = null; |
220 | |
} |
221 | |
else |
222 | |
{ |
223 | 0 | el = factory.element( childName, element.getNamespace() ); |
224 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
225 | |
} |
226 | 0 | el.setText( value ); |
227 | 0 | innerCount.increaseCount(); |
228 | 0 | } |
229 | 0 | if ( elIt != null ) |
230 | |
{ |
231 | 0 | while ( elIt.hasNext() ) |
232 | |
{ |
233 | 0 | elIt.next(); |
234 | 0 | elIt.remove(); |
235 | |
} |
236 | |
} |
237 | |
} |
238 | 0 | return element; |
239 | |
} |
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
protected Element findAndReplaceXpp3DOM( Counter counter, Element parent, String name, Xpp3Dom dom ) |
250 | |
{ |
251 | 0 | boolean shouldExist = dom != null && ( dom.getChildCount() > 0 || dom.getValue() != null ); |
252 | 0 | Element element = updateElement( counter, parent, name, shouldExist ); |
253 | 0 | if ( shouldExist ) |
254 | |
{ |
255 | 0 | replaceXpp3DOM( element, dom, new Counter( counter.getDepth() + 1 ) ); |
256 | |
} |
257 | 0 | return element; |
258 | |
} |
259 | |
|
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
protected void insertAtPreferredLocation( Element parent, Element child, Counter counter ) |
268 | |
{ |
269 | 0 | int contentIndex = 0; |
270 | 0 | int elementCounter = 0; |
271 | 0 | Iterator it = parent.getContent().iterator(); |
272 | 0 | Text lastText = null; |
273 | 0 | int offset = 0; |
274 | 0 | while ( it.hasNext() && elementCounter <= counter.getCurrentIndex() ) |
275 | |
{ |
276 | 0 | Object next = it.next(); |
277 | 0 | offset = offset + 1; |
278 | 0 | if ( next instanceof Element ) |
279 | |
{ |
280 | 0 | elementCounter = elementCounter + 1; |
281 | 0 | contentIndex = contentIndex + offset; |
282 | 0 | offset = 0; |
283 | |
} |
284 | 0 | if ( next instanceof Text && it.hasNext() ) |
285 | |
{ |
286 | 0 | lastText = (Text) next; |
287 | |
} |
288 | 0 | } |
289 | 0 | if ( lastText != null && lastText.getTextTrim().length() == 0 ) |
290 | |
{ |
291 | 0 | lastText = (Text) lastText.clone(); |
292 | |
} |
293 | |
else |
294 | |
{ |
295 | 0 | String starter = lineSeparator; |
296 | 0 | for ( int i = 0; i < counter.getDepth(); i++ ) |
297 | |
{ |
298 | 0 | starter = starter + " "; |
299 | |
} |
300 | 0 | lastText = factory.text( starter ); |
301 | |
} |
302 | 0 | if ( parent.getContentSize() == 0 ) |
303 | |
{ |
304 | 0 | Text finalText = (Text) lastText.clone(); |
305 | 0 | finalText.setText( finalText.getText().substring( 0, finalText.getText().length() - " ".length() ) ); |
306 | 0 | parent.addContent( contentIndex, finalText ); |
307 | |
} |
308 | 0 | parent.addContent( contentIndex, child ); |
309 | 0 | parent.addContent( contentIndex, lastText ); |
310 | 0 | } |
311 | |
|
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
protected void iterateContributor( Counter counter, Element parent, java.util.Collection list, |
322 | |
java.lang.String parentTag, java.lang.String childTag ) |
323 | |
{ |
324 | 0 | boolean shouldExist = list != null && list.size() > 0; |
325 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
326 | 0 | if ( shouldExist ) |
327 | |
{ |
328 | 0 | Iterator it = list.iterator(); |
329 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
330 | 0 | if ( !elIt.hasNext() ) |
331 | 0 | elIt = null; |
332 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
333 | 0 | while ( it.hasNext() ) |
334 | |
{ |
335 | 0 | Contributor value = (Contributor) it.next(); |
336 | |
Element el; |
337 | 0 | if ( elIt != null && elIt.hasNext() ) |
338 | |
{ |
339 | 0 | el = (Element) elIt.next(); |
340 | 0 | if ( !elIt.hasNext() ) |
341 | 0 | elIt = null; |
342 | |
} |
343 | |
else |
344 | |
{ |
345 | 0 | el = factory.element( childTag, element.getNamespace() ); |
346 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
347 | |
} |
348 | 0 | updateContributor( value, childTag, innerCount, el ); |
349 | 0 | innerCount.increaseCount(); |
350 | 0 | } |
351 | 0 | if ( elIt != null ) |
352 | |
{ |
353 | 0 | while ( elIt.hasNext() ) |
354 | |
{ |
355 | 0 | elIt.next(); |
356 | 0 | elIt.remove(); |
357 | |
} |
358 | |
} |
359 | |
} |
360 | 0 | } |
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
|
366 | |
|
367 | |
|
368 | |
|
369 | |
|
370 | |
|
371 | |
protected void iterateDependency( Counter counter, Element parent, java.util.Collection list, |
372 | |
java.lang.String parentTag, java.lang.String childTag ) |
373 | |
{ |
374 | 0 | boolean shouldExist = list != null && list.size() > 0; |
375 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
376 | 0 | if ( shouldExist ) |
377 | |
{ |
378 | 0 | Iterator it = list.iterator(); |
379 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
380 | 0 | if ( !elIt.hasNext() ) |
381 | 0 | elIt = null; |
382 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
383 | 0 | while ( it.hasNext() ) |
384 | |
{ |
385 | 0 | Dependency value = (Dependency) it.next(); |
386 | |
Element el; |
387 | 0 | if ( elIt != null && elIt.hasNext() ) |
388 | |
{ |
389 | 0 | el = (Element) elIt.next(); |
390 | 0 | if ( !elIt.hasNext() ) |
391 | 0 | elIt = null; |
392 | |
} |
393 | |
else |
394 | |
{ |
395 | 0 | el = factory.element( childTag, element.getNamespace() ); |
396 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
397 | |
} |
398 | 0 | updateDependency( value, childTag, innerCount, el ); |
399 | 0 | innerCount.increaseCount(); |
400 | 0 | } |
401 | 0 | if ( elIt != null ) |
402 | |
{ |
403 | 0 | while ( elIt.hasNext() ) |
404 | |
{ |
405 | 0 | elIt.next(); |
406 | 0 | elIt.remove(); |
407 | |
} |
408 | |
} |
409 | |
} |
410 | 0 | } |
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
|
421 | |
protected void iterateDeveloper( Counter counter, Element parent, java.util.Collection list, |
422 | |
java.lang.String parentTag, java.lang.String childTag ) |
423 | |
{ |
424 | 0 | boolean shouldExist = list != null && list.size() > 0; |
425 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
426 | 0 | if ( shouldExist ) |
427 | |
{ |
428 | 0 | Iterator it = list.iterator(); |
429 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
430 | 0 | if ( !elIt.hasNext() ) |
431 | 0 | elIt = null; |
432 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
433 | 0 | while ( it.hasNext() ) |
434 | |
{ |
435 | 0 | Developer value = (Developer) it.next(); |
436 | |
Element el; |
437 | 0 | if ( elIt != null && elIt.hasNext() ) |
438 | |
{ |
439 | 0 | el = (Element) elIt.next(); |
440 | 0 | if ( !elIt.hasNext() ) |
441 | 0 | elIt = null; |
442 | |
} |
443 | |
else |
444 | |
{ |
445 | 0 | el = factory.element( childTag, element.getNamespace() ); |
446 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
447 | |
} |
448 | 0 | updateDeveloper( value, childTag, innerCount, el ); |
449 | 0 | innerCount.increaseCount(); |
450 | 0 | } |
451 | 0 | if ( elIt != null ) |
452 | |
{ |
453 | 0 | while ( elIt.hasNext() ) |
454 | |
{ |
455 | 0 | elIt.next(); |
456 | 0 | elIt.remove(); |
457 | |
} |
458 | |
} |
459 | |
} |
460 | 0 | } |
461 | |
|
462 | |
|
463 | |
|
464 | |
|
465 | |
|
466 | |
|
467 | |
|
468 | |
|
469 | |
|
470 | |
|
471 | |
protected void iterateExclusion( Counter counter, Element parent, java.util.Collection list, |
472 | |
java.lang.String parentTag, java.lang.String childTag ) |
473 | |
{ |
474 | 0 | boolean shouldExist = list != null && list.size() > 0; |
475 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
476 | 0 | if ( shouldExist ) |
477 | |
{ |
478 | 0 | Iterator it = list.iterator(); |
479 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
480 | 0 | if ( !elIt.hasNext() ) |
481 | 0 | elIt = null; |
482 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
483 | 0 | while ( it.hasNext() ) |
484 | |
{ |
485 | 0 | Exclusion value = (Exclusion) it.next(); |
486 | |
Element el; |
487 | 0 | if ( elIt != null && elIt.hasNext() ) |
488 | |
{ |
489 | 0 | el = (Element) elIt.next(); |
490 | 0 | if ( !elIt.hasNext() ) |
491 | 0 | elIt = null; |
492 | |
} |
493 | |
else |
494 | |
{ |
495 | 0 | el = factory.element( childTag, element.getNamespace() ); |
496 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
497 | |
} |
498 | 0 | updateExclusion( value, childTag, innerCount, el ); |
499 | 0 | innerCount.increaseCount(); |
500 | 0 | } |
501 | 0 | if ( elIt != null ) |
502 | |
{ |
503 | 0 | while ( elIt.hasNext() ) |
504 | |
{ |
505 | 0 | elIt.next(); |
506 | 0 | elIt.remove(); |
507 | |
} |
508 | |
} |
509 | |
} |
510 | 0 | } |
511 | |
|
512 | |
|
513 | |
|
514 | |
|
515 | |
|
516 | |
|
517 | |
|
518 | |
|
519 | |
|
520 | |
|
521 | |
protected void iterateExtension( Counter counter, Element parent, java.util.Collection list, |
522 | |
java.lang.String parentTag, java.lang.String childTag ) |
523 | |
{ |
524 | 0 | boolean shouldExist = list != null && list.size() > 0; |
525 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
526 | 0 | if ( shouldExist ) |
527 | |
{ |
528 | 0 | Iterator it = list.iterator(); |
529 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
530 | 0 | if ( !elIt.hasNext() ) |
531 | 0 | elIt = null; |
532 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
533 | 0 | while ( it.hasNext() ) |
534 | |
{ |
535 | 0 | Extension value = (Extension) it.next(); |
536 | |
Element el; |
537 | 0 | if ( elIt != null && elIt.hasNext() ) |
538 | |
{ |
539 | 0 | el = (Element) elIt.next(); |
540 | 0 | if ( !elIt.hasNext() ) |
541 | 0 | elIt = null; |
542 | |
} |
543 | |
else |
544 | |
{ |
545 | 0 | el = factory.element( childTag, element.getNamespace() ); |
546 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
547 | |
} |
548 | 0 | updateExtension( value, childTag, innerCount, el ); |
549 | 0 | innerCount.increaseCount(); |
550 | 0 | } |
551 | 0 | if ( elIt != null ) |
552 | |
{ |
553 | 0 | while ( elIt.hasNext() ) |
554 | |
{ |
555 | 0 | elIt.next(); |
556 | 0 | elIt.remove(); |
557 | |
} |
558 | |
} |
559 | |
} |
560 | 0 | } |
561 | |
|
562 | |
|
563 | |
|
564 | |
|
565 | |
|
566 | |
|
567 | |
|
568 | |
|
569 | |
|
570 | |
|
571 | |
protected void iterateLicense( Counter counter, Element parent, java.util.Collection list, |
572 | |
java.lang.String parentTag, java.lang.String childTag ) |
573 | |
{ |
574 | 0 | boolean shouldExist = list != null && list.size() > 0; |
575 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
576 | 0 | if ( shouldExist ) |
577 | |
{ |
578 | 0 | Iterator it = list.iterator(); |
579 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
580 | 0 | if ( !elIt.hasNext() ) |
581 | 0 | elIt = null; |
582 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
583 | 0 | while ( it.hasNext() ) |
584 | |
{ |
585 | 0 | License value = (License) it.next(); |
586 | |
Element el; |
587 | 0 | if ( elIt != null && elIt.hasNext() ) |
588 | |
{ |
589 | 0 | el = (Element) elIt.next(); |
590 | 0 | if ( !elIt.hasNext() ) |
591 | 0 | elIt = null; |
592 | |
} |
593 | |
else |
594 | |
{ |
595 | 0 | el = factory.element( childTag, element.getNamespace() ); |
596 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
597 | |
} |
598 | 0 | updateLicense( value, childTag, innerCount, el ); |
599 | 0 | innerCount.increaseCount(); |
600 | 0 | } |
601 | 0 | if ( elIt != null ) |
602 | |
{ |
603 | 0 | while ( elIt.hasNext() ) |
604 | |
{ |
605 | 0 | elIt.next(); |
606 | 0 | elIt.remove(); |
607 | |
} |
608 | |
} |
609 | |
} |
610 | 0 | } |
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
|
621 | |
protected void iterateMailingList( Counter counter, Element parent, java.util.Collection list, |
622 | |
java.lang.String parentTag, java.lang.String childTag ) |
623 | |
{ |
624 | 0 | boolean shouldExist = list != null && list.size() > 0; |
625 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
626 | 0 | if ( shouldExist ) |
627 | |
{ |
628 | 0 | Iterator it = list.iterator(); |
629 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
630 | 0 | if ( !elIt.hasNext() ) |
631 | 0 | elIt = null; |
632 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
633 | 0 | while ( it.hasNext() ) |
634 | |
{ |
635 | 0 | MailingList value = (MailingList) it.next(); |
636 | |
Element el; |
637 | 0 | if ( elIt != null && elIt.hasNext() ) |
638 | |
{ |
639 | 0 | el = (Element) elIt.next(); |
640 | 0 | if ( !elIt.hasNext() ) |
641 | 0 | elIt = null; |
642 | |
} |
643 | |
else |
644 | |
{ |
645 | 0 | el = factory.element( childTag, element.getNamespace() ); |
646 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
647 | |
} |
648 | 0 | updateMailingList( value, childTag, innerCount, el ); |
649 | 0 | innerCount.increaseCount(); |
650 | 0 | } |
651 | 0 | if ( elIt != null ) |
652 | |
{ |
653 | 0 | while ( elIt.hasNext() ) |
654 | |
{ |
655 | 0 | elIt.next(); |
656 | 0 | elIt.remove(); |
657 | |
} |
658 | |
} |
659 | |
} |
660 | 0 | } |
661 | |
|
662 | |
|
663 | |
|
664 | |
|
665 | |
|
666 | |
|
667 | |
|
668 | |
|
669 | |
|
670 | |
|
671 | |
protected void iterateNotifier( Counter counter, Element parent, java.util.Collection list, |
672 | |
java.lang.String parentTag, java.lang.String childTag ) |
673 | |
{ |
674 | 0 | boolean shouldExist = list != null && list.size() > 0; |
675 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
676 | 0 | if ( shouldExist ) |
677 | |
{ |
678 | 0 | Iterator it = list.iterator(); |
679 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
680 | 0 | if ( !elIt.hasNext() ) |
681 | 0 | elIt = null; |
682 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
683 | 0 | while ( it.hasNext() ) |
684 | |
{ |
685 | 0 | Notifier value = (Notifier) it.next(); |
686 | |
Element el; |
687 | 0 | if ( elIt != null && elIt.hasNext() ) |
688 | |
{ |
689 | 0 | el = (Element) elIt.next(); |
690 | 0 | if ( !elIt.hasNext() ) |
691 | 0 | elIt = null; |
692 | |
} |
693 | |
else |
694 | |
{ |
695 | 0 | el = factory.element( childTag, element.getNamespace() ); |
696 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
697 | |
} |
698 | 0 | updateNotifier( value, childTag, innerCount, el ); |
699 | 0 | innerCount.increaseCount(); |
700 | 0 | } |
701 | 0 | if ( elIt != null ) |
702 | |
{ |
703 | 0 | while ( elIt.hasNext() ) |
704 | |
{ |
705 | 0 | elIt.next(); |
706 | 0 | elIt.remove(); |
707 | |
} |
708 | |
} |
709 | |
} |
710 | 0 | } |
711 | |
|
712 | |
|
713 | |
|
714 | |
|
715 | |
|
716 | |
|
717 | |
|
718 | |
|
719 | |
|
720 | |
|
721 | |
protected void iteratePlugin( Counter counter, Element parent, java.util.Collection list, |
722 | |
java.lang.String parentTag, java.lang.String childTag ) |
723 | |
{ |
724 | 0 | boolean shouldExist = list != null && list.size() > 0; |
725 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
726 | 0 | if ( shouldExist ) |
727 | |
{ |
728 | 0 | Iterator it = list.iterator(); |
729 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
730 | 0 | if ( !elIt.hasNext() ) |
731 | 0 | elIt = null; |
732 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
733 | 0 | while ( it.hasNext() ) |
734 | |
{ |
735 | 0 | Plugin value = (Plugin) it.next(); |
736 | |
Element el; |
737 | 0 | if ( elIt != null && elIt.hasNext() ) |
738 | |
{ |
739 | 0 | el = (Element) elIt.next(); |
740 | 0 | if ( !elIt.hasNext() ) |
741 | 0 | elIt = null; |
742 | |
} |
743 | |
else |
744 | |
{ |
745 | 0 | el = factory.element( childTag, element.getNamespace() ); |
746 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
747 | |
} |
748 | 0 | updatePlugin( value, childTag, innerCount, el ); |
749 | 0 | innerCount.increaseCount(); |
750 | 0 | } |
751 | 0 | if ( elIt != null ) |
752 | |
{ |
753 | 0 | while ( elIt.hasNext() ) |
754 | |
{ |
755 | 0 | elIt.next(); |
756 | 0 | elIt.remove(); |
757 | |
} |
758 | |
} |
759 | |
} |
760 | 0 | } |
761 | |
|
762 | |
|
763 | |
|
764 | |
|
765 | |
|
766 | |
|
767 | |
|
768 | |
|
769 | |
|
770 | |
|
771 | |
protected void iteratePluginExecution( Counter counter, Element parent, java.util.Collection list, |
772 | |
java.lang.String parentTag, java.lang.String childTag ) |
773 | |
{ |
774 | 0 | boolean shouldExist = list != null && list.size() > 0; |
775 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
776 | 0 | if ( shouldExist ) |
777 | |
{ |
778 | 0 | Iterator it = list.iterator(); |
779 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
780 | 0 | if ( !elIt.hasNext() ) |
781 | 0 | elIt = null; |
782 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
783 | 0 | while ( it.hasNext() ) |
784 | |
{ |
785 | 0 | PluginExecution value = (PluginExecution) it.next(); |
786 | |
Element el; |
787 | 0 | if ( elIt != null && elIt.hasNext() ) |
788 | |
{ |
789 | 0 | el = (Element) elIt.next(); |
790 | 0 | if ( !elIt.hasNext() ) |
791 | 0 | elIt = null; |
792 | |
} |
793 | |
else |
794 | |
{ |
795 | 0 | el = factory.element( childTag, element.getNamespace() ); |
796 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
797 | |
} |
798 | 0 | updatePluginExecution( value, childTag, innerCount, el ); |
799 | 0 | innerCount.increaseCount(); |
800 | 0 | } |
801 | 0 | if ( elIt != null ) |
802 | |
{ |
803 | 0 | while ( elIt.hasNext() ) |
804 | |
{ |
805 | 0 | elIt.next(); |
806 | 0 | elIt.remove(); |
807 | |
} |
808 | |
} |
809 | |
} |
810 | 0 | } |
811 | |
|
812 | |
|
813 | |
|
814 | |
|
815 | |
|
816 | |
|
817 | |
|
818 | |
|
819 | |
|
820 | |
|
821 | |
protected void iterateProfile( Counter counter, Element parent, java.util.Collection list, |
822 | |
java.lang.String parentTag, java.lang.String childTag ) |
823 | |
{ |
824 | 0 | boolean shouldExist = list != null && list.size() > 0; |
825 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
826 | 0 | if ( shouldExist ) |
827 | |
{ |
828 | 0 | Iterator it = list.iterator(); |
829 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
830 | 0 | if ( !elIt.hasNext() ) |
831 | 0 | elIt = null; |
832 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
833 | 0 | while ( it.hasNext() ) |
834 | |
{ |
835 | 0 | Profile value = (Profile) it.next(); |
836 | |
Element el; |
837 | 0 | if ( elIt != null && elIt.hasNext() ) |
838 | |
{ |
839 | 0 | el = (Element) elIt.next(); |
840 | 0 | if ( !elIt.hasNext() ) |
841 | 0 | elIt = null; |
842 | |
} |
843 | |
else |
844 | |
{ |
845 | 0 | el = factory.element( childTag, element.getNamespace() ); |
846 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
847 | |
} |
848 | 0 | updateProfile( value, childTag, innerCount, el ); |
849 | 0 | innerCount.increaseCount(); |
850 | 0 | } |
851 | 0 | if ( elIt != null ) |
852 | |
{ |
853 | 0 | while ( elIt.hasNext() ) |
854 | |
{ |
855 | 0 | elIt.next(); |
856 | 0 | elIt.remove(); |
857 | |
} |
858 | |
} |
859 | |
} |
860 | 0 | } |
861 | |
|
862 | |
|
863 | |
|
864 | |
|
865 | |
|
866 | |
|
867 | |
|
868 | |
|
869 | |
|
870 | |
|
871 | |
protected void iterateReportPlugin( Counter counter, Element parent, java.util.Collection list, |
872 | |
java.lang.String parentTag, java.lang.String childTag ) |
873 | |
{ |
874 | 0 | boolean shouldExist = list != null && list.size() > 0; |
875 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
876 | 0 | if ( shouldExist ) |
877 | |
{ |
878 | 0 | Iterator it = list.iterator(); |
879 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
880 | 0 | if ( !elIt.hasNext() ) |
881 | 0 | elIt = null; |
882 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
883 | 0 | while ( it.hasNext() ) |
884 | |
{ |
885 | 0 | ReportPlugin value = (ReportPlugin) it.next(); |
886 | |
Element el; |
887 | 0 | if ( elIt != null && elIt.hasNext() ) |
888 | |
{ |
889 | 0 | el = (Element) elIt.next(); |
890 | 0 | if ( !elIt.hasNext() ) |
891 | 0 | elIt = null; |
892 | |
} |
893 | |
else |
894 | |
{ |
895 | 0 | el = factory.element( childTag, element.getNamespace() ); |
896 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
897 | |
} |
898 | 0 | updateReportPlugin( value, childTag, innerCount, el ); |
899 | 0 | innerCount.increaseCount(); |
900 | 0 | } |
901 | 0 | if ( elIt != null ) |
902 | |
{ |
903 | 0 | while ( elIt.hasNext() ) |
904 | |
{ |
905 | 0 | elIt.next(); |
906 | 0 | elIt.remove(); |
907 | |
} |
908 | |
} |
909 | |
} |
910 | 0 | } |
911 | |
|
912 | |
|
913 | |
|
914 | |
|
915 | |
|
916 | |
|
917 | |
|
918 | |
|
919 | |
|
920 | |
|
921 | |
protected void iterateReportSet( Counter counter, Element parent, java.util.Collection list, |
922 | |
java.lang.String parentTag, java.lang.String childTag ) |
923 | |
{ |
924 | 0 | boolean shouldExist = list != null && list.size() > 0; |
925 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
926 | 0 | if ( shouldExist ) |
927 | |
{ |
928 | 0 | Iterator it = list.iterator(); |
929 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
930 | 0 | if ( !elIt.hasNext() ) |
931 | 0 | elIt = null; |
932 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
933 | 0 | while ( it.hasNext() ) |
934 | |
{ |
935 | 0 | ReportSet value = (ReportSet) it.next(); |
936 | |
Element el; |
937 | 0 | if ( elIt != null && elIt.hasNext() ) |
938 | |
{ |
939 | 0 | el = (Element) elIt.next(); |
940 | 0 | if ( !elIt.hasNext() ) |
941 | 0 | elIt = null; |
942 | |
} |
943 | |
else |
944 | |
{ |
945 | 0 | el = factory.element( childTag, element.getNamespace() ); |
946 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
947 | |
} |
948 | 0 | updateReportSet( value, childTag, innerCount, el ); |
949 | 0 | innerCount.increaseCount(); |
950 | 0 | } |
951 | 0 | if ( elIt != null ) |
952 | |
{ |
953 | 0 | while ( elIt.hasNext() ) |
954 | |
{ |
955 | 0 | elIt.next(); |
956 | 0 | elIt.remove(); |
957 | |
} |
958 | |
} |
959 | |
} |
960 | 0 | } |
961 | |
|
962 | |
|
963 | |
|
964 | |
|
965 | |
|
966 | |
|
967 | |
|
968 | |
|
969 | |
|
970 | |
|
971 | |
protected void iterateRepository( Counter counter, Element parent, java.util.Collection list, |
972 | |
java.lang.String parentTag, java.lang.String childTag ) |
973 | |
{ |
974 | 0 | boolean shouldExist = list != null && list.size() > 0; |
975 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
976 | 0 | if ( shouldExist ) |
977 | |
{ |
978 | 0 | Iterator it = list.iterator(); |
979 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
980 | 0 | if ( !elIt.hasNext() ) |
981 | 0 | elIt = null; |
982 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
983 | 0 | while ( it.hasNext() ) |
984 | |
{ |
985 | 0 | Repository value = (Repository) it.next(); |
986 | |
Element el; |
987 | 0 | if ( elIt != null && elIt.hasNext() ) |
988 | |
{ |
989 | 0 | el = (Element) elIt.next(); |
990 | 0 | if ( !elIt.hasNext() ) |
991 | 0 | elIt = null; |
992 | |
} |
993 | |
else |
994 | |
{ |
995 | 0 | el = factory.element( childTag, element.getNamespace() ); |
996 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
997 | |
} |
998 | 0 | updateRepository( value, childTag, innerCount, el ); |
999 | 0 | innerCount.increaseCount(); |
1000 | 0 | } |
1001 | 0 | if ( elIt != null ) |
1002 | |
{ |
1003 | 0 | while ( elIt.hasNext() ) |
1004 | |
{ |
1005 | 0 | elIt.next(); |
1006 | 0 | elIt.remove(); |
1007 | |
} |
1008 | |
} |
1009 | |
} |
1010 | 0 | } |
1011 | |
|
1012 | |
|
1013 | |
|
1014 | |
|
1015 | |
|
1016 | |
|
1017 | |
|
1018 | |
|
1019 | |
|
1020 | |
|
1021 | |
protected void iterateResource( Counter counter, Element parent, java.util.Collection list, |
1022 | |
java.lang.String parentTag, java.lang.String childTag ) |
1023 | |
{ |
1024 | 0 | boolean shouldExist = list != null && list.size() > 0; |
1025 | 0 | Element element = updateElement( counter, parent, parentTag, shouldExist ); |
1026 | 0 | if ( shouldExist ) |
1027 | |
{ |
1028 | 0 | Iterator it = list.iterator(); |
1029 | 0 | Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); |
1030 | 0 | if ( !elIt.hasNext() ) |
1031 | 0 | elIt = null; |
1032 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1033 | 0 | while ( it.hasNext() ) |
1034 | |
{ |
1035 | 0 | Resource value = (Resource) it.next(); |
1036 | |
Element el; |
1037 | 0 | if ( elIt != null && elIt.hasNext() ) |
1038 | |
{ |
1039 | 0 | el = (Element) elIt.next(); |
1040 | 0 | if ( !elIt.hasNext() ) |
1041 | 0 | elIt = null; |
1042 | |
} |
1043 | |
else |
1044 | |
{ |
1045 | 0 | el = factory.element( childTag, element.getNamespace() ); |
1046 | 0 | insertAtPreferredLocation( element, el, innerCount ); |
1047 | |
} |
1048 | 0 | updateResource( value, childTag, innerCount, el ); |
1049 | 0 | innerCount.increaseCount(); |
1050 | 0 | } |
1051 | 0 | if ( elIt != null ) |
1052 | |
{ |
1053 | 0 | while ( elIt.hasNext() ) |
1054 | |
{ |
1055 | 0 | elIt.next(); |
1056 | 0 | elIt.remove(); |
1057 | |
} |
1058 | |
} |
1059 | |
} |
1060 | 0 | } |
1061 | |
|
1062 | |
|
1063 | |
|
1064 | |
|
1065 | |
|
1066 | |
|
1067 | |
|
1068 | |
|
1069 | |
protected void replaceXpp3DOM( Element parent, Xpp3Dom parentDom, Counter counter ) |
1070 | |
{ |
1071 | 0 | if ( parentDom.getChildCount() > 0 ) |
1072 | |
{ |
1073 | 0 | Xpp3Dom[] childs = parentDom.getChildren(); |
1074 | 0 | Collection domChilds = new ArrayList(); |
1075 | 0 | for ( int i = 0; i < childs.length; i++ ) |
1076 | |
{ |
1077 | 0 | domChilds.add( childs[i] ); |
1078 | |
} |
1079 | |
|
1080 | 0 | ListIterator it = parent.getChildren().listIterator(); |
1081 | 0 | while ( it.hasNext() ) |
1082 | |
{ |
1083 | 0 | Element elem = (Element) it.next(); |
1084 | 0 | Iterator it2 = domChilds.iterator(); |
1085 | 0 | Xpp3Dom corrDom = null; |
1086 | 0 | while ( it2.hasNext() ) |
1087 | |
{ |
1088 | 0 | Xpp3Dom dm = (Xpp3Dom) it2.next(); |
1089 | 0 | if ( dm.getName().equals( elem.getName() ) ) |
1090 | |
{ |
1091 | 0 | corrDom = dm; |
1092 | 0 | break; |
1093 | |
} |
1094 | 0 | } |
1095 | 0 | if ( corrDom != null ) |
1096 | |
{ |
1097 | 0 | domChilds.remove( corrDom ); |
1098 | 0 | replaceXpp3DOM( elem, corrDom, new Counter( counter.getDepth() + 1 ) ); |
1099 | 0 | counter.increaseCount(); |
1100 | |
} |
1101 | |
else |
1102 | |
{ |
1103 | 0 | parent.removeContent( elem ); |
1104 | |
} |
1105 | 0 | } |
1106 | 0 | Iterator it2 = domChilds.iterator(); |
1107 | 0 | while ( it2.hasNext() ) |
1108 | |
{ |
1109 | 0 | Xpp3Dom dm = (Xpp3Dom) it2.next(); |
1110 | 0 | Element elem = factory.element( dm.getName(), parent.getNamespace() ); |
1111 | 0 | insertAtPreferredLocation( parent, elem, counter ); |
1112 | 0 | counter.increaseCount(); |
1113 | 0 | replaceXpp3DOM( elem, dm, new Counter( counter.getDepth() + 1 ) ); |
1114 | 0 | } |
1115 | 0 | } |
1116 | 0 | else if ( parentDom.getValue() != null ) |
1117 | |
{ |
1118 | 0 | parent.setText( parentDom.getValue() ); |
1119 | |
} |
1120 | 0 | } |
1121 | |
|
1122 | |
|
1123 | |
|
1124 | |
|
1125 | |
|
1126 | |
|
1127 | |
|
1128 | |
|
1129 | |
|
1130 | |
|
1131 | |
|
1132 | |
|
1133 | |
|
1134 | |
|
1135 | |
|
1136 | |
|
1137 | |
|
1138 | |
|
1139 | |
|
1140 | |
|
1141 | |
|
1142 | |
|
1143 | |
|
1144 | |
|
1145 | |
|
1146 | |
|
1147 | |
|
1148 | |
|
1149 | |
|
1150 | |
|
1151 | |
|
1152 | |
|
1153 | |
|
1154 | |
|
1155 | |
|
1156 | |
|
1157 | |
|
1158 | |
|
1159 | |
|
1160 | |
|
1161 | |
|
1162 | |
|
1163 | |
|
1164 | |
|
1165 | |
|
1166 | |
protected void updateActivationFile( ActivationFile value, String xmlTag, Counter counter, Element element ) |
1167 | |
{ |
1168 | 0 | boolean shouldExist = value != null; |
1169 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1170 | 0 | if ( shouldExist ) |
1171 | |
{ |
1172 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1173 | 0 | findAndReplaceSimpleElement( innerCount, root, "missing", value.getMissing(), null ); |
1174 | 0 | findAndReplaceSimpleElement( innerCount, root, "exists", value.getExists(), null ); |
1175 | |
} |
1176 | 0 | } |
1177 | |
|
1178 | |
|
1179 | |
|
1180 | |
|
1181 | |
|
1182 | |
|
1183 | |
|
1184 | |
|
1185 | |
|
1186 | |
protected void updateActivationOS( ActivationOS value, String xmlTag, Counter counter, Element element ) |
1187 | |
{ |
1188 | 0 | boolean shouldExist = value != null; |
1189 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1190 | 0 | if ( shouldExist ) |
1191 | |
{ |
1192 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1193 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
1194 | 0 | findAndReplaceSimpleElement( innerCount, root, "family", value.getFamily(), null ); |
1195 | 0 | findAndReplaceSimpleElement( innerCount, root, "arch", value.getArch(), null ); |
1196 | 0 | findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null ); |
1197 | |
} |
1198 | 0 | } |
1199 | |
|
1200 | |
|
1201 | |
|
1202 | |
|
1203 | |
|
1204 | |
|
1205 | |
|
1206 | |
|
1207 | |
|
1208 | |
protected void updateActivationProperty( ActivationProperty value, String xmlTag, Counter counter, Element element ) |
1209 | |
{ |
1210 | 0 | boolean shouldExist = value != null; |
1211 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1212 | 0 | if ( shouldExist ) |
1213 | |
{ |
1214 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1215 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
1216 | 0 | findAndReplaceSimpleElement( innerCount, root, "value", value.getValue(), null ); |
1217 | |
} |
1218 | 0 | } |
1219 | |
|
1220 | |
|
1221 | |
|
1222 | |
|
1223 | |
|
1224 | |
|
1225 | |
|
1226 | |
|
1227 | |
|
1228 | |
protected void updateBuild( Build value, String xmlTag, Counter counter, Element element ) |
1229 | |
{ |
1230 | 0 | boolean shouldExist = value != null; |
1231 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1232 | 0 | if ( shouldExist ) |
1233 | |
{ |
1234 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1235 | 0 | findAndReplaceSimpleElement( innerCount, root, "sourceDirectory", value.getSourceDirectory(), null ); |
1236 | 0 | findAndReplaceSimpleElement( innerCount, root, "scriptSourceDirectory", value.getScriptSourceDirectory(), |
1237 | |
null ); |
1238 | 0 | findAndReplaceSimpleElement( innerCount, root, "testSourceDirectory", value.getTestSourceDirectory(), null ); |
1239 | 0 | findAndReplaceSimpleElement( innerCount, root, "outputDirectory", value.getOutputDirectory(), null ); |
1240 | 0 | findAndReplaceSimpleElement( innerCount, root, "testOutputDirectory", value.getTestOutputDirectory(), null ); |
1241 | 0 | iterateExtension( innerCount, root, value.getExtensions(), "extensions", "extension" ); |
1242 | 0 | findAndReplaceSimpleElement( innerCount, root, "defaultGoal", value.getDefaultGoal(), null ); |
1243 | 0 | iterateResource( innerCount, root, value.getResources(), "resources", "resource" ); |
1244 | 0 | iterateResource( innerCount, root, value.getTestResources(), "testResources", "testResource" ); |
1245 | 0 | findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null ); |
1246 | 0 | findAndReplaceSimpleElement( innerCount, root, "finalName", value.getFinalName(), null ); |
1247 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getFilters(), "filters", "filter" ); |
1248 | 0 | updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root ); |
1249 | 0 | iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" ); |
1250 | |
} |
1251 | 0 | } |
1252 | |
|
1253 | |
|
1254 | |
|
1255 | |
|
1256 | |
|
1257 | |
|
1258 | |
|
1259 | |
|
1260 | |
|
1261 | |
protected void updateBuildBase( BuildBase value, String xmlTag, Counter counter, Element element ) |
1262 | |
{ |
1263 | 0 | boolean shouldExist = value != null; |
1264 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1265 | 0 | if ( shouldExist ) |
1266 | |
{ |
1267 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1268 | 0 | findAndReplaceSimpleElement( innerCount, root, "defaultGoal", value.getDefaultGoal(), null ); |
1269 | 0 | iterateResource( innerCount, root, value.getResources(), "resources", "resource" ); |
1270 | 0 | iterateResource( innerCount, root, value.getTestResources(), "testResources", "testResource" ); |
1271 | 0 | findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null ); |
1272 | 0 | findAndReplaceSimpleElement( innerCount, root, "finalName", value.getFinalName(), null ); |
1273 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getFilters(), "filters", "filter" ); |
1274 | 0 | updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root ); |
1275 | 0 | iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" ); |
1276 | |
} |
1277 | 0 | } |
1278 | |
|
1279 | |
|
1280 | |
|
1281 | |
|
1282 | |
|
1283 | |
|
1284 | |
|
1285 | |
|
1286 | |
|
1287 | |
protected void updateCiManagement( CiManagement value, String xmlTag, Counter counter, Element element ) |
1288 | |
{ |
1289 | 0 | boolean shouldExist = value != null; |
1290 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1291 | 0 | if ( shouldExist ) |
1292 | |
{ |
1293 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1294 | 0 | findAndReplaceSimpleElement( innerCount, root, "system", value.getSystem(), null ); |
1295 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
1296 | 0 | iterateNotifier( innerCount, root, value.getNotifiers(), "notifiers", "notifier" ); |
1297 | |
} |
1298 | 0 | } |
1299 | |
|
1300 | |
|
1301 | |
|
1302 | |
|
1303 | |
|
1304 | |
|
1305 | |
|
1306 | |
|
1307 | |
|
1308 | |
protected void updateConfigurationContainer( ConfigurationContainer value, String xmlTag, Counter counter, |
1309 | |
Element element ) |
1310 | |
{ |
1311 | 0 | boolean shouldExist = value != null; |
1312 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1313 | 0 | if ( shouldExist ) |
1314 | |
{ |
1315 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1316 | 0 | findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null ); |
1317 | 0 | findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() ); |
1318 | |
} |
1319 | 0 | } |
1320 | |
|
1321 | |
|
1322 | |
|
1323 | |
|
1324 | |
|
1325 | |
|
1326 | |
|
1327 | |
|
1328 | |
|
1329 | |
protected void updateContributor( Contributor value, String xmlTag, Counter counter, Element element ) |
1330 | |
{ |
1331 | 0 | Element root = element; |
1332 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1333 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
1334 | 0 | findAndReplaceSimpleElement( innerCount, root, "email", value.getEmail(), null ); |
1335 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
1336 | 0 | findAndReplaceSimpleElement( innerCount, root, "organization", value.getOrganization(), null ); |
1337 | 0 | findAndReplaceSimpleElement( innerCount, root, "organizationUrl", value.getOrganizationUrl(), null ); |
1338 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getRoles(), "roles", "role" ); |
1339 | 0 | findAndReplaceSimpleElement( innerCount, root, "timezone", value.getTimezone(), null ); |
1340 | 0 | findAndReplaceProperties( innerCount, root, "properties", value.getProperties() ); |
1341 | 0 | } |
1342 | |
|
1343 | |
|
1344 | |
|
1345 | |
|
1346 | |
|
1347 | |
|
1348 | |
|
1349 | |
|
1350 | |
|
1351 | |
protected void updateDependency( Dependency value, String xmlTag, Counter counter, Element element ) |
1352 | |
{ |
1353 | 0 | Element root = element; |
1354 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1355 | 0 | findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null ); |
1356 | 0 | findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null ); |
1357 | 0 | findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null ); |
1358 | 0 | findAndReplaceSimpleElement( innerCount, root, "type", value.getType(), "jar" ); |
1359 | 0 | findAndReplaceSimpleElement( innerCount, root, "classifier", value.getClassifier(), null ); |
1360 | 0 | findAndReplaceSimpleElement( innerCount, root, "scope", value.getScope(), null ); |
1361 | 0 | findAndReplaceSimpleElement( innerCount, root, "systemPath", value.getSystemPath(), null ); |
1362 | 0 | iterateExclusion( innerCount, root, value.getExclusions(), "exclusions", "exclusion" ); |
1363 | 0 | findAndReplaceSimpleElement( innerCount, root, "optional", !value.isOptional() ? null |
1364 | |
: String.valueOf( value.isOptional() ), "false" ); |
1365 | 0 | } |
1366 | |
|
1367 | |
|
1368 | |
|
1369 | |
|
1370 | |
|
1371 | |
|
1372 | |
|
1373 | |
|
1374 | |
|
1375 | |
protected void updateDependencyManagement( DependencyManagement value, String xmlTag, Counter counter, |
1376 | |
Element element ) |
1377 | |
{ |
1378 | 0 | boolean shouldExist = value != null; |
1379 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1380 | 0 | if ( shouldExist ) |
1381 | |
{ |
1382 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1383 | 0 | iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" ); |
1384 | |
} |
1385 | 0 | } |
1386 | |
|
1387 | |
|
1388 | |
|
1389 | |
|
1390 | |
|
1391 | |
|
1392 | |
|
1393 | |
|
1394 | |
|
1395 | |
protected void updateDeploymentRepository( DeploymentRepository value, String xmlTag, Counter counter, |
1396 | |
Element element ) |
1397 | |
{ |
1398 | 0 | boolean shouldExist = value != null; |
1399 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1400 | 0 | if ( shouldExist ) |
1401 | |
{ |
1402 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1403 | 0 | findAndReplaceSimpleElement( innerCount, root, "uniqueVersion", value.isUniqueVersion() ? null |
1404 | |
: String.valueOf( value.isUniqueVersion() ), "true" ); |
1405 | 0 | findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null ); |
1406 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
1407 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
1408 | 0 | findAndReplaceSimpleElement( innerCount, root, "layout", value.getLayout(), "default" ); |
1409 | |
} |
1410 | 0 | } |
1411 | |
|
1412 | |
|
1413 | |
|
1414 | |
|
1415 | |
|
1416 | |
|
1417 | |
|
1418 | |
|
1419 | |
|
1420 | |
protected void updateDeveloper( Developer value, String xmlTag, Counter counter, Element element ) |
1421 | |
{ |
1422 | 0 | Element root = element; |
1423 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1424 | 0 | findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null ); |
1425 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
1426 | 0 | findAndReplaceSimpleElement( innerCount, root, "email", value.getEmail(), null ); |
1427 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
1428 | 0 | findAndReplaceSimpleElement( innerCount, root, "organization", value.getOrganization(), null ); |
1429 | 0 | findAndReplaceSimpleElement( innerCount, root, "organizationUrl", value.getOrganizationUrl(), null ); |
1430 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getRoles(), "roles", "role" ); |
1431 | 0 | findAndReplaceSimpleElement( innerCount, root, "timezone", value.getTimezone(), null ); |
1432 | 0 | findAndReplaceProperties( innerCount, root, "properties", value.getProperties() ); |
1433 | 0 | } |
1434 | |
|
1435 | |
|
1436 | |
|
1437 | |
|
1438 | |
|
1439 | |
|
1440 | |
|
1441 | |
|
1442 | |
|
1443 | |
protected void updateDistributionManagement( DistributionManagement value, String xmlTag, Counter counter, |
1444 | |
Element element ) |
1445 | |
{ |
1446 | 0 | boolean shouldExist = value != null; |
1447 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1448 | 0 | if ( shouldExist ) |
1449 | |
{ |
1450 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1451 | 0 | updateDeploymentRepository( value.getRepository(), "repository", innerCount, root ); |
1452 | 0 | updateDeploymentRepository( value.getSnapshotRepository(), "snapshotRepository", innerCount, root ); |
1453 | 0 | updateSite( value.getSite(), "site", innerCount, root ); |
1454 | 0 | findAndReplaceSimpleElement( innerCount, root, "downloadUrl", value.getDownloadUrl(), null ); |
1455 | 0 | updateRelocation( value.getRelocation(), "relocation", innerCount, root ); |
1456 | 0 | findAndReplaceSimpleElement( innerCount, root, "status", value.getStatus(), null ); |
1457 | |
} |
1458 | 0 | } |
1459 | |
|
1460 | |
|
1461 | |
|
1462 | |
|
1463 | |
|
1464 | |
|
1465 | |
|
1466 | |
|
1467 | |
|
1468 | |
protected Element updateElement( Counter counter, Element parent, String name, boolean shouldExist ) |
1469 | |
{ |
1470 | 0 | Element element = parent.getChild( name, parent.getNamespace() ); |
1471 | 0 | if ( element != null && shouldExist ) |
1472 | |
{ |
1473 | 0 | counter.increaseCount(); |
1474 | |
} |
1475 | 0 | if ( element == null && shouldExist ) |
1476 | |
{ |
1477 | 0 | element = factory.element( name, parent.getNamespace() ); |
1478 | 0 | insertAtPreferredLocation( parent, element, counter ); |
1479 | 0 | counter.increaseCount(); |
1480 | |
} |
1481 | 0 | if ( !shouldExist && element != null ) |
1482 | |
{ |
1483 | 0 | int index = parent.indexOf( element ); |
1484 | 0 | if ( index > 0 ) |
1485 | |
{ |
1486 | 0 | Content previous = parent.getContent( index - 1 ); |
1487 | 0 | if ( previous instanceof Text ) |
1488 | |
{ |
1489 | 0 | Text txt = (Text) previous; |
1490 | 0 | if ( txt.getTextTrim().length() == 0 ) |
1491 | |
{ |
1492 | 0 | parent.removeContent( txt ); |
1493 | |
} |
1494 | |
} |
1495 | |
} |
1496 | 0 | parent.removeContent( element ); |
1497 | |
} |
1498 | 0 | return element; |
1499 | |
} |
1500 | |
|
1501 | |
|
1502 | |
|
1503 | |
|
1504 | |
|
1505 | |
|
1506 | |
|
1507 | |
|
1508 | |
|
1509 | |
protected void updateExclusion( Exclusion value, String xmlTag, Counter counter, Element element ) |
1510 | |
{ |
1511 | 0 | Element root = element; |
1512 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1513 | 0 | findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null ); |
1514 | 0 | findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null ); |
1515 | 0 | } |
1516 | |
|
1517 | |
|
1518 | |
|
1519 | |
|
1520 | |
|
1521 | |
|
1522 | |
|
1523 | |
|
1524 | |
|
1525 | |
protected void updateExtension( Extension value, String xmlTag, Counter counter, Element element ) |
1526 | |
{ |
1527 | 0 | Element root = element; |
1528 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1529 | 0 | findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null ); |
1530 | 0 | findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null ); |
1531 | 0 | findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null ); |
1532 | 0 | } |
1533 | |
|
1534 | |
|
1535 | |
|
1536 | |
|
1537 | |
|
1538 | |
|
1539 | |
|
1540 | |
|
1541 | |
|
1542 | |
protected void updateFileSet( FileSet value, String xmlTag, Counter counter, Element element ) |
1543 | |
{ |
1544 | 0 | boolean shouldExist = value != null; |
1545 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1546 | 0 | if ( shouldExist ) |
1547 | |
{ |
1548 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1549 | 0 | findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null ); |
1550 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getIncludes(), "includes", "include" ); |
1551 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getExcludes(), "excludes", "exclude" ); |
1552 | |
} |
1553 | 0 | } |
1554 | |
|
1555 | |
|
1556 | |
|
1557 | |
|
1558 | |
|
1559 | |
|
1560 | |
|
1561 | |
|
1562 | |
|
1563 | |
protected void updateIssueManagement( IssueManagement value, String xmlTag, Counter counter, Element element ) |
1564 | |
{ |
1565 | 0 | boolean shouldExist = value != null; |
1566 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1567 | 0 | if ( shouldExist ) |
1568 | |
{ |
1569 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1570 | 0 | findAndReplaceSimpleElement( innerCount, root, "system", value.getSystem(), null ); |
1571 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
1572 | |
} |
1573 | 0 | } |
1574 | |
|
1575 | |
|
1576 | |
|
1577 | |
|
1578 | |
|
1579 | |
|
1580 | |
|
1581 | |
|
1582 | |
|
1583 | |
protected void updateLicense( License value, String xmlTag, Counter counter, Element element ) |
1584 | |
{ |
1585 | 0 | Element root = element; |
1586 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1587 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
1588 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
1589 | 0 | findAndReplaceSimpleElement( innerCount, root, "distribution", value.getDistribution(), null ); |
1590 | 0 | findAndReplaceSimpleElement( innerCount, root, "comments", value.getComments(), null ); |
1591 | 0 | } |
1592 | |
|
1593 | |
|
1594 | |
|
1595 | |
|
1596 | |
|
1597 | |
|
1598 | |
|
1599 | |
|
1600 | |
|
1601 | |
protected void updateMailingList( MailingList value, String xmlTag, Counter counter, Element element ) |
1602 | |
{ |
1603 | 0 | Element root = element; |
1604 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1605 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
1606 | 0 | findAndReplaceSimpleElement( innerCount, root, "subscribe", value.getSubscribe(), null ); |
1607 | 0 | findAndReplaceSimpleElement( innerCount, root, "unsubscribe", value.getUnsubscribe(), null ); |
1608 | 0 | findAndReplaceSimpleElement( innerCount, root, "post", value.getPost(), null ); |
1609 | 0 | findAndReplaceSimpleElement( innerCount, root, "archive", value.getArchive(), null ); |
1610 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getOtherArchives(), "otherArchives", "otherArchive" ); |
1611 | 0 | } |
1612 | |
|
1613 | |
|
1614 | |
|
1615 | |
|
1616 | |
|
1617 | |
|
1618 | |
|
1619 | |
|
1620 | |
|
1621 | |
protected void updateModel( Model value, String xmlTag, Counter counter, Element element ) |
1622 | |
{ |
1623 | 0 | Element root = element; |
1624 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1625 | 0 | updateParent( value.getParent(), "parent", innerCount, root ); |
1626 | 0 | findAndReplaceSimpleElement( innerCount, root, "modelVersion", value.getModelVersion(), null ); |
1627 | 0 | findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null ); |
1628 | 0 | findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null ); |
1629 | 0 | findAndReplaceSimpleElement( innerCount, root, "packaging", value.getPackaging(), "jar" ); |
1630 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
1631 | 0 | findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null ); |
1632 | 0 | findAndReplaceSimpleElement( innerCount, root, "description", value.getDescription(), null ); |
1633 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
1634 | 0 | updatePrerequisites( value.getPrerequisites(), "prerequisites", innerCount, root ); |
1635 | 0 | updateIssueManagement( value.getIssueManagement(), "issueManagement", innerCount, root ); |
1636 | 0 | updateCiManagement( value.getCiManagement(), "ciManagement", innerCount, root ); |
1637 | 0 | findAndReplaceSimpleElement( innerCount, root, "inceptionYear", value.getInceptionYear(), null ); |
1638 | 0 | iterateMailingList( innerCount, root, value.getMailingLists(), "mailingLists", "mailingList" ); |
1639 | 0 | iterateDeveloper( innerCount, root, value.getDevelopers(), "developers", "developer" ); |
1640 | 0 | iterateContributor( innerCount, root, value.getContributors(), "contributors", "contributor" ); |
1641 | 0 | iterateLicense( innerCount, root, value.getLicenses(), "licenses", "license" ); |
1642 | 0 | updateScm( value.getScm(), "scm", innerCount, root ); |
1643 | 0 | updateOrganization( value.getOrganization(), "organization", innerCount, root ); |
1644 | 0 | updateBuild( value.getBuild(), "build", innerCount, root ); |
1645 | 0 | iterateProfile( innerCount, root, value.getProfiles(), "profiles", "profile" ); |
1646 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" ); |
1647 | 0 | iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" ); |
1648 | 0 | iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository" ); |
1649 | 0 | iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" ); |
1650 | 0 | findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() ); |
1651 | 0 | updateReporting( value.getReporting(), "reporting", innerCount, root ); |
1652 | 0 | updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root ); |
1653 | 0 | updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root ); |
1654 | 0 | findAndReplaceProperties( innerCount, root, "properties", value.getProperties() ); |
1655 | 0 | } |
1656 | |
|
1657 | |
|
1658 | |
|
1659 | |
|
1660 | |
|
1661 | |
|
1662 | |
|
1663 | |
|
1664 | |
|
1665 | |
protected void updateModelBase( ModelBase value, String xmlTag, Counter counter, Element element ) |
1666 | |
{ |
1667 | 0 | boolean shouldExist = value != null; |
1668 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1669 | 0 | if ( shouldExist ) |
1670 | |
{ |
1671 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1672 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" ); |
1673 | 0 | iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" ); |
1674 | 0 | iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories", |
1675 | |
"pluginRepository" ); |
1676 | 0 | iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" ); |
1677 | 0 | findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() ); |
1678 | 0 | updateReporting( value.getReporting(), "reporting", innerCount, root ); |
1679 | 0 | updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root ); |
1680 | 0 | updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root ); |
1681 | 0 | findAndReplaceProperties( innerCount, root, "properties", value.getProperties() ); |
1682 | |
} |
1683 | 0 | } |
1684 | |
|
1685 | |
|
1686 | |
|
1687 | |
|
1688 | |
|
1689 | |
|
1690 | |
|
1691 | |
|
1692 | |
|
1693 | |
protected void updateNotifier( Notifier value, String xmlTag, Counter counter, Element element ) |
1694 | |
{ |
1695 | 0 | Element root = element; |
1696 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1697 | 0 | findAndReplaceSimpleElement( innerCount, root, "type", value.getType(), "mail" ); |
1698 | 0 | findAndReplaceSimpleElement( innerCount, root, "sendOnError", value.isSendOnError() ? null |
1699 | |
: String.valueOf( value.isSendOnError() ), "true" ); |
1700 | 0 | findAndReplaceSimpleElement( innerCount, root, "sendOnFailure", value.isSendOnFailure() ? null |
1701 | |
: String.valueOf( value.isSendOnFailure() ), "true" ); |
1702 | 0 | findAndReplaceSimpleElement( innerCount, root, "sendOnSuccess", value.isSendOnSuccess() ? null |
1703 | |
: String.valueOf( value.isSendOnSuccess() ), "true" ); |
1704 | 0 | findAndReplaceSimpleElement( innerCount, root, "sendOnWarning", value.isSendOnWarning() ? null |
1705 | |
: String.valueOf( value.isSendOnWarning() ), "true" ); |
1706 | 0 | findAndReplaceSimpleElement( innerCount, root, "address", value.getAddress(), null ); |
1707 | 0 | findAndReplaceProperties( innerCount, root, "configuration", value.getConfiguration() ); |
1708 | 0 | } |
1709 | |
|
1710 | |
|
1711 | |
|
1712 | |
|
1713 | |
|
1714 | |
|
1715 | |
|
1716 | |
|
1717 | |
|
1718 | |
protected void updateOrganization( Organization value, String xmlTag, Counter counter, Element element ) |
1719 | |
{ |
1720 | 0 | boolean shouldExist = value != null; |
1721 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1722 | 0 | if ( shouldExist ) |
1723 | |
{ |
1724 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1725 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
1726 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
1727 | |
} |
1728 | 0 | } |
1729 | |
|
1730 | |
|
1731 | |
|
1732 | |
|
1733 | |
|
1734 | |
|
1735 | |
|
1736 | |
|
1737 | |
|
1738 | |
protected void updateParent( Parent value, String xmlTag, Counter counter, Element element ) |
1739 | |
{ |
1740 | 0 | boolean shouldExist = value != null; |
1741 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1742 | 0 | if ( shouldExist ) |
1743 | |
{ |
1744 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1745 | 0 | findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null ); |
1746 | 0 | findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null ); |
1747 | 0 | findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null ); |
1748 | 0 | findAndReplaceSimpleElement( innerCount, root, "relativePath", value.getRelativePath(), "../pom.xml" ); |
1749 | |
} |
1750 | 0 | } |
1751 | |
|
1752 | |
|
1753 | |
|
1754 | |
|
1755 | |
|
1756 | |
|
1757 | |
|
1758 | |
|
1759 | |
|
1760 | |
protected void updatePatternSet( PatternSet value, String xmlTag, Counter counter, Element element ) |
1761 | |
{ |
1762 | 0 | boolean shouldExist = value != null; |
1763 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1764 | 0 | if ( shouldExist ) |
1765 | |
{ |
1766 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1767 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getIncludes(), "includes", "include" ); |
1768 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getExcludes(), "excludes", "exclude" ); |
1769 | |
} |
1770 | 0 | } |
1771 | |
|
1772 | |
|
1773 | |
|
1774 | |
|
1775 | |
|
1776 | |
|
1777 | |
|
1778 | |
|
1779 | |
|
1780 | |
protected void updatePlugin( Plugin value, String xmlTag, Counter counter, Element element ) |
1781 | |
{ |
1782 | 0 | Element root = element; |
1783 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1784 | 0 | findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), "org.apache.maven.plugins" ); |
1785 | 0 | findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null ); |
1786 | 0 | findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null ); |
1787 | 0 | findAndReplaceSimpleElement( innerCount, root, "extensions", !value.isExtensions() ? null |
1788 | |
: String.valueOf( value.isExtensions() ), "false" ); |
1789 | 0 | iteratePluginExecution( innerCount, root, value.getExecutions(), "executions", "execution" ); |
1790 | 0 | iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" ); |
1791 | 0 | findAndReplaceXpp3DOM( innerCount, root, "goals", (Xpp3Dom) value.getGoals() ); |
1792 | 0 | findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null ); |
1793 | 0 | findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() ); |
1794 | 0 | } |
1795 | |
|
1796 | |
|
1797 | |
|
1798 | |
|
1799 | |
|
1800 | |
|
1801 | |
|
1802 | |
|
1803 | |
|
1804 | |
protected void updatePluginConfiguration( PluginConfiguration value, String xmlTag, Counter counter, Element element ) |
1805 | |
{ |
1806 | 0 | boolean shouldExist = value != null; |
1807 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1808 | 0 | if ( shouldExist ) |
1809 | |
{ |
1810 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1811 | 0 | updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root ); |
1812 | 0 | iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" ); |
1813 | |
} |
1814 | 0 | } |
1815 | |
|
1816 | |
|
1817 | |
|
1818 | |
|
1819 | |
|
1820 | |
|
1821 | |
|
1822 | |
|
1823 | |
|
1824 | |
protected void updatePluginContainer( PluginContainer value, String xmlTag, Counter counter, Element element ) |
1825 | |
{ |
1826 | 0 | boolean shouldExist = value != null; |
1827 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1828 | 0 | if ( shouldExist ) |
1829 | |
{ |
1830 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1831 | 0 | iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" ); |
1832 | |
} |
1833 | 0 | } |
1834 | |
|
1835 | |
|
1836 | |
|
1837 | |
|
1838 | |
|
1839 | |
|
1840 | |
|
1841 | |
|
1842 | |
|
1843 | |
protected void updatePluginExecution( PluginExecution value, String xmlTag, Counter counter, Element element ) |
1844 | |
{ |
1845 | 0 | Element root = element; |
1846 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1847 | 0 | findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), "default" ); |
1848 | 0 | findAndReplaceSimpleElement( innerCount, root, "phase", value.getPhase(), null ); |
1849 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getGoals(), "goals", "goal" ); |
1850 | 0 | findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null ); |
1851 | 0 | findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() ); |
1852 | 0 | } |
1853 | |
|
1854 | |
|
1855 | |
|
1856 | |
|
1857 | |
|
1858 | |
|
1859 | |
|
1860 | |
|
1861 | |
|
1862 | |
protected void updatePluginManagement( PluginManagement value, String xmlTag, Counter counter, Element element ) |
1863 | |
{ |
1864 | 0 | boolean shouldExist = value != null; |
1865 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1866 | 0 | if ( shouldExist ) |
1867 | |
{ |
1868 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1869 | 0 | iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" ); |
1870 | |
} |
1871 | 0 | } |
1872 | |
|
1873 | |
|
1874 | |
|
1875 | |
|
1876 | |
|
1877 | |
|
1878 | |
|
1879 | |
|
1880 | |
|
1881 | |
protected void updatePrerequisites( Prerequisites value, String xmlTag, Counter counter, Element element ) |
1882 | |
{ |
1883 | 0 | boolean shouldExist = value != null; |
1884 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1885 | 0 | if ( shouldExist ) |
1886 | |
{ |
1887 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1888 | 0 | findAndReplaceSimpleElement( innerCount, root, "maven", value.getMaven(), "2.0" ); |
1889 | |
} |
1890 | 0 | } |
1891 | |
|
1892 | |
|
1893 | |
|
1894 | |
|
1895 | |
|
1896 | |
|
1897 | |
|
1898 | |
|
1899 | |
|
1900 | |
protected void updateProfile( Profile value, String xmlTag, Counter counter, Element element ) |
1901 | |
{ |
1902 | 0 | Element root = element; |
1903 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1904 | 0 | findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), "default" ); |
1905 | |
|
1906 | 0 | updateBuildBase( value.getBuild(), "build", innerCount, root ); |
1907 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" ); |
1908 | 0 | iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" ); |
1909 | 0 | iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository" ); |
1910 | 0 | iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" ); |
1911 | 0 | findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() ); |
1912 | 0 | updateReporting( value.getReporting(), "reporting", innerCount, root ); |
1913 | 0 | updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root ); |
1914 | 0 | updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root ); |
1915 | 0 | findAndReplaceProperties( innerCount, root, "properties", value.getProperties() ); |
1916 | 0 | } |
1917 | |
|
1918 | |
|
1919 | |
|
1920 | |
|
1921 | |
|
1922 | |
|
1923 | |
|
1924 | |
|
1925 | |
|
1926 | |
protected void updateRelocation( Relocation value, String xmlTag, Counter counter, Element element ) |
1927 | |
{ |
1928 | 0 | boolean shouldExist = value != null; |
1929 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1930 | 0 | if ( shouldExist ) |
1931 | |
{ |
1932 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1933 | 0 | findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null ); |
1934 | 0 | findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null ); |
1935 | 0 | findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null ); |
1936 | 0 | findAndReplaceSimpleElement( innerCount, root, "message", value.getMessage(), null ); |
1937 | |
} |
1938 | 0 | } |
1939 | |
|
1940 | |
|
1941 | |
|
1942 | |
|
1943 | |
|
1944 | |
|
1945 | |
|
1946 | |
|
1947 | |
|
1948 | |
protected void updateReportPlugin( ReportPlugin value, String xmlTag, Counter counter, Element element ) |
1949 | |
{ |
1950 | 0 | Element root = element; |
1951 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1952 | 0 | findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), "org.apache.maven.plugins" ); |
1953 | 0 | findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null ); |
1954 | 0 | findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null ); |
1955 | 0 | findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null ); |
1956 | 0 | findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() ); |
1957 | 0 | iterateReportSet( innerCount, root, value.getReportSets(), "reportSets", "reportSet" ); |
1958 | 0 | } |
1959 | |
|
1960 | |
|
1961 | |
|
1962 | |
|
1963 | |
|
1964 | |
|
1965 | |
|
1966 | |
|
1967 | |
|
1968 | |
protected void updateReportSet( ReportSet value, String xmlTag, Counter counter, Element element ) |
1969 | |
{ |
1970 | 0 | Element root = element; |
1971 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1972 | 0 | findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), "default" ); |
1973 | 0 | findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() ); |
1974 | 0 | findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null ); |
1975 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getReports(), "reports", "report" ); |
1976 | 0 | } |
1977 | |
|
1978 | |
|
1979 | |
|
1980 | |
|
1981 | |
|
1982 | |
|
1983 | |
|
1984 | |
|
1985 | |
|
1986 | |
protected void updateReporting( Reporting value, String xmlTag, Counter counter, Element element ) |
1987 | |
{ |
1988 | 0 | boolean shouldExist = value != null; |
1989 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
1990 | 0 | if ( shouldExist ) |
1991 | |
{ |
1992 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
1993 | 0 | findAndReplaceSimpleElement( innerCount, root, "excludeDefaults", !value.isExcludeDefaults() ? null |
1994 | |
: String.valueOf( value.isExcludeDefaults() ), "false" ); |
1995 | 0 | findAndReplaceSimpleElement( innerCount, root, "outputDirectory", value.getOutputDirectory(), null ); |
1996 | 0 | iterateReportPlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" ); |
1997 | |
} |
1998 | 0 | } |
1999 | |
|
2000 | |
|
2001 | |
|
2002 | |
|
2003 | |
|
2004 | |
|
2005 | |
|
2006 | |
|
2007 | |
|
2008 | |
protected void updateRepository( Repository value, String xmlTag, Counter counter, Element element ) |
2009 | |
{ |
2010 | 0 | Element root = element; |
2011 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
2012 | 0 | updateRepositoryPolicy( value.getReleases(), "releases", innerCount, root ); |
2013 | 0 | updateRepositoryPolicy( value.getSnapshots(), "snapshots", innerCount, root ); |
2014 | 0 | findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null ); |
2015 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
2016 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
2017 | 0 | findAndReplaceSimpleElement( innerCount, root, "layout", value.getLayout(), "default" ); |
2018 | 0 | } |
2019 | |
|
2020 | |
|
2021 | |
|
2022 | |
|
2023 | |
|
2024 | |
|
2025 | |
|
2026 | |
|
2027 | |
|
2028 | |
protected void updateRepositoryBase( RepositoryBase value, String xmlTag, Counter counter, Element element ) |
2029 | |
{ |
2030 | 0 | boolean shouldExist = value != null; |
2031 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
2032 | 0 | if ( shouldExist ) |
2033 | |
{ |
2034 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
2035 | 0 | findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null ); |
2036 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
2037 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
2038 | 0 | findAndReplaceSimpleElement( innerCount, root, "layout", value.getLayout(), "default" ); |
2039 | |
} |
2040 | 0 | } |
2041 | |
|
2042 | |
|
2043 | |
|
2044 | |
|
2045 | |
|
2046 | |
|
2047 | |
|
2048 | |
|
2049 | |
|
2050 | |
protected void updateRepositoryPolicy( RepositoryPolicy value, String xmlTag, Counter counter, Element element ) |
2051 | |
{ |
2052 | 0 | boolean shouldExist = value != null; |
2053 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
2054 | 0 | if ( shouldExist ) |
2055 | |
{ |
2056 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
2057 | 0 | findAndReplaceSimpleElement( innerCount, root, "enabled", value.isEnabled() ? null |
2058 | |
: String.valueOf( value.isEnabled() ), "true" ); |
2059 | 0 | findAndReplaceSimpleElement( innerCount, root, "updatePolicy", value.getUpdatePolicy(), null ); |
2060 | 0 | findAndReplaceSimpleElement( innerCount, root, "checksumPolicy", value.getChecksumPolicy(), null ); |
2061 | |
} |
2062 | 0 | } |
2063 | |
|
2064 | |
|
2065 | |
|
2066 | |
|
2067 | |
|
2068 | |
|
2069 | |
|
2070 | |
|
2071 | |
|
2072 | |
protected void updateResource( Resource value, String xmlTag, Counter counter, Element element ) |
2073 | |
{ |
2074 | 0 | Element root = element; |
2075 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
2076 | 0 | findAndReplaceSimpleElement( innerCount, root, "targetPath", value.getTargetPath(), null ); |
2077 | 0 | findAndReplaceSimpleElement( innerCount, root, "filtering", !value.isFiltering() ? null |
2078 | |
: String.valueOf( value.isFiltering() ), "false" ); |
2079 | 0 | findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null ); |
2080 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getIncludes(), "includes", "include" ); |
2081 | 0 | findAndReplaceSimpleLists( innerCount, root, value.getExcludes(), "excludes", "exclude" ); |
2082 | 0 | } |
2083 | |
|
2084 | |
|
2085 | |
|
2086 | |
|
2087 | |
|
2088 | |
|
2089 | |
|
2090 | |
|
2091 | |
|
2092 | |
protected void updateScm( Scm value, String xmlTag, Counter counter, Element element ) |
2093 | |
{ |
2094 | 0 | boolean shouldExist = value != null; |
2095 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
2096 | 0 | if ( shouldExist ) |
2097 | |
{ |
2098 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
2099 | 0 | findAndReplaceSimpleElement( innerCount, root, "connection", value.getConnection(), null ); |
2100 | 0 | findAndReplaceSimpleElement( innerCount, root, "developerConnection", value.getDeveloperConnection(), null ); |
2101 | 0 | findAndReplaceSimpleElement( innerCount, root, "tag", value.getTag(), "HEAD" ); |
2102 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
2103 | |
} |
2104 | 0 | } |
2105 | |
|
2106 | |
|
2107 | |
|
2108 | |
|
2109 | |
|
2110 | |
|
2111 | |
|
2112 | |
|
2113 | |
|
2114 | |
protected void updateSite( Site value, String xmlTag, Counter counter, Element element ) |
2115 | |
{ |
2116 | 0 | boolean shouldExist = value != null; |
2117 | 0 | Element root = updateElement( counter, element, xmlTag, shouldExist ); |
2118 | 0 | if ( shouldExist ) |
2119 | |
{ |
2120 | 0 | Counter innerCount = new Counter( counter.getDepth() + 1 ); |
2121 | 0 | findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null ); |
2122 | 0 | findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); |
2123 | 0 | findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); |
2124 | |
} |
2125 | 0 | } |
2126 | |
|
2127 | |
|
2128 | |
|
2129 | |
|
2130 | |
|
2131 | |
|
2132 | |
|
2133 | |
|
2134 | |
|
2135 | |
public void write( Model project, Document document, OutputStream stream ) |
2136 | |
throws java.io.IOException |
2137 | |
{ |
2138 | 0 | updateModel( project, "project", new Counter( 0 ), document.getRootElement() ); |
2139 | 0 | XMLOutputter outputter = new XMLOutputter(); |
2140 | 0 | Format format = Format.getPrettyFormat(); |
2141 | 0 | format.setIndent( " " ).setLineSeparator( System.getProperty( "line.separator" ) ); |
2142 | 0 | outputter.setFormat( format ); |
2143 | 0 | outputter.output( document, stream ); |
2144 | 0 | } |
2145 | |
|
2146 | |
|
2147 | |
|
2148 | |
|
2149 | |
|
2150 | |
|
2151 | |
|
2152 | |
|
2153 | |
public void write( Model project, Document document, OutputStreamWriter writer ) |
2154 | |
throws java.io.IOException |
2155 | |
{ |
2156 | 0 | Format format = Format.getRawFormat(); |
2157 | 0 | format.setEncoding( writer.getEncoding() ).setLineSeparator( System.getProperty( "line.separator" ) ); |
2158 | 0 | write( project, document, writer, format ); |
2159 | 0 | } |
2160 | |
|
2161 | |
|
2162 | |
|
2163 | |
|
2164 | |
|
2165 | |
|
2166 | |
|
2167 | |
|
2168 | |
|
2169 | |
public void write( Model project, Document document, Writer writer, Format jdomFormat ) |
2170 | |
throws java.io.IOException |
2171 | |
{ |
2172 | 0 | updateModel( project, "project", new Counter( 0 ), document.getRootElement() ); |
2173 | 0 | XMLOutputter outputter = new XMLOutputter(); |
2174 | 0 | outputter.setFormat( jdomFormat ); |
2175 | 0 | outputter.output( document, writer ); |
2176 | 0 | } |
2177 | |
|
2178 | |
|
2179 | |
|
2180 | |
|
2181 | |
|
2182 | |
|
2183 | |
|
2184 | |
|
2185 | |
|
2186 | |
|
2187 | |
public class Counter |
2188 | |
{ |
2189 | |
|
2190 | |
|
2191 | |
|
2192 | |
|
2193 | |
|
2194 | |
|
2195 | |
|
2196 | |
|
2197 | 0 | private int currentIndex = 0; |
2198 | |
|
2199 | |
|
2200 | |
|
2201 | |
|
2202 | |
private int level; |
2203 | |
|
2204 | |
|
2205 | |
|
2206 | |
|
2207 | |
|
2208 | |
public Counter( int depthLevel ) |
2209 | 0 | { |
2210 | 0 | level = depthLevel; |
2211 | 0 | } |
2212 | |
|
2213 | |
|
2214 | |
|
2215 | |
|
2216 | |
|
2217 | |
|
2218 | |
|
2219 | |
|
2220 | |
public int getCurrentIndex() |
2221 | |
{ |
2222 | 0 | return currentIndex; |
2223 | |
} |
2224 | |
|
2225 | |
|
2226 | |
|
2227 | |
|
2228 | |
public int getDepth() |
2229 | |
{ |
2230 | 0 | return level; |
2231 | |
} |
2232 | |
|
2233 | |
|
2234 | |
|
2235 | |
|
2236 | |
public void increaseCount() |
2237 | |
{ |
2238 | 0 | currentIndex = currentIndex + 1; |
2239 | 0 | } |
2240 | |
|
2241 | |
} |
2242 | |
|
2243 | |
} |