| java.lang.Object org.mmbase.util.CVSReader
CVSReader | public class CVSReader (Code) | | Class for reading and parsing the contents of a CVS (comma value seperated) file.
author: Daniel Ockeloen author: Pierre van Rooden (javadocs) version: $Id: CVSReader.java,v 1.13 2007/02/25 17:56:59 nklasens Exp $ |
Field Summary | |
String | filename The CVS file to read. | protected Hashtable<String, Integer> | name2pos The CVS file header, which contains the column names. | protected Vector<Vector<String>> | 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. |
Constructor Summary | |
public | CVSReader(String filename) Constructor for the CVS Reader. |
Method Summary | |
Vector<Vector<String>> | decodeBody(StringTokenizer mtok) Parses the body text of a CVS file.
Each row (line of text) in the body is a record whose fields are represented by a list of
komma-separated, possibly quoted, elements.
This routime converted the line into a Vector consisting of these elements.
Parameters: tok - A tokenenized list of strings (lines) that make up the body text. | Hashtable<String, Integer> | decodeHeader(String line) Converts a CVS Header line into a hashtable of header elements. | public String | getElement(int row, int col) Returns the element at the given row and column. | public String | getElement(int row, String colname) Returns the element at the given row and with the given column name. | public String | loadFile(String filename) Reads the content of a file. | public void | readCVS(String filename) Reads the contents of a CVS file and extracts the header and body content. | public int | size() Returns the number of rows in the CVS body. |
name2pos | protected Hashtable<String, Integer> name2pos(Code) | | 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 Vector<Vector<String>> rows(Code) | | 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(String filename)(Code) | | Constructor for the CVS Reader.
Parameters: filename - The CVS file to read |
decodeBody | Vector<Vector<String>> decodeBody(StringTokenizer mtok)(Code) | | Parses the body text of a CVS file.
Each row (line of text) in the body is a record whose fields are represented by a list of
komma-separated, possibly quoted, elements.
This routime converted the line into a Vector consisting of these elements.
Parameters: tok - A tokenenized list of strings (lines) that make up the body text. a Vector containing, for each line in the CVS body, a list of elements. |
decodeHeader | Hashtable<String, Integer> decodeHeader(String line)(Code) | | Converts a CVS Header line into a hashtable of header elements.
Parameters: line - the headerline to parse (should exists of elements seperated by commas) a Hashtable containing the header values with theirpostition in the header |
getElement | public String getElement(int row, int col)(Code) | | Returns the element at the given row and column.
Parameters: row - the element row Parameters: col - the element column the element as a String. |
getElement | public String getElement(int row, String colname)(Code) | | Returns the element at the given row and with the given column name.
Parameters: row - the element row Parameters: colname - the element columnname the element as a String. |
loadFile | public String loadFile(String filename)(Code) | | Reads the content of a file.
Parameters: filename - path and name of the file to read the content of the file as a string |
readCVS | public void readCVS(String filename)(Code) | | 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
CVSReader.name2pos field,
the body content in the
CVSReader.rows field.
|
size | public int size()(Code) | | Returns the number of rows in the CVS body.
|
|
|