public class AsciiFileParser extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
delims
The permissible delimeters between fields.
|
protected boolean |
fixed
Whether the number of fields is fixed.
|
protected char |
inlineComment
The character used for inline comments.
|
protected int |
nFields
The number of fixed fields in the file.
|
protected ArrayList<String[]> |
rowList
A list that contains arrays of each set of Strings parsed from each row.
|
protected char |
singleComment
The character used for single-line comments.
|
Constructor and Description |
---|
AsciiFileParser()
Create an instance.
|
AsciiFileParser(boolean fixed)
Create an instance.
|
AsciiFileParser(File file)
Create an instance and parse a given File.
|
AsciiFileParser(File file,
boolean fixed)
Create an instance and parse a given File.
|
Modifier and Type | Method and Description |
---|---|
protected void |
decode(File file)
Open, read and decode the contents of the file.
|
boolean |
getBooleanField(int row,
int column)
Get the boolean value of a field.
|
String |
getDelimeters()
Get the character used as field delimeters.
|
double |
getDoubleField(int row,
int column)
Get the double precision value of a field.
|
char |
getInlineCommentChar()
Get the character used for in-line comments.
|
int |
getIntegerField(int row,
int column)
Get the integer value of a field.
|
int |
getNFields()
Get the number of fields located in the file.
|
int |
getNFields(int row)
Get the number of fields in a row.
|
int |
getNRows()
Get the number of rows located in the file.
|
String[] |
getRow(int row)
Get the parsed Strings in a row.
|
char |
getSingleCommentChar()
Get the character used for single line comments.
|
String |
getStringField(int row,
int column)
Get the String value of a field.
|
boolean |
isFixed()
Get whether the file is expected to have a fixed number of fields.
|
void |
parse(File file)
Parse a file using the current configuration.
|
void |
setDelimeters(String delims)
Set the characters used as field delimeters.
|
void |
setFixed(boolean fixed)
Set whether the file is expected to have a fixed number of fields.
|
void |
setInlineCommentChar(char inlineComment)
Set the character used for in-line comments.
|
void |
setSingleCommentChar(char singleComment)
Set the character used for single line comments.
|
protected boolean fixed
protected int nFields
protected ArrayList<String[]> rowList
protected char singleComment
protected char inlineComment
protected String delims
public AsciiFileParser()
public AsciiFileParser(boolean fixed)
fixed
- whether fixed format is required.public AsciiFileParser(File file)
file
- reference a File that describes the input file.public AsciiFileParser(File file, boolean fixed)
file
- reference a File that describes the input file.fixed
- whether fixed format is required.public void setFixed(boolean fixed)
fixed
- whether fixed format is required.public boolean isFixed()
public void parse(File file)
file
- reference a File that describes the input file.public int getNFields()
public int getNFields(int row)
public int getNRows()
public String[] getRow(int row)
public String getStringField(int row, int column)
row
- the row index of the field required.column
- the column index of the field required.public int getIntegerField(int row, int column)
row
- the row index of the field required.column
- the column index of the field required.public double getDoubleField(int row, int column)
row
- the row index of the field required.column
- the column index of the field required.public boolean getBooleanField(int row, int column)
row
- the row index of the field required.column
- the column index of the field required.public void setSingleCommentChar(char singleComment)
public char getSingleCommentChar()
public void setInlineCommentChar(char inlineComment)
public char getInlineCommentChar()
public void setDelimeters(String delims)
delims
- list of characters to be used as field
delimiters.public String getDelimeters()
protected void decode(File file)
file
- reference a File that describes the input file.Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.