KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > model > WorkbookRecordList


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

16
17 package org.apache.poi.hssf.model;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
22
23 import org.apache.poi.hssf.record.NameRecord;
24 import org.apache.poi.hssf.record.Record;
25
26 public class WorkbookRecordList
27 {
28     private List JavaDoc records = new ArrayList JavaDoc();
29
30     private int protpos = 0; // holds the position of the protect record.
31
private int bspos = 0; // holds the position of the last bound sheet.
32
private int tabpos = 0; // holds the position of the tabid record
33
private int fontpos = 0; // hold the position of the last font record
34
private int xfpos = 0; // hold the position of the last extended font record
35
private int backuppos = 0; // holds the position of the backup record.
36
private int namepos = 0; // holds the position of last name record
37
private int supbookpos = 0; // holds the position of sup book
38
private int externsheetPos = 0;// holds the position of the extern sheet
39
private int palettepos = -1; // hold the position of the palette, if applicable
40

41
42     public void setRecords( List JavaDoc records )
43     {
44         this.records = records;
45     }
46
47     public int size()
48     {
49         return records.size();
50     }
51
52     public Record get( int i )
53     {
54         return (Record) records.get(i);
55     }
56
57     public void add( int pos, Record r )
58     {
59         records.add(pos, r);
60         if (getProtpos() >= pos) setProtpos( protpos + 1 );
61         if (getBspos() >= pos) setBspos( bspos + 1 );
62         if (getTabpos() >= pos) setTabpos( tabpos + 1 );
63         if (getFontpos() >= pos) setFontpos( fontpos + 1 );
64         if (getXfpos() >= pos) setXfpos( xfpos + 1 );
65         if (getBackuppos() >= pos) setBackuppos( backuppos + 1 );
66         if (getNamepos() >= pos) setNamepos(namepos+1);
67         if (getSupbookpos() >= pos) setSupbookpos(supbookpos+1);
68         if ((getPalettepos() != -1) && (getPalettepos() >= pos)) setPalettepos( palettepos + 1 );
69         if (getExternsheetPos() >= pos) setExternsheetPos(getExternsheetPos() + 1);
70     }
71
72     public List JavaDoc getRecords()
73     {
74         return records;
75     }
76
77     public Iterator JavaDoc iterator()
78     {
79         return records.iterator();
80     }
81
82     public void remove( int pos )
83     {
84         records.remove(pos);
85         if (getProtpos() >= pos) setProtpos( protpos - 1 );
86         if (getBspos() >= pos) setBspos( bspos - 1 );
87         if (getTabpos() >= pos) setTabpos( tabpos - 1 );
88         if (getFontpos() >= pos) setFontpos( fontpos - 1 );
89         if (getXfpos() >= pos) setXfpos( xfpos - 1 );
90         if (getBackuppos() >= pos) setBackuppos( backuppos - 1 );
91         if (getNamepos() >= pos) setNamepos(getNamepos()-1);
92         if (getSupbookpos() >= pos) setSupbookpos(getSupbookpos()-1);
93         if ((getPalettepos() != -1) && (getPalettepos() >= pos)) setPalettepos( palettepos - 1 );
94         if (getExternsheetPos() >= pos) setExternsheetPos( getExternsheetPos() -1);
95     }
96
97     public int getProtpos()
98     {
99         return protpos;
100     }
101
102     public void setProtpos( int protpos )
103     {
104         this.protpos = protpos;
105     }
106
107     public int getBspos()
108     {
109         return bspos;
110     }
111
112     public void setBspos( int bspos )
113     {
114         this.bspos = bspos;
115     }
116
117     public int getTabpos()
118     {
119         return tabpos;
120     }
121
122     public void setTabpos( int tabpos )
123     {
124         this.tabpos = tabpos;
125     }
126
127     public int getFontpos()
128     {
129         return fontpos;
130     }
131
132     public void setFontpos( int fontpos )
133     {
134         this.fontpos = fontpos;
135     }
136
137     public int getXfpos()
138     {
139         return xfpos;
140     }
141
142     public void setXfpos( int xfpos )
143     {
144         this.xfpos = xfpos;
145     }
146
147     public int getBackuppos()
148     {
149         return backuppos;
150     }
151
152     public void setBackuppos( int backuppos )
153     {
154         this.backuppos = backuppos;
155     }
156
157     public int getPalettepos()
158     {
159         return palettepos;
160     }
161
162     public void setPalettepos( int palettepos )
163     {
164         this.palettepos = palettepos;
165     }
166
167     
168     /**
169      * Returns the namepos.
170      * @return int
171      */

172     public int getNamepos() {
173         return namepos;
174     }
175
176     /**
177      * Returns the supbookpos.
178      * @return int
179      */

180     public int getSupbookpos() {
181         return supbookpos;
182     }
183
184     /**
185      * Sets the namepos.
186      * @param namepos The namepos to set
187      */

188     public void setNamepos(int namepos) {
189         this.namepos = namepos;
190     }
191
192     /**
193      * Sets the supbookpos.
194      * @param supbookpos The supbookpos to set
195      */

196     public void setSupbookpos(int supbookpos) {
197         this.supbookpos = supbookpos;
198     }
199
200     /**
201      * Returns the externsheetPos.
202      * @return int
203      */

204     public int getExternsheetPos() {
205         return externsheetPos;
206     }
207
208     /**
209      * Sets the externsheetPos.
210      * @param externsheetPos The externsheetPos to set
211      */

212     public void setExternsheetPos(int externsheetPos) {
213         this.externsheetPos = externsheetPos;
214     }
215
216 }
217
Popular Tags