public boolean isQualified(int columnIndex) throws IOException { checkClosed(); if (columnIndex < columnsCount && columnIndex > -1) { return isQualified[columnIndex]; } else { return false; } }
/** * Returns the current column value for a given column index. * * @param columnIndex * The index of the column. * @return The current column value. * @exception IOException * Thrown if this object has already been closed. */ public String get(int columnIndex) throws IOException { checkClosed(); if (columnIndex > -1 && columnIndex < columnsCount) { return values[columnIndex]; } else { return ""; } }
/** * Returns the column header value for a given column index. * * @param columnIndex * The index of the header column being requested. * @return The value of the column header at the given column index. * @exception IOException * Thrown if this object has already been closed. */ public String getHeader(int columnIndex) throws IOException { checkClosed(); // check to see if we have read the header record yet // check to see if the column index is within the bounds // of our header array if (columnIndex > -1 && columnIndex < headersHolder.Length) { // return the processed header data for this column return headersHolder.Headers[columnIndex]; } else { return ""; } }
public String[] getValues() throws IOException { checkClosed(); // need to return a clone, and can't use clone because values.Length // might be greater than columnsCount String[] clone = new String[columnsCount]; System.arraycopy(values, 0, clone, 0, columnsCount); return clone; }
/** * Returns the header values as a string array. * * @return The header values as a String array. * @exception IOException * Thrown if this object has already been closed. */ public String[] getHeaders() throws IOException { checkClosed(); if (headersHolder.Headers == null) { return null; } else { // use clone here to prevent the outside code from // setting values on the array directly, which would // throw off the index lookup based on header name String[] clone = new String[headersHolder.Length]; System.arraycopy(headersHolder.Headers, 0, clone, 0, headersHolder.Length); return clone; } }
/** * Gets the corresponding column index for a given column header name. * * @param headerName * The header name of the column. * @return The column index for the given column header name. Returns * -1 if not found. * @exception IOException * Thrown if this object has already been closed. */ public int getIndex(String headerName) throws IOException { checkClosed(); Object indexValue = headersHolder.IndexByName.get(headerName); if (indexValue != null) { return ((Integer) indexValue).intValue(); } else { return -1; } }
/** * Skips the next record of data by parsing each column. Does not * increment * {@link org.jumpmind.symmetric.csv.CsvReader#getCurrentRecord getCurrentRecord()}. * * @return Whether another record was successfully skipped or not. * @exception IOException * Thrown if an error occurs while reading data from the * source stream. */ public boolean skipRecord() throws IOException { checkClosed(); boolean recordRead = false; if (hasMoreData) { recordRead = readRecord(); if (recordRead) { currentRecord--; } } return recordRead; }
/** * Returns the current column value for a given column header name. * * @param headerName * The header name of the column. * @return The current column value. * @exception IOException * Thrown if this object has already been closed. */ public String get(String headerName) throws IOException { checkClosed(); return get(getIndex(headerName)); }