KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nilostep > xlsql > database > xlFile


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

20 package com.nilostep.xlsql.database;
21
22 import com.nilostep.xlsql.sql.xlSqlSelect;
23
24 import java.io.File JavaDoc;
25
26
27 import java.util.logging.Logger JavaDoc;
28
29
30 /**
31  * Abstract File. Extend for particular use.
32  *
33  * @author Jim Caprioli
34  */

35 public abstract class xlFile {
36     protected static final Logger JavaDoc logger = Logger.getAnonymousLogger(); protected java.io.File JavaDoc directory;
37     protected String JavaDoc subFolderName;
38     protected String JavaDoc fileName;
39     protected boolean validAsSqlTable;
40     protected int columnCount;
41     protected int rowCount;
42     protected String JavaDoc[] columnNames;
43     protected String JavaDoc[] columnTypes;
44     protected boolean[] isChanged = new boolean[3];
45
46     protected xlFile(File JavaDoc dir, String JavaDoc folder, String JavaDoc name) throws xlException {
47         directory = dir;
48         subFolderName = folder;
49         fileName = name;
50         validAsSqlTable = readFile();
51     }
52
53     protected xlFile(File JavaDoc dir, String JavaDoc folder, String JavaDoc name, boolean bdirty) {
54         directory = dir;
55         subFolderName = folder;
56         fileName = name;
57         validAsSqlTable = true;
58         rowCount = 1;
59         isChanged[xlConstants.ADD] = bdirty;
60     }
61
62     protected abstract boolean readFile() throws xlException;
63
64     /**
65      * DOCUMENT ME!
66      *
67      * @param subOut DOCUMENT ME!
68      * @param select DOCUMENT ME!
69      *
70      * @throws Exception DOCUMENT ME!
71      */

72     public abstract void close(Object JavaDoc subOut, xlSqlSelect select)
73                         throws xlException;
74     
75     public abstract String JavaDoc[][] getValues() throws xlException;
76     
77     /**
78      * Setter for property rows.
79      */

80     void addRow() {
81         rowCount++;
82     }
83     
84     /**
85      * Getter for property columns.
86      *
87      * @return Value of property columns.
88      */

89     java.lang.String JavaDoc[] getColumnNames() {
90         return this.columnNames;
91     }
92     
93     /**
94      * DOCUMENT ME!
95      *
96      * @param i DOCUMENT ME!
97      *
98      * @return DOCUMENT ME!
99      */

100     boolean getIsChanged(int i) {
101         return isChanged[i];
102     }
103     
104     /**
105      * Getter for property rows.
106      *
107      * @return Value of property rows.
108      */

109     int getRows() {
110         return rowCount;
111     }
112     
113     /**
114      * Getter for property sName.
115      *
116      * @return Value of property sName.
117      */

118     java.lang.String JavaDoc getSName() {
119         return fileName;
120     }
121     
122     /**
123      * Getter for property types.
124      *
125      * @return Value of property types.
126      */

127     java.lang.String JavaDoc[] getColumnTypes() {
128         return this.columnTypes;
129     }
130     
131     /**
132      * Getter for property valid.
133      *
134      * @return Value of property valid.
135      */

136     public boolean isValid() {
137         return validAsSqlTable;
138     }
139     
140     /**
141      * Getter for property bDirty.
142      *
143      * @param i DOCUMENT ME!
144      * @param val DOCUMENT ME!
145      */

146     public void setIsChanged(int i, boolean val) {
147         isChanged[i] = val;
148     }
149     
150 }
Popular Tags