Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / derby-10.3.2.1 / java / engine / org / apache / derby / impl / load / LoadError.java
diff --git a/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/load/LoadError.java b/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/load/LoadError.java
new file mode 100644 (file)
index 0000000..aa38768
--- /dev/null
@@ -0,0 +1,227 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.load.LoadError\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to You under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.load;\r
+\r
+import java.io.IOException;\r
+import java.sql.SQLException;\r
+import org.apache.derby.iapi.error.ExceptionSeverity;\r
+import org.apache.derby.iapi.reference.SQLState;\r
+import org.apache.derby.iapi.error.StandardException;\r
+import org.apache.derby.iapi.error.PublicAPI;\r
+\r
+/**\r
+ * These exceptions are thrown by the import and export modules.\r
+ * \r
+ *\r
+       @see SQLException\r
+ */\r
+class LoadError {\r
+       \r
+       /**\r
+        Raised if, the Derby database connection is null.\r
+       */\r
+\r
+       static SQLException connectionNull() {\r
+               return PublicAPI.wrapStandardException(\r
+                          StandardException.newException(SQLState.CONNECTION_NULL));\r
+       }\r
+\r
+       /**\r
+          Raised if, there is data found between the stop delimiter and field/record spearator.\r
+          @param lineNumber Found invalid data on this line number in the data file\r
+          @param columnNumber Found invalid data for this column number in the data file\r
+       */\r
+       static SQLException dataAfterStopDelimiter(int lineNumber, int columnNumber) {\r
+               return PublicAPI.wrapStandardException(\r
+                          StandardException.newException(SQLState.DATA_AFTER_STOP_DELIMITER,\r
+                                                                                         new Integer(lineNumber),new Integer(columnNumber)));                                  \r
+       }\r
+\r
+       /**\r
+          Raised if, the passed data file can't be found.\r
+          @param fileName the data file name \r
+          @param ex the exception that prevented us from opening the file\r
+       */\r
+       static SQLException dataFileNotFound(String fileName, Exception ex) {\r
+\r
+               return PublicAPI.wrapStandardException(\r
+                          StandardException.newException(SQLState.DATA_FILE_NOT_FOUND, ex,\r
+                                                                                         fileName));\r
+       }\r
+\r
+  \r
+       /**\r
+          Raised if, null is passed for data file url.\r
+       */\r
+       static SQLException dataFileNull() {\r
+    return PublicAPI.wrapStandardException(\r
+                          StandardException.newException(SQLState.DATA_FILE_NULL));\r
+       }\r
+        /**\r
+          Raised if, data file exists.\r
+       */\r
+       static SQLException dataFileExists(String fileName) {\r
+    return PublicAPI.wrapStandardException(\r
+                          StandardException.newException(SQLState.DATA_FILE_EXISTS, fileName));\r
+       }\r
+       /**\r
+           Raised if, lob file exists.\r
+        */\r
+        static SQLException lobsFileExists(String fileName) {\r
+    return PublicAPI.wrapStandardException(\r
+                           StandardException.newException(SQLState.LOB_DATA_FILE_EXISTS, fileName));\r
+        }\r
+       /**\r
+          Raised if, the entity (ie table/view) for import/export is missing in the database.\r
+       */\r
+\r
+       static SQLException entityNameMissing() {\r
+    return PublicAPI.wrapStandardException(\r
+                  StandardException.newException(SQLState.ENTITY_NAME_MISSING));\r
+\r
+       }\r
+\r
+\r
+       /**\r
+          Raised if, field & record separators are substring of each other.\r
+       */\r
+       static SQLException fieldAndRecordSeparatorsSubset() {\r
+               return  PublicAPI.wrapStandardException(\r
+                               StandardException.newException(SQLState.FIELD_IS_RECORD_SEPERATOR_SUBSET));\r
+       }\r
+\r
+       /**\r
+          Raised if, no column by given name is found in the resultset while importing.\r
+          @param columnName the resultset doesn't have this column name\r
+       */\r
+       static SQLException invalidColumnName(String columnName) {\r
+               return  PublicAPI.wrapStandardException(\r
+                               StandardException.newException(SQLState.INVALID_COLUMN_NAME , columnName));\r
+\r
+       }\r
+\r
+\r
+       /**\r
+          Raised if, no column by given number is found in the resultset while importing.\r
+          @param numberOfColumns the resultset doesn't have this column number\r
+       */\r
+       static SQLException invalidColumnNumber(int numberOfColumns) {\r
+               \r
+               return PublicAPI.wrapStandardException(\r
+                               StandardException.newException(SQLState.INVALID_COLUMN_NUMBER,\r
+                                                                                          new Integer(numberOfColumns)\r
+                                                                                          ));\r
+       }\r
+\r
+       /**\r
+          Raised if, trying to export/import from an entity which has non supported\r
+          type columns in it.\r
+       */\r
+       static SQLException nonSupportedTypeColumn(String columnName, String typeName) {\r
+               return  PublicAPI.wrapStandardException(\r
+                               StandardException.newException(SQLState.UNSUPPORTED_COLUMN_TYPE,\r
+                                                                                          columnName,\r
+                                                                                          typeName));\r
+       }\r
+\r
+\r
+       /**\r
+          Raised if, in case of fixed format, don't find the record separator for a row in the data file.\r
+          @param lineNumber the line number with the missing record separator in the data file\r
+       */\r
+       static SQLException recordSeparatorMissing(int lineNumber) {\r
+\r
+               return  PublicAPI.wrapStandardException(\r
+                               StandardException.newException(SQLState.RECORD_SEPERATOR_MISSING,\r
+                                                                                          new Integer(lineNumber)));\r
+       }\r
+\r
+       /**\r
+          Raised if, in case of fixed format, reach end of file before reading data for all the columns.\r
+       */\r
+       static SQLException unexpectedEndOfFile(int lineNumber) {\r
+    return  PublicAPI.wrapStandardException(\r
+                       StandardException.newException(SQLState.UNEXPECTED_END_OF_FILE,\r
+                                                                                  new Integer(lineNumber)));\r
+       }\r
+\r
+       /**\r
+          Raised if, got IOException while writing data to the file.\r
+       */\r
+       static SQLException errorWritingData(IOException ioe) {\r
+               return PublicAPI.wrapStandardException(\r
+                       StandardException.newException(SQLState.ERROR_WRITING_DATA, ioe));\r
+       }\r
+\r
+\r
+       /*\r
+        * Raised if period(.) is used a character delimiter\r
+        */\r
+       static SQLException periodAsCharDelimiterNotAllowed()\r
+       {\r
+               return PublicAPI.wrapStandardException(\r
+                          StandardException.newException(SQLState.PERIOD_AS_CHAR_DELIMITER_NOT_ALLOWED));\r
+       }\r
+\r
+       /*\r
+        * Raised if same delimiter character is used for more than one delimiter\r
+        * type . For eg using ';' for both column delimter and character delimter\r
+        */\r
+       static SQLException delimitersAreNotMutuallyExclusive()\r
+       {\r
+               return PublicAPI.wrapStandardException(\r
+                          StandardException.newException(SQLState.DELIMITERS_ARE_NOT_MUTUALLY_EXCLUSIVE));\r
+       }\r
+\r
+\r
+       static SQLException tableNotFound(String tableName)\r
+       {\r
+       \r
+               return PublicAPI.wrapStandardException(\r
+                          StandardException.newException(SQLState.TABLE_NOT_FOUND, tableName));\r
+       }\r
+\r
+               \r
+       /* Wrapper to throw an unknown excepton duing Import/Export.\r
+        * Typically this can be some IO error which is not generic error\r
+        * like the above error messages. \r
+        */\r
+\r
+       static SQLException unexpectedError(Throwable t )\r
+       {\r
+               if (!(t instanceof SQLException))  \r
+               {\r
+                       return PublicAPI.wrapStandardException(StandardException.plainWrapException(t));\r
+               }\r
+               else\r
+                       return (SQLException) t;\r
+       }\r
+       \r
+\r
+\r
+       \r
+}\r
+\r
+\r
+\r
+\r
+\r