1 package org.apache.maven.doxia.sink;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.LinkedList;
23 import java.util.List;
24 import java.util.Stack;
25
26
27
28
29
30
31
32
33
34 public class WellformednessCheckingSink
35 extends AbstractSink
36 {
37 private final Stack<String> elements = new Stack<String>();
38
39 private final List<String> errors = new LinkedList<String>();
40
41
42 public void head()
43 {
44 startElement( "head" );
45 }
46
47
48 public void head_()
49 {
50 checkWellformedness( "head" );
51 }
52
53
54 public void body()
55 {
56 startElement( "body" );
57 }
58
59
60 public void body_()
61 {
62 checkWellformedness( "body" );
63 }
64
65
66 public void section1()
67 {
68 startElement( "section1" );
69 }
70
71
72 public void section1_()
73 {
74 checkWellformedness( "section1" );
75 }
76
77
78 public void section2()
79 {
80 startElement( "section2" );
81 }
82
83
84 public void section2_()
85 {
86 checkWellformedness( "section2" );
87 }
88
89
90 public void section3()
91 {
92 startElement( "section3" );
93 }
94
95
96 public void section3_()
97 {
98 checkWellformedness( "section3" );
99 }
100
101
102 public void section4()
103 {
104 startElement( "section4" );
105 }
106
107
108 public void section4_()
109 {
110 checkWellformedness( "section4" );
111 }
112
113
114 public void section5()
115 {
116 startElement( "section5" );
117 }
118
119
120 public void section5_()
121 {
122 checkWellformedness( "section5" );
123 }
124
125
126 public void list()
127 {
128 startElement( "list" );
129 }
130
131
132 public void list_()
133 {
134 checkWellformedness( "list" );
135 }
136
137
138 public void listItem()
139 {
140 startElement( "listItem" );
141 }
142
143
144 public void listItem_()
145 {
146 checkWellformedness( "listItem" );
147 }
148
149
150 public void numberedList( int numbering )
151 {
152 startElement( "numberedList" );
153 }
154
155
156 public void numberedList_()
157 {
158 checkWellformedness( "numberedList" );
159 }
160
161
162 public void numberedListItem()
163 {
164 startElement( "numberedListItem" );
165 }
166
167
168 public void numberedListItem_()
169 {
170 checkWellformedness( "numberedListItem" );
171 }
172
173
174 public void definitionList()
175 {
176 startElement( "definitionList" );
177 }
178
179
180 public void definitionList_()
181 {
182 checkWellformedness( "definitionList" );
183 }
184
185
186 public void definitionListItem()
187 {
188 startElement( "definitionListItem" );
189 }
190
191
192 public void definitionListItem_()
193 {
194 checkWellformedness( "definitionListItem" );
195 }
196
197
198 public void definition()
199 {
200 startElement( "definition" );
201 }
202
203
204 public void definition_()
205 {
206 checkWellformedness( "definition" );
207 }
208
209
210 public void figure()
211 {
212 startElement( "figure" );
213 }
214
215
216 public void figure_()
217 {
218 checkWellformedness( "figure" );
219 }
220
221
222 public void table()
223 {
224 startElement( "table" );
225 }
226
227
228 public void table_()
229 {
230 checkWellformedness( "table" );
231 }
232
233
234 public void tableRows( int[] justification, boolean grid )
235 {
236 startElement( "tableRows" );
237 }
238
239
240 public void tableRows_()
241 {
242 checkWellformedness( "tableRows" );
243 }
244
245
246 public void tableRow()
247 {
248 startElement( "tableRow" );
249 }
250
251
252 public void tableRow_()
253 {
254 checkWellformedness( "tableRow" );
255 }
256
257
258 public void title()
259 {
260 startElement( "title" );
261 }
262
263
264 public void title_()
265 {
266 checkWellformedness( "title" );
267 }
268
269
270 public void author()
271 {
272 startElement( "author" );
273 }
274
275
276 public void author_()
277 {
278 checkWellformedness( "author" );
279 }
280
281
282 public void date()
283 {
284 startElement( "date" );
285 }
286
287
288 public void date_()
289 {
290 checkWellformedness( "date" );
291 }
292
293
294 public void sectionTitle()
295 {
296 startElement( "sectionTitle" );
297 }
298
299
300 public void sectionTitle_()
301 {
302 checkWellformedness( "sectionTitle" );
303 }
304
305
306 public void sectionTitle1()
307 {
308 startElement( "sectionTitle1" );
309 }
310
311
312 public void sectionTitle1_()
313 {
314 checkWellformedness( "sectionTitle1" );
315 }
316
317
318 public void sectionTitle2()
319 {
320 startElement( "sectionTitle2" );
321 }
322
323
324 public void sectionTitle2_()
325 {
326 checkWellformedness( "sectionTitle2" );
327 }
328
329
330 public void sectionTitle3()
331 {
332 startElement( "sectionTitle3" );
333 }
334
335
336 public void sectionTitle3_()
337 {
338 checkWellformedness( "sectionTitle3" );
339 }
340
341
342 public void sectionTitle4()
343 {
344 startElement( "sectionTitle4" );
345 }
346
347
348 public void sectionTitle4_()
349 {
350 checkWellformedness( "sectionTitle4" );
351 }
352
353
354 public void sectionTitle5()
355 {
356 startElement( "sectionTitle5" );
357 }
358
359
360 public void sectionTitle5_()
361 {
362 checkWellformedness( "sectionTitle5" );
363 }
364
365
366 public void paragraph()
367 {
368 startElement( "paragraph" );
369 }
370
371
372 public void paragraph_()
373 {
374 checkWellformedness( "paragraph" );
375 }
376
377
378 public void verbatim( boolean boxed )
379 {
380 startElement( "verbatim" );
381 }
382
383
384 public void verbatim_()
385 {
386 checkWellformedness( "verbatim" );
387 }
388
389
390 public void definedTerm()
391 {
392 startElement( "definedTerm" );
393 }
394
395
396 public void definedTerm_()
397 {
398 checkWellformedness( "definedTerm" );
399 }
400
401
402 public void figureCaption()
403 {
404 startElement( "figureCaption" );
405 }
406
407
408 public void figureCaption_()
409 {
410 checkWellformedness( "figureCaption" );
411 }
412
413
414 public void tableCell()
415 {
416 startElement( "tableCell" );
417 }
418
419
420 public void tableCell( String width )
421 {
422 startElement( "tableCell" );
423 }
424
425
426 public void tableCell_()
427 {
428 checkWellformedness( "tableCell" );
429 }
430
431
432 public void tableHeaderCell()
433 {
434 startElement( "tableHeaderCell" );
435 }
436
437
438 public void tableHeaderCell( String width )
439 {
440 startElement( "tableHeaderCell" );
441 }
442
443
444 public void tableHeaderCell_()
445 {
446 checkWellformedness( "tableHeaderCell" );
447 }
448
449
450 public void tableCaption()
451 {
452 startElement( "tableCaption" );
453 }
454
455
456 public void tableCaption_()
457 {
458 checkWellformedness( "tableCaption" );
459 }
460
461
462 public void figureGraphics( String name )
463 {
464
465 }
466
467
468 public void horizontalRule()
469 {
470
471 }
472
473
474 public void pageBreak()
475 {
476
477 }
478
479
480 public void anchor( String name )
481 {
482 startElement( "anchor" );
483 }
484
485
486 public void anchor_()
487 {
488 checkWellformedness( "anchor" );
489 }
490
491
492 public void link( String name )
493 {
494 startElement( "link" );
495 }
496
497
498 public void link_()
499 {
500 checkWellformedness( "link" );
501 }
502
503
504 public void italic()
505 {
506 startElement( "italic" );
507 }
508
509
510 public void italic_()
511 {
512 checkWellformedness( "italic" );
513 }
514
515
516 public void bold()
517 {
518 startElement( "bold" );
519 }
520
521
522 public void bold_()
523 {
524 checkWellformedness( "bold" );
525 }
526
527
528 public void monospaced()
529 {
530 startElement( "monospaced" );
531 }
532
533
534 public void monospaced_()
535 {
536 checkWellformedness( "monospaced" );
537 }
538
539
540 public void lineBreak()
541 {
542
543 }
544
545
546 public void nonBreakingSpace()
547 {
548
549 }
550
551
552 public void text( String text )
553 {
554
555 }
556
557
558 public void rawText( String text )
559 {
560
561 }
562
563
564 public void comment( String comment )
565 {
566
567 }
568
569
570 public void flush()
571 {
572
573 }
574
575
576 public void close()
577 {
578 this.elements.clear();
579 this.errors.clear();
580 }
581
582
583
584
585
586
587
588 public boolean isWellformed()
589 {
590 return errors.isEmpty();
591 }
592
593
594
595
596
597
598
599 public String getOffender()
600 {
601 if ( isWellformed() )
602 {
603 return null;
604 }
605
606 return errors.get( errors.size() - 1 );
607 }
608
609
610
611
612
613
614 public List<String> getOffenders()
615 {
616 return errors;
617 }
618
619
620
621
622
623
624
625 private void checkWellformedness( String actual )
626 {
627 String expected = elements.pop();
628
629 if ( !expected.equals( actual ) )
630 {
631 errors.add( "Encountered closing: " + actual + ", expected " + expected );
632 }
633 }
634
635
636
637
638
639
640
641 private void startElement( String string )
642 {
643 elements.push( string );
644 }
645
646
647 public void head( SinkEventAttributes attributes )
648 {
649 head();
650 }
651
652
653 public void title( SinkEventAttributes attributes )
654 {
655 title();
656 }
657
658
659 public void author( SinkEventAttributes attributes )
660 {
661 author();
662 }
663
664
665 public void date( SinkEventAttributes attributes )
666 {
667 date();
668 }
669
670
671 public void body( SinkEventAttributes attributes )
672 {
673 body();
674 }
675
676
677 public void section( int level, SinkEventAttributes attributes )
678 {
679 startElement( "section" + level );
680 }
681
682
683 public void section_( int level )
684 {
685 checkWellformedness( "section" + level );
686 }
687
688
689 public void sectionTitle( int level, SinkEventAttributes attributes )
690 {
691 startElement( "sectionTitle" + level );
692 }
693
694
695 public void sectionTitle_( int level )
696 {
697 checkWellformedness( "sectionTitle" + level );
698 }
699
700
701 public void list( SinkEventAttributes attributes )
702 {
703 list();
704 }
705
706
707 public void listItem( SinkEventAttributes attributes )
708 {
709 listItem();
710 }
711
712
713 public void numberedList( int numbering, SinkEventAttributes attributes )
714 {
715 numberedList( numbering );
716 }
717
718
719 public void numberedListItem( SinkEventAttributes attributes )
720 {
721 numberedListItem();
722 }
723
724
725 public void definitionList( SinkEventAttributes attributes )
726 {
727 definitionList();
728 }
729
730
731 public void definitionListItem( SinkEventAttributes attributes )
732 {
733 definitionListItem();
734 }
735
736
737 public void definition( SinkEventAttributes attributes )
738 {
739 definition();
740 }
741
742
743 public void definedTerm( SinkEventAttributes attributes )
744 {
745 definedTerm();
746 }
747
748
749 public void figure( SinkEventAttributes attributes )
750 {
751 figure();
752 }
753
754
755 public void figureCaption( SinkEventAttributes attributes )
756 {
757 figureCaption();
758 }
759
760
761 public void figureGraphics( String src, SinkEventAttributes attributes )
762 {
763 figureGraphics( src );
764 }
765
766
767 public void table( SinkEventAttributes attributes )
768 {
769 table();
770 }
771
772
773 public void tableRow( SinkEventAttributes attributes )
774 {
775 tableRow();
776 }
777
778
779 public void tableCell( SinkEventAttributes attributes )
780 {
781 tableCell();
782 }
783
784
785 public void tableHeaderCell( SinkEventAttributes attributes )
786 {
787 tableHeaderCell();
788 }
789
790
791 public void tableCaption( SinkEventAttributes attributes )
792 {
793 tableCaption();
794 }
795
796
797 public void paragraph( SinkEventAttributes attributes )
798 {
799 paragraph();
800 }
801
802
803 public void verbatim( SinkEventAttributes attributes )
804 {
805 verbatim( false );
806 }
807
808
809 public void horizontalRule( SinkEventAttributes attributes )
810 {
811 horizontalRule();
812 }
813
814
815 public void anchor( String name, SinkEventAttributes attributes )
816 {
817 anchor( name );
818 }
819
820
821 public void link( String name, SinkEventAttributes attributes )
822 {
823 link( name );
824 }
825
826
827 public void lineBreak( SinkEventAttributes attributes )
828 {
829 lineBreak();
830 }
831
832
833 public void text( String text, SinkEventAttributes attributes )
834 {
835 text( text );
836 }
837
838
839 public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
840 {
841
842 }
843 }