|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.ac.starlink.util.AsciiFileParser
Generalised parser for data stored as a table in a plain text file. The following assumptions are made about the structure of these files:
Field Summary | |
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 |
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 Summary | |
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. |
Method Summary | |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean fixed
protected int nFields
protected ArrayList rowList
protected char singleComment
protected char inlineComment
protected String delims
Constructor Detail |
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.Method Detail |
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 © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |