KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hwpf > usermodel > Table


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17
18 package org.apache.poi.hwpf.usermodel;
19
20 import java.util.ArrayList JavaDoc;
21
22 public class Table
23   extends Range
24 {
25   ArrayList JavaDoc _rows;
26
27   Table(int startIdx, int endIdx, Range parent, int levelNum)
28   {
29     super(startIdx, endIdx, Range.TYPE_PARAGRAPH, parent);
30     _rows = new ArrayList JavaDoc();
31     int numParagraphs = numParagraphs();
32
33     int rowStart = 0;
34     int rowEnd = 0;
35
36     while (rowEnd < numParagraphs)
37     {
38       Paragraph p = getParagraph(rowEnd);
39       rowEnd++;
40       if (p.isTableRowEnd() && p.getTableLevel() == levelNum)
41       {
42         _rows.add(new TableRow(rowStart, rowEnd, this, levelNum));
43         rowStart = rowEnd;
44       }
45     }
46   }
47
48   public int numRows()
49   {
50     return _rows.size();
51   }
52
53   public int type()
54   {
55     return TYPE_TABLE;
56   }
57
58   public TableRow getRow(int index)
59   {
60     return (TableRow)_rows.get(index);
61   }
62 }
63
Popular Tags