test_class.declarator: spreadsheetReader
test_class.modifier: private
test_class.original_string: private SpreadsheetReader spreadsheetReader;
test_class.type: SpreadsheetReader
test_class.var_name: spreadsheetReader
test_class.file: taverna-spreadsheet-import-activity/src/test/java/org/apache/taverna/activities/spreadsheet/ODFSpreadsheetReaderTest.java
test_class.identifier: ODFSpreadsheetReaderTest
test_case.body: @Test
  	public void testRead() throws Exception {
  		String[] testFiles2 = new String[] { "/test-spreadsheet.ods" };
  		for (int i = 0; i < testFiles2.length; i++) {
  			final List<Integer> rows = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 5));
  			spreadsheetReader.read(getClass().getResourceAsStream(testFiles2[i]), new Range(0, 5), new Range(0, 4), false,
  					new SpreadsheetRowProcessor() {
  
  						public void processRow(int rowIndex, SortedMap<Integer, String> row) {
  							assertTrue(rows.remove((Integer) rowIndex));
  							List<Integer> columns = new ArrayList<Integer>(Arrays.asList(0, 1, 2,
  									3, 4));
  							for (Entry<Integer, String> cell : row.entrySet()) {
  								assertTrue(columns.remove(cell.getKey()));
  								if (rowIndex == 0) {
  									if (cell.getKey().equals(0)) {
  										assertEquals("A", cell.getValue());
  									} else if (cell.getKey().equals(1)) {
  										assertEquals("5.0", cell.getValue());
  									} else if (cell.getKey().equals(2)) {
  										assertEquals("C", cell.getValue());
  									} else if (cell.getKey().equals(3)) {
  										assertEquals("1.0", cell.getValue());
  									} else {
  										assertNull(cell.getValue());
  									}
  								} else if (rowIndex == 1) {
  									if (cell.getKey().equals(0)) {
  										assertEquals("A", cell.getValue());
  									} else if (cell.getKey().equals(1)) {
  										assertEquals("5.0", cell.getValue());
  									} else if (cell.getKey().equals(2)) {
  										assertEquals("C", cell.getValue());
  									} else if (cell.getKey().equals(3)) {
  										assertEquals("1.0", cell.getValue());
  									} else {
  										assertNull(cell.getValue());
  									}
  								} else if (rowIndex == 2) {
  									if (cell.getKey().equals(0)) {
  										assertEquals("true", cell.getValue());
  									} else if (cell.getKey().equals(1)) {
  										assertEquals("2009-06-15", cell.getValue());
  									} else if (cell.getKey().equals(2)) {
  										assertNull(cell.getValue());
  									} else if (cell.getKey().equals(3)) {
  										assertEquals("2.0", cell.getValue());
  									} else {
  										assertNull(cell.getValue());
  									}
  								} else if (rowIndex == 3 || rowIndex == 4) {
  									if (cell.getKey().equals(4)) {
  										assertNull(cell.getValue());
  									} else {
  										assertEquals("X", cell.getValue());
  									}
  								} else {
  									assertNull(cell.getValue());
  								}
  							}
  							assertTrue(columns.isEmpty());
  						}
  					});
  			assertTrue(rows.isEmpty());
  
  		}
  
  	}
