KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > load > LoadError


1 /*
2
3    Derby - Class org.apache.derby.impl.load.LoadError
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.load;
23
24 import java.sql.SQLException JavaDoc;
25 import org.apache.derby.iapi.error.ExceptionSeverity;
26 import org.apache.derby.iapi.reference.SQLState;
27 import org.apache.derby.iapi.error.StandardException;
28 import org.apache.derby.iapi.error.PublicAPI;
29
30 /**
31  * These exceptions are thrown by the import and export modules.
32  *
33  *
34  * @author Mamta Satoor
35     @see SQLException
36  */

37 class LoadError {
38     
39     /**
40      Raised if, the Cloudscape database connection is null.
41     */

42
43     static SQLException JavaDoc connectionNull() {
44         return PublicAPI.wrapStandardException(
45                StandardException.newException(SQLState.CONNECTION_NULL));
46     }
47
48     /**
49        Raised if, there is data found between the stop delimiter and field/record spearator.
50        @param lineNumber Found invalid data on this line number in the data file
51        @param columnNumber Found invalid data for this column number in the data file
52     */

53     static SQLException JavaDoc dataAfterStopDelimiter(int lineNumber, int columnNumber) {
54         return PublicAPI.wrapStandardException(
55                StandardException.newException(SQLState.DATA_AFTER_STOP_DELIMITER,
56                                               new Integer JavaDoc(lineNumber),new Integer JavaDoc(columnNumber)));
57     }
58
59     /**
60        Raised if, the passed data file can't be found.
61        @param fileName the data file name
62     */

63     static SQLException JavaDoc dataFileNotFound(String JavaDoc fileName) {
64
65         return PublicAPI.wrapStandardException(
66                StandardException.newException(SQLState.DATA_FILE_NOT_FOUND, fileName));
67     }
68
69   
70     /**
71        Raised if, null is passed for data file url.
72     */

73     static SQLException JavaDoc dataFileNull() {
74     return PublicAPI.wrapStandardException(
75                StandardException.newException(SQLState.DATA_FILE_NULL));
76     }
77
78     /**
79        Raised if, the entity (ie table/view) for import/export is missing in the database.
80     */

81
82     static SQLException JavaDoc entityNameMissing() {
83     return PublicAPI.wrapStandardException(
84            StandardException.newException(SQLState.ENTITY_NAME_MISSING));
85
86     }
87
88
89     /**
90        Raised if, field & record separators are substring of each other.
91     */

92     static SQLException JavaDoc fieldAndRecordSeparatorsSubset() {
93         return PublicAPI.wrapStandardException(
94                 StandardException.newException(SQLState.FIELD_IS_RECORD_SEPERATOR_SUBSET));
95     }
96
97     /**
98        Raised if, no column by given name is found in the resultset while importing.
99        @param columnName the resultset doesn't have this column name
100     */

101     static SQLException JavaDoc invalidColumnName(String JavaDoc columnName) {
102         return PublicAPI.wrapStandardException(
103                 StandardException.newException(SQLState.INVALID_COLUMN_NAME , columnName));
104
105     }
106
107
108     /**
109        Raised if, no column by given number is found in the resultset while importing.
110        @param numberOfColumns the resultset doesn't have this column number
111     */

112     static SQLException JavaDoc invalidColumnNumber(int numberOfColumns) {
113         
114         return PublicAPI.wrapStandardException(
115                 StandardException.newException(SQLState.INVALID_COLUMN_NUMBER,
116                                                new Integer JavaDoc(numberOfColumns)
117                                                ));
118     }
119
120     /**
121        Raised if, trying to export/import from an entity which has non supported
122        type columns in it.
123     */

124     static SQLException JavaDoc nonSupportedTypeColumn(String JavaDoc columnName, String JavaDoc typeName) {
125         return PublicAPI.wrapStandardException(
126                 StandardException.newException(SQLState.UNSUPPORTED_COLUMN_TYPE,
127                                                columnName,
128                                                typeName));
129     }
130
131
132     /**
133        Raised if, in case of fixed format, don't find the record separator for a row in the data file.
134        @param lineNumber the line number with the missing record separator in the data file
135     */

136     static SQLException JavaDoc recordSeparatorMissing(int lineNumber) {
137
138         return PublicAPI.wrapStandardException(
139                 StandardException.newException(SQLState.RECORD_SEPERATOR_MISSING,
140                                                new Integer JavaDoc(lineNumber)));
141     }
142
143     /**
144        Raised if, in case of fixed format, reach end of file before reading data for all the columns.
145     */

146     static SQLException JavaDoc unexpectedEndOfFile(int lineNumber) {
147     return PublicAPI.wrapStandardException(
148             StandardException.newException(SQLState.UNEXPECTED_END_OF_FILE,
149                                            new Integer JavaDoc(lineNumber)));
150     }
151
152     /**
153        Raised if, got IOException while writing data to the file.
154     */

155     static SQLException JavaDoc errorWritingData() {
156         return PublicAPI.wrapStandardException(
157                StandardException.newException(SQLState.ERROR_WRITING_DATA));
158     }
159
160
161     /*
162      * Raised if period(.) is used a character delimiter
163      */

164     static SQLException JavaDoc periodAsCharDelimiterNotAllowed()
165     {
166         return PublicAPI.wrapStandardException(
167                StandardException.newException(SQLState.PERIOD_AS_CHAR_DELIMITER_NOT_ALLOWED));
168     }
169
170     /*
171      * Raised if same delimiter character is used for more than one delimiter
172      * type . For eg using ';' for both column delimter and character delimter
173      */

174     static SQLException JavaDoc delimitersAreNotMutuallyExclusive()
175     {
176         return PublicAPI.wrapStandardException(
177                StandardException.newException(SQLState.DELIMITERS_ARE_NOT_MUTUALLY_EXCLUSIVE));
178     }
179
180
181     static SQLException JavaDoc tableNotFound(String JavaDoc tableName)
182     {
183     
184         return PublicAPI.wrapStandardException(
185                StandardException.newException(SQLState.TABLE_NOT_FOUND, tableName));
186     }
187
188         
189     /* Wrapper to throw an unknown excepton duing Import/Export.
190      * Typically this can be some IO error which is not generic error
191      * like the above error messages.
192      */

193
194     static SQLException JavaDoc unexpectedError(Throwable JavaDoc t )
195     {
196         if (!(t instanceof SQLException JavaDoc))
197         {
198             return PublicAPI.wrapStandardException(StandardException.plainWrapException(t));
199         }
200         else
201             return (SQLException JavaDoc) t;
202     }
203     
204
205
206     
207 }
208
209
210
211
212
213
Popular Tags