View Javadoc

1   package org.apache.maven.doxia.siterenderer.sink;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.doxia.module.xhtml.XhtmlSink;
23  import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
24  import org.codehaus.doxia.sink.Sink;
25  
26  import java.io.StringWriter;
27  import java.io.Writer;
28  import java.util.ArrayList;
29  import java.util.List;
30  
31  /**
32   * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
33   * @version $Id: SiteRendererSink.java 737610 2009-01-25 23:43:01Z dennisl $
34   */
35  public class SiteRendererSink
36      extends XhtmlSink
37      implements Sink
38  {
39      private String date = "";
40  
41      private String title = "";
42  
43      private List authors = new ArrayList();
44  
45      private final Writer writer;
46  
47      public SiteRendererSink( RenderingContext renderingContext )
48      {
49          this( new StringWriter(), renderingContext );
50      }
51  
52      private SiteRendererSink( StringWriter writer, RenderingContext renderingContext )
53      {
54          super( writer, renderingContext, null );
55  
56          this.writer = writer;
57      }
58  
59      /**
60       * @see org.apache.maven.doxia.module.xhtml.XhtmlSink#title_()
61       */
62      public void title_()
63      {
64          if ( getBuffer().length() > 0 )
65          {
66              title = getBuffer().toString();
67          }
68  
69          resetBuffer();
70      }
71  
72      /**
73       * @see org.apache.maven.doxia.module.xhtml.XhtmlSink#title()
74       */
75      public void title()
76      {
77      }
78  
79      public String getTitle()
80      {
81          return title;
82      }
83  
84      /**
85       * @see org.apache.maven.doxia.module.xhtml.XhtmlSink#author_()
86       */
87      public void author_()
88      {
89          if ( getBuffer().length() > 0 )
90          {
91              authors.add( getBuffer().toString() );
92          }
93  
94          resetBuffer();
95      }
96  
97      public List getAuthors()
98      {
99          return authors;
100     }
101 
102     /**
103      * @see org.apache.maven.doxia.module.xhtml.XhtmlSink#date_()
104      */
105     public void date_()
106     {
107         if ( getBuffer().length() > 0 )
108         {
109             date = getBuffer().toString();
110         }
111 
112         resetBuffer();
113     }
114 
115     public String getDate()
116     {
117         return date;
118     }
119 
120     /**
121      * @see org.apache.maven.doxia.module.xhtml.XhtmlSink#body_()
122      */
123     public void body_()
124     {
125     }
126 
127     /**
128      * @see org.apache.maven.doxia.module.xhtml.XhtmlSink#body()
129      */
130     public void body()
131     {
132     }
133 
134     public String getBody()
135     {
136         return writer.toString();
137     }
138 
139     /**
140      * @see org.apache.maven.doxia.module.xhtml.XhtmlSink#head_()
141      */
142     public void head_()
143     {
144         setHeadFlag( false );
145     }
146 
147     /**
148      * @see org.apache.maven.doxia.module.xhtml.XhtmlSink#head()
149      */
150     public void head()
151     {
152         setHeadFlag( true );
153     }
154 }