Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / derby-10.3.2.1 / java / engine / org / apache / derby / impl / load / ExportWriteDataAbstract.java
diff --git a/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/load/ExportWriteDataAbstract.java b/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/load/ExportWriteDataAbstract.java
new file mode 100644 (file)
index 0000000..ba07c16
--- /dev/null
@@ -0,0 +1,97 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.load.ExportWriteDataAbstract\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
+import java.io.InputStream;\r
+import java.io.Reader;\r
+\r
+abstract class ExportWriteDataAbstract {\r
+\r
+  protected ControlInfo controlFileReader;\r
+  protected int[] columnLengths;\r
+\r
+  protected String fieldSeparator;\r
+  protected String recordSeparator;\r
+  protected String nullString;\r
+  protected String columnDefinition;\r
+  protected String format;\r
+  protected String fieldStartDelimiter;\r
+  protected String fieldStopDelimiter;\r
+  protected String dataCodeset;\r
+  protected String dataLocale;\r
+  protected boolean hasDelimiterAtEnd;\r
+  protected boolean doubleDelimiter=true;\r
+\r
+  //load properties locally for faster reference to them periodically\r
+  protected void loadPropertiesInfo() throws Exception {\r
+    fieldSeparator = controlFileReader.getFieldSeparator();\r
+    recordSeparator = controlFileReader.getRecordSeparator();\r
+    nullString = controlFileReader.getNullString();\r
+    columnDefinition = controlFileReader.getColumnDefinition();\r
+    format = controlFileReader.getFormat();\r
+    fieldStartDelimiter = controlFileReader.getFieldStartDelimiter();\r
+    fieldStopDelimiter = controlFileReader.getFieldEndDelimiter();\r
+    dataCodeset = controlFileReader.getDataCodeset();\r
+    hasDelimiterAtEnd = controlFileReader.getHasDelimiterAtEnd();\r
+  }\r
+\r
+  //if control file says true for column definition, write it as first line of the\r
+  //data file\r
+  abstract void writeColumnDefinitionOptionally(String[] columnNames,\r
+                                                                                                          String[] columnTypes)\r
+                                                                                       throws Exception;\r
+\r
+  //used in case of fixed format\r
+  public void setColumnLengths(int[] columnLengths) {\r
+    this.columnLengths = columnLengths;\r
+  }\r
+\r
+  //write the passed row into the data file\r
+  public abstract void writeData(String[] oneRow, boolean[] isNumeric) throws Exception;\r
+\r
+    /*\r
+     * Writes the binary data in the given input stream to an \r
+     * external lob export file, and return it's location \r
+     * information in the file as string. Location information \r
+     * is written in the main export file. \r
+     * @param istream   input streams that contains a binary column data.\r
+     * @return Location where the column data written in the external file. \r
+     * @exception Exception  if any error occurs while writing the data.  \r
+     */\r
+    abstract String writeBinaryColumnToExternalFile(InputStream istream) \r
+        throws Exception;\r
+    \r
+    /*\r
+     * Writes the clob data in the given input Reader to an \r
+     * external lob export file, and return it's location \r
+     * information in the file as string. Location information \r
+     * is written in the main export file. \r
+     * @param ir   Reader that contains a clob column data.\r
+     * @return Location where the column data written in the external file. \r
+     * @exception Exception  if any error occurs while writing the data.   \r
+     */\r
+    abstract String writeCharColumnToExternalFile(Reader ir) \r
+        throws Exception;\r
+\r
+  //if nothing more to write, then close the file and write a message of completion\r
+  //in message file\r
+  public abstract void noMoreRows() throws Exception;\r
+}\r