View Javadoc
1   package org.apache.maven.doxia.module.twiki.parser;
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.sink.Sink;
23  
24  /**
25   * Represents a table
26   *
27   * @author Juan F. Codagnone
28   */
29  class TableBlock
30      extends AbstractFatherBlock
31  {
32      /**
33       * Creates the TableBlock.
34       *
35       * @param childBlocks child blocks
36       */
37      TableBlock( final Block[] childBlocks )
38      {
39          super( childBlocks );
40      }
41  
42      /** {@inheritDoc} */
43      final void before( final Sink sink )
44      {
45          sink.table();
46          sink.tableRows( getJustification(), false );
47      }
48  
49      /** {@inheritDoc} */
50      final void after( final Sink sink )
51      {
52          sink.tableRows_();
53          sink.table_();
54      }
55  
56      private int[] getJustification()
57      {
58          int[] justification = new int[( (AbstractFatherBlock) getBlocks()[0] ).getBlocks().length];
59          for ( int i = 0; i < justification.length; i++ )
60          {
61              justification[i] = Sink.JUSTIFY_CENTER;
62          }
63  
64          return justification;
65      }
66  }