1    package org.apache.poi.hssf.model;
2    
3    import org.apache.poi.hssf.record.Record;
4    
5    import java.util.ArrayList;
6    import java.util.List;
7    import java.util.Iterator;
8    
9    public class WorkbookRecordList
10   {
11       private List records = new ArrayList();
12   
13       private int  protpos     = 0;   // holds the position of the protect record.
14       private int  bspos       = 0;   // holds the position of the last bound sheet.
15       private int  tabpos      = 0;   // holds the position of the tabid record
16       private int  fontpos     = 0;   // hold the position of the last font record
17       private int  xfpos       = 0;   // hold the position of the last extended font record
18       private int  backuppos   = 0;   // holds the position of the backup record.
19   //    public int  namepos     = 0;   // holds the position of last name record
20   //    public int  supbookpos  = 0;   // holds the position of sup book
21       private int  palettepos  = 0;   // hold the position of the palette, if applicable
22   
23   
24       public void setRecords( List records )
25       {
26           this.records = records;
27       }
28   
29       public int size()
30       {
31           return records.size();
32       }
33   
34       public Record get( int i )
35       {
36           return (Record) records.get(i);
37       }
38   
39       public void add( int pos, Record r )
40       {
41           records.add(pos, r);
42           if (getProtpos() >= pos) setProtpos( protpos + 1 );
43           if (getBspos() >= pos) setBspos( bspos + 1 );
44           if (getTabpos() >= pos) setTabpos( tabpos + 1 );
45           if (getFontpos() >= pos) setFontpos( fontpos + 1 );
46           if (getXfpos() >= pos) setXfpos( xfpos + 1 );
47           if (getBackuppos() >= pos) setBackuppos( backuppos + 1 );
48   //        if (namepos >= pos) namepos++;
49   //        if (supbookpos >= pos) supbookpos++;
50           if (getPalettepos() >= pos) setPalettepos( palettepos + 1 );
51       }
52   
53       public List getRecords()
54       {
55           return records;
56       }
57   
58       public Iterator iterator()
59       {
60           return records.iterator();
61       }
62   
63       public void remove( int pos )
64       {
65           records.remove(pos);
66           if (getProtpos() >= pos) setProtpos( protpos - 1 );
67           if (getBspos() >= pos) setBspos( bspos - 1 );
68           if (getTabpos() >= pos) setTabpos( tabpos - 1 );
69           if (getFontpos() >= pos) setFontpos( fontpos - 1 );
70           if (getXfpos() >= pos) setXfpos( xfpos - 1 );
71           if (getBackuppos() >= pos) setBackuppos( backuppos - 1 );
72   //        if (namepos >= pos) namepos--;
73   //        if (supbookpos >= pos) supbookpos--;
74           if (getPalettepos() >= pos) setPalettepos( palettepos - 1 );
75       }
76   
77       public int getProtpos()
78       {
79           return protpos;
80       }
81   
82       public void setProtpos( int protpos )
83       {
84           this.protpos = protpos;
85       }
86   
87       public int getBspos()
88       {
89           return bspos;
90       }
91   
92       public void setBspos( int bspos )
93       {
94           this.bspos = bspos;
95       }
96   
97       public int getTabpos()
98       {
99           return tabpos;
100      }
101  
102      public void setTabpos( int tabpos )
103      {
104          this.tabpos = tabpos;
105      }
106  
107      public int getFontpos()
108      {
109          return fontpos;
110      }
111  
112      public void setFontpos( int fontpos )
113      {
114          this.fontpos = fontpos;
115      }
116  
117      public int getXfpos()
118      {
119          return xfpos;
120      }
121  
122      public void setXfpos( int xfpos )
123      {
124          this.xfpos = xfpos;
125      }
126  
127      public int getBackuppos()
128      {
129          return backuppos;
130      }
131  
132      public void setBackuppos( int backuppos )
133      {
134          this.backuppos = backuppos;
135      }
136  
137      public int getPalettepos()
138      {
139          return palettepos;
140      }
141  
142      public void setPalettepos( int palettepos )
143      {
144          this.palettepos = palettepos;
145      }
146  
147  
148  }
149