KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > write > biff > DataValidityListRecord


1 /*********************************************************************
2 *
3 * Copyright (C) 2004 Andrew Khan
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ***************************************************************************/

19
20 package jxl.write.biff;
21
22 import jxl.biff.Type;
23 import jxl.biff.WritableRecordData;
24 import jxl.biff.DValParser;
25
26 /**
27  * Data validity settings
28  */

29 class DataValidityListRecord extends WritableRecordData
30 {
31   /**
32    * The binary data
33    */

34   private byte[] data;
35
36   /**
37    * The dval parser
38    */

39   private DValParser dvalParser;
40
41   /**
42    * Constructor
43    *
44    * @param dvlr the record copied from a read only sheet
45    */

46   DataValidityListRecord(jxl.read.biff.DataValidityListRecord dvlr)
47   {
48     super(Type.DVAL);
49     
50     data = dvlr.getData();
51   }
52
53   /**
54    * Constructor
55    *
56    * @param dvlr the record copied from a writable sheet
57    */

58   DataValidityListRecord(DataValidityListRecord dvlr)
59   {
60     super(Type.DVAL);
61     
62     data = new byte[dvlr.data.length];
63     System.arraycopy(dvlr.data, 0, data, 0, data.length);
64   }
65
66   /**
67    * Retrieves the data for output to binary file
68    *
69    * @return the data to be written
70    */

71   public byte[] getData()
72   {
73     if (dvalParser == null)
74     {
75       return data;
76     }
77
78     return dvalParser.getData();
79   }
80
81   /**
82    * Called when a remove row or column results in one of DV records being
83    * removed
84    */

85   void dvRemoved()
86   {
87     if (dvalParser == null)
88     {
89       dvalParser = new DValParser(data);
90     }
91
92     dvalParser.dvRemoved();
93   }
94
95   /**
96    * Accessor for the number of DV records
97    *
98    * @return the number of DV records for this list
99    */

100   public boolean hasDVRecords()
101   {
102     if (dvalParser == null)
103     {
104       return true;
105     }
106
107     return dvalParser.getNumberOfDVRecords() > 0;
108   }
109
110 }
111
Popular Tags