test_case.class_method_signature: ODFSpreadsheetReaderTest.testRead()
test_case.full_signature: @Test public void testRead()
test_case.identifier: testRead
test_case.invocations: asList read getResourceAsStream getClass assertTrue remove asList entrySet assertTrue remove getKey equals getKey assertEquals getValue equals getKey assertEquals getValue equals getKey assertEquals getValue equals getKey assertEquals getValue assertNull getValue equals getKey assertEquals getValue equals getKey assertEquals getValue equals getKey assertEquals getValue equals getKey assertEquals getValue assertNull getValue equals getKey assertEquals getValue equals getKey assertEquals getValue equals getKey assertNull getValue equals getKey assertEquals getValue assertNull getValue equals getKey assertNull getValue assertEquals getValue assertNull getValue assertTrue isEmpty assertTrue isEmpty
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRead()
focal_class.declarator: logger = Logger.getLogger(ODFSpreadsheetReader.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = Logger.getLogger(ODFSpreadsheetReader.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: taverna-spreadsheet-import-activity/src/main/java/org/apache/taverna/activities/spreadsheet/ODFSpreadsheetReader.java
focal_class.identifier: ODFSpreadsheetReader
focal_class.interfaces: implements SpreadsheetReader
focal_class.class_method_signature: ODFSpreadsheetReader.read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_class.full_signature: public void read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_class.identifier: read
focal_class.modifiers: public
focal_class.parameters: (InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_class.return: void
focal_class.signature: void read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_class.class_method_signature: ODFSpreadsheetReader.calculateRowCount(NodeList rowList)
focal_class.full_signature: private int calculateRowCount(NodeList rowList)
focal_class.identifier: calculateRowCount
focal_class.modifiers: private
focal_class.parameters: (NodeList rowList)
focal_class.return: int
focal_class.signature: int calculateRowCount(NodeList rowList)
focal_class.class_method_signature: ODFSpreadsheetReader.isBlankRow(OdfTableRow row)
focal_class.full_signature: private boolean isBlankRow(OdfTableRow row)
focal_class.identifier: isBlankRow
focal_class.modifiers: private
focal_class.parameters: (OdfTableRow row)
focal_class.return: boolean
focal_class.signature: boolean isBlankRow(OdfTableRow row)
focal_method.body: public void read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
  			throws SpreadsheetReadException {
  		NodeList rowList = null;
  		try {
  			// Load the ODF document
  			OdfDocument odfDoc = OdfDocument.loadDocument(inputStream);
  			logger.debug("Reading document of type : " + odfDoc.getMediaType());
  			// Get the content as DOM tree
  			OdfFileDom odfContent = odfDoc.getContentDom();
  			// Initialize XPath
  			XPath xpath = odfDoc.getXPath();
  			// Get the rows of the first table
  			String rowsPath = ("//table:table[1]/table:table-row");
  			rowList = (NodeList) xpath.evaluate(rowsPath, odfContent, XPathConstants.NODESET);
  		} catch (Exception e) {
  			if (e instanceof RuntimeException) {
  				throw (RuntimeException) e;
  			}
  			throw new SpreadsheetReadException("The spreadsheet file could not be read", e);
  		}
  
  		if (rowRange.getEnd() < 0) {
  			rowRange.setEnd(calculateRowCount(rowList) - 1);
  		}
  
  		SortedMap<Integer, String> currentDataRow = new TreeMap<Integer, String>();
  		int rowRep = 0;
  		for (int rowIndex = rowRange.getStart(); rowIndex <= rowRange.getEnd(); rowIndex++) {
  			boolean blankRow = true;
  			OdfTableRow row = (OdfTableRow) rowList.item(rowIndex);
  			int columnRep = 0;
  			for (int columnIndex = columnRange.getStart(); columnIndex <= columnRange.getEnd(); columnIndex++) {
  				String value = null;
  				OdfTableCell cell = null;
  				if (row != null) {
  					cell = (OdfTableCell) row.getCellAt(columnIndex);
  					if (cell != null) {
  						String type = cell.getOfficeValueTypeAttribute();
  						if ("float".equals(type)) {
  							value = cell.getOfficeValueAttribute().toString();
  						} else if ("percentage".equals(type)) {
  							value = cell.getOfficeValueAttribute().toString();
  						} else if ("currency".equals(type)) {
  							value = cell.getOfficeValueAttribute().toString();
  						} else if ("date".equals(type)) {
  							value = cell.getOfficeDateValueAttribute();
  						} else if ("time".equals(type)) {
  							value = cell.getOfficeTimeValueAttribute();
  						} else if ("boolean".equals(type)) {
  							value = cell.getOfficeBooleanValueAttribute().toString();
  						} else if ("string".equals(type)) {
  							value = cell.getOfficeStringValueAttribute();
  							if (value == null) {
  								value = cell.getTextContent();
  							}
  						} else {
  							value = cell.getTextContent();
  						}
  					}
  				}
  				value = "".equals(value) ? null : value;
  				if (value != null) {
  					blankRow = false;
  				}
  				// if the cell is within the column range add it to the row values
  				if (columnRange.contains(columnIndex + columnRep)) {
  					currentDataRow.put(columnIndex + columnRep, value);
  				}
  				// check if this cell is repeated
  				int repeatedCells = cell == null ? 0 : cell
  						.getTableNumberColumnsRepeatedAttribute() - 1;
  				while (repeatedCells > 0 && columnIndex + columnRep < columnRange.getEnd()) {
  					columnRep++;
  					if (columnRange.contains(columnIndex + columnRep)) {
  						currentDataRow
  								.put(columnIndex + columnRep, value);
  					}
  					repeatedCells--;
  				}
  				// if it's the last cell in the range process the row
  				if (columnIndex == columnRange.getEnd()) {
  					if (rowRange.contains(rowIndex + rowRep)) {
  						if (!ignoreBlankRows || !blankRow) {
  							rowProcessor.processRow(rowIndex + rowRep, currentDataRow);
  						}
  					}
  					// check if this row is repeated
  					int repeatedRows = row == null ? 0
  							: row.getTableNumberRowsRepeatedAttribute() - 1;
  					while (repeatedRows > 0 && rowIndex + rowRep < rowRange.getEnd()) {
  						rowRep++;
  						if (rowRange.contains(rowIndex + rowRep)) {
  							if (!ignoreBlankRows || !blankRow) {
  								rowProcessor.processRow(rowIndex + rowRep, currentDataRow);
  							}
  						}
  						repeatedRows--;
  					}
  					currentDataRow = new TreeMap<Integer, String>();
  				}
  
  			}
  		}
  
  	}
focal_method.class_method_signature: ODFSpreadsheetReader.read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_method.full_signature: public void read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_method.identifier: read
focal_method.invocations: loadDocument debug getMediaType getContentDom getXPath evaluate getEnd setEnd calculateRowCount getStart getEnd item getStart getEnd getCellAt getOfficeValueTypeAttribute equals toString getOfficeValueAttribute equals toString getOfficeValueAttribute equals toString getOfficeValueAttribute equals getOfficeDateValueAttribute equals getOfficeTimeValueAttribute equals toString getOfficeBooleanValueAttribute equals getOfficeStringValueAttribute getTextContent getTextContent equals contains put getTableNumberColumnsRepeatedAttribute getEnd contains put getEnd contains processRow getTableNumberRowsRepeatedAttribute getEnd contains processRow
focal_method.modifiers: public
focal_method.parameters: (InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_method.return: void
focal_method.signature: void read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)