Class FortranField
Title: FortranField
Description: This is a class that holds the column positions of
a field from an old Fortran Card input for parsing that card.
For example, if you had a flow card that looked like this:
Q0 123.40 6789.0 ...
with a format of A2,F8.0,9F10.0
you would create a Fortran Field for the ID using columns 1 and 2,
the first variable 3,10, next 11,20 (Fortran starts in col 1, not col 0)
e.g.
FortranField ff[] = new FortranField[11];
ff[0] = new FortranField(1,2);
ff[1] = new FortranField(3,10);
for (int i=2; i<11; i++) {
int k = i-1;
ff[i] = new FortranField((k*10+1), i*10);
}
Then you call parseFixedFormat and get an String array of your fields, e.g.,
String line;
(read line, e.g. line = "Q0 123.40 6789.0 ...")
String fields[] = FortranField(line, ff)
then fields[0] = "Q)"
fields[1] = "123.40"
etc.
Inversely, you can go back to the card format with function toFixedFormat()
Company: HEC
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]
parseFixedFormat
(String line, FortranField[] fortranColumn) static String[]
parseFixedFormat
(String line, FortranField[] fortranColumn, String emptyField) static String
toFixedFormat
(String[] fields, FortranField[] fortranColumn)
-
Field Details
-
start
public int start -
end
public int end
-
-
Constructor Details
-
FortranField
public FortranField(int startField, int endField)
-
-
Method Details
-
parseFixedFormat
-
parseFixedFormat
public static String[] parseFixedFormat(String line, FortranField[] fortranColumn, String emptyField) -
toFixedFormat
-