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