01: /*
02:
03: Derby - Class org.apache.derby.impl.load.ExportWriteDataAbstract
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (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: abstract class ExportWriteDataAbstract {
25:
26: protected ControlInfo controlFileReader;
27: protected int[] columnLengths;
28:
29: protected String fieldSeparator;
30: protected String recordSeparator;
31: protected String nullString;
32: protected String columnDefinition;
33: protected String format;
34: protected String fieldStartDelimiter;
35: protected String fieldStopDelimiter;
36: protected String dataCodeset;
37: protected String dataLocale;
38: protected boolean hasDelimiterAtEnd;
39: protected boolean doubleDelimiter = true;
40:
41: //load properties locally for faster reference to them periodically
42: protected void loadPropertiesInfo() throws Exception {
43: fieldSeparator = controlFileReader.getFieldSeparator();
44: recordSeparator = controlFileReader.getRecordSeparator();
45: nullString = controlFileReader.getNullString();
46: columnDefinition = controlFileReader.getColumnDefinition();
47: format = controlFileReader.getFormat();
48: fieldStartDelimiter = controlFileReader
49: .getFieldStartDelimiter();
50: fieldStopDelimiter = controlFileReader.getFieldEndDelimiter();
51: dataCodeset = controlFileReader.getDataCodeset();
52: hasDelimiterAtEnd = controlFileReader.getHasDelimiterAtEnd();
53: }
54:
55: //if control file says true for column definition, write it as first line of the
56: //data file
57: abstract void writeColumnDefinitionOptionally(String[] columnNames,
58: String[] columnTypes) throws Exception;
59:
60: //used in case of fixed format
61: public void setColumnLengths(int[] columnLengths) {
62: this .columnLengths = columnLengths;
63: }
64:
65: //write the passed row into the data file
66: public abstract void writeData(String[] oneRow, boolean[] isNumeric)
67: throws Exception;
68:
69: //if nothing more to write, then close the file and write a message of completion
70: //in message file
71: public abstract void noMoreRows() throws Exception;
72: }
|