org.mmbase.util
Class CVSReader
java.lang.Object
|
+--org.mmbase.util.CVSReader
- public class CVSReader
- extends java.lang.Object
Class for reading and parsing the contents of a CVS (comma value seperated) file.
- Author:
- Daniel Ockeloen, Pierre van Rooden (javadocs)
|
Field Summary |
protected java.util.Hashtable |
name2pos
The CVS file header, which contains the column names. |
protected java.util.Vector |
rows
The content of the CVS file body (the records or rows). |
|
Constructor Summary |
CVSReader(java.lang.String filename)
Constructor for the CVS Reader. |
|
Method Summary |
java.lang.String |
getElement(int row,
int col)
Returns the element at the given row and column. |
java.lang.String |
getElement(int row,
java.lang.String colname)
Returns the element at the given row and with the given column name. |
java.lang.String |
loadFile(java.lang.String filename)
Reads the content of a file. |
void |
readCVS(java.lang.String filename)
Reads the contents of a CVS file and extracts the header and body content. |
int |
size()
Returns the number of rows in the CVS body. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
name2pos
protected java.util.Hashtable name2pos
- The CVS file header, which contains the column names.
The header is represented by a
Hashtable of name-values
where name is a column name and value the index of that column.
rows
protected java.util.Vector rows
- The content of the CVS file body (the records or rows).
Each entry in
rows represents a line or record in the CVS body.
Each line is represented by a Vector of values. The position of those
values matches with teh columns from the header.
CVSReader
public CVSReader(java.lang.String filename)
- Constructor for the CVS Reader.
readCVS
public void readCVS(java.lang.String filename)
- Reads the contents of a CVS file and extracts the header and body content.
The body content of the CVS file is stored in the
name2pos field,
the body content in the rows field.
loadFile
public java.lang.String loadFile(java.lang.String filename)
- Reads the content of a file.
- Parameters:
filename - path and name of the file to read- Returns:
- the content of the file as a string
getElement
public java.lang.String getElement(int row,
int col)
- Returns the element at the given row and column.
- Parameters:
row - the element rowcol - the element column- Returns:
- the element as a String.
getElement
public java.lang.String getElement(int row,
java.lang.String colname)
- Returns the element at the given row and with the given column name.
- Parameters:
row - the element rowcol - the element columnname- Returns:
- the element as a String.
size
public int size()
- Returns the number of rows in the CVS body.
MMBase 2001