/**
   * DOCUMENT ME!
   *
   * @return DOCUMENT ME!
   */
  public String getReport() {
    final StringBuilder sb = new StringBuilder();
    final Map<String, Object> invalid = parser.getInvalidMap();
    sb.append(globalCounter + " entries are loaded and mapped into table.");

    if (invalid.size() > 0) {
      sb.append("\n\nThe following enties are invalid and were not imported:\n");
      int limit = 10;
      for (String key : invalid.keySet()) {
        sb.append(key + " = " + invalid.get(key) + "\n");
        if (limit-- <= 0) {
          sb.append(
              "Approximately "
                  + (invalid.size() - 10)
                  + " additional entries were not imported...");
          break;
        }
      }
    }
    return sb.toString();
  }
  @Override
  public void readTable(CyTable table) throws IOException {
    Row row;
    int rowCount = startLineNumber;
    String[] cellsInOneRow;

    while ((row = sheet.getRow(rowCount)) != null) {
      cellsInOneRow = createElementStringArray(row);
      try {
        // if(importAll)
        parser.parseAll(table, cellsInOneRow);
        // else
        //	parser.parseEntry(table, cellsInOneRow);
      } catch (Exception ex) {
        logger.warn("Couldn't parse row: " + rowCount, ex);
      }

      rowCount++;
      globalCounter++;
    }
  }
  /** Read table from the data source. */
  public void readTable(CyTable table) throws IOException {
    // InputStream is = null;

    try {
      BufferedReader bufRd = null;

      if (is == null) {
        is = URLUtil.getInputStream(source);
      }
      try {

        // This data is shared by both the OpenCSV and the old method of reading files.
        int lineCount = 0;
        bufRd =
            new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8").newDecoder()));
        /*
         * Read & extract one line at a time. The line can be Tab delimited,
         */
        final String delimiter = mapping.getDelimiterRegEx();

        // If the delimiter contains a comma, treat the file as a CSV file.
        if (delimiter.contains(TextFileDelimiters.COMMA.toString())
            && mapping.getDelimiters().size() == 1) {
          // Use OpenCSV.. New method...
          CSVReader reader = new CSVReader(bufRd);
          String[] rowData; // Note that rowData is roughly equivalent to "parts" in the old code.
          while ((rowData = reader.readNext()) != null) {
            // If key dos not exists, ignore the line.
            if (lineCount >= startLineNumber && rowData.length >= mapping.getKeyIndex() + 1) {
              try {
                // if(importAll) {
                parser.parseAll(table, rowData);
                // } else
                //	parser.parseEntry(table, parts);
              } catch (Exception ex) {
                logger.warn("Couldn't parse row from OpenCSV: " + lineCount);
              }
              globalCounter++;
            }
            lineCount++;
          }

        } else // Use the "old" method for splitting the lines.
        {
          String line;
          String[] parts = null;
          while ((line = bufRd.readLine()) != null) {
            /*
             * Ignore Empty & Commnet lines.
             */
            if ((commentChar != null) && line.startsWith(commentChar)) {
              // Do nothing
            } else if ((lineCount >= startLineNumber) && (line.trim().length() > 0)) {
              parts = line.split(delimiter);
              // If key dos not exists, ignore the line.
              if (parts.length >= mapping.getKeyIndex() + 1) {
                try {
                  // if(importAll) {
                  parser.parseAll(table, parts);
                  // } else
                  //	parser.parseEntry(table, parts);
                } catch (Exception ex) {
                  logger.warn("Couldn't parse row: " + lineCount);
                }
                globalCounter++;
              }
            }

            lineCount++;
          }
        }
      } finally {
        if (bufRd != null) {
          bufRd.close();
        }
      }
    } finally {
      if (is != null) {
        is.close();
      }
    }
  }