-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathKxFileReaderWithNames.java
65 lines (57 loc) · 1.76 KB
/
KxFileReaderWithNames.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// ----------------------------------------------------------------------------
// Copyright....: (c) SAP 1999-2021
// Project......:
// Library......:
// File.........: KxFileReaderWithNames.java
// Author.......:
// Created......: Wed Jan 08 12:22:51 2003
// Description..:
// ----------------------------------------------------------------------------
package KxJRT;
import java.io.*;
import java.lang.*;
import java.util.*;
/**
* Reads variable names on the first line of input file.
* @see KxJRT.KxFileReader KxFileReader
*/
public class KxFileReaderWithNames extends KxFileReader
implements IKxJModelInputWithNames {
private String[] mVariables = null;
/**
* @see KxJRT.KxFileReader#KxFileReader(String, String) KxFileReader
**/
public KxFileReaderWithNames( String iFilePath, String iSeparator ) {
super( iFilePath, iSeparator );
init();
setName(getVariables());
}
private void init() {
String lFirstLine = null;
try {
lFirstLine = mBuffer.readLine();
}
catch ( IOException e ) {
throw new RuntimeException("Uniniatilzed buffer for current reader\n");
}
if (lFirstLine != null && !lFirstLine.equals("")) {
KxSmartTokenizer lSt = new KxSmartTokenizer(lFirstLine, mSeparator);
int lFieldsCount = lSt.countTokens();
mFields = new String[lFieldsCount];
mVariables = new String[lFieldsCount];
KxLog.getInstance().print("Head file :\n");
for( int i=0; lSt.hasMoreTokens(); i++ ) {
mVariables[i] = lSt.nextToken();
KxLog.getInstance().print(mVariables[i]+",");
}
KxLog.getInstance().print("\n");
}
else {
KxLog.getInstance().print("First line is not valid or empty\n");
throw new RuntimeException("First line is not valid or empty\n");
}
}
final public String[] getVariables() {
return mVariables;
}
}