Table extends Component { String[] splitCellAddress(String cellAddress) { String[] returnArray = new String[3]; StringTokenizer stDot = new StringTokenizer(cellAddress, "."); String cell = ""; if (stDot.countTokens() >= 2) { StringTokenizer stDollar = new StringTokenizer(stDot.nextToken(), "$"); returnArray[0] = stDollar.nextToken(); cell = stDot.nextToken(); } else { returnArray[0] = getTableName(); cell = stDot.nextToken(); } StringTokenizer stDollar = new StringTokenizer(cell, "$"); if (stDollar.countTokens() >= 2) { returnArray[1] = stDollar.nextToken(); returnArray[2] = stDollar.nextToken(); } else { cell = stDollar.nextToken(); for (int i = 0; i < cell.length(); i++) { if (!Character.isLetter(cell.charAt(i))) { returnArray[1] = cell.substring(0, i); returnArray[2] = cell.substring(i); break; } } } return returnArray; } private  Table(TableContainer container, TableTableElement table); static Table getInstance(TableTableElement element); static Table newTable(TableContainer tableContainer); static Table newTable(TableContainer tableContainer, int numRows, int numCols); static Table newTable(TableContainer tableContainer, int numRows, int numCols, 
			double marginLeft, double marginRight); static Table newTable(TableContainer tableContainer, int numRows, int numCols, int headerRowNumber,
			int headerColumnNumber); static Table newTable(TableContainer tableContainer, String[] rowLabel, String[] columnLabel, double[][] data); static Table newTable(TableContainer tableContainer, String[] rowLabel, String[] columnLabel, String[][] data); double getWidth(); void setWidth(double width); void applyStyle(TableTemplate template); int getRowCount(); int getColumnCount(); Row appendRow(); List<Row> appendRows(int rowCount); Column appendColumn(); List<Column> appendColumns(int columnCount); TableTableElement getOdfElement(); List<Column> insertColumnsBefore(int index, int columnCount); void removeColumnsByIndex(int startIndex, int deleteColCount); List<Row> insertRowsBefore(int index, int rowCount); List<Column> getColumnList(); Iterator<Column> getColumnIterator(); List<Row> getRowList(); Iterator<Row> getRowIterator(); Column getColumnByIndex(int index); Row getRowByIndex(int index); void removeRowsByIndex(int startIndex, int deleteRowCount); void remove(); int getHeaderRowCount(); int getHeaderColumnCount(); String getTableName(); void setTableName(String tableName); boolean isProtected(); void setProtected(boolean isProtected); boolean isCellStyleInheritance(); void setCellStyleInheritance(boolean isEnabled); boolean isUseRepeat(); void setUseRepeat(boolean isSingle); CellRange getCellRangeByPosition(int startCol, int startRow, int endCol, int endRow); CellRange getCellRangeByPosition(String startAddress, String endAddress); CellRange getCellRangeByName(String name); Cell getCellByPosition(int colIndex, int rowIndex); Cell getCellByPosition(String address); void setVerticalMargin(double spaceTop, double spaceBottom); DefaultStyleHandler getStyleHandler();  }
@Test public void testSplitCellAddress() { mOdtDoc = loadODTDocument(mOdtTestFileName + ".odt"); Table table1 = mOdtDoc.getTableByName("Table1"); String[] address = table1.splitCellAddress("A1"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("A", address[1]); Assert.assertEquals("1", address[2]); address = table1.splitCellAddress("AC1"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("AC", address[1]); Assert.assertEquals("1", address[2]); address = table1.splitCellAddress("B34"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("B", address[1]); Assert.assertEquals("34", address[2]); address = table1.splitCellAddress("AC29"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("AC", address[1]); Assert.assertEquals("29", address[2]); address = table1.splitCellAddress("Table1.A1"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("A", address[1]); Assert.assertEquals("1", address[2]); address = table1.splitCellAddress("Table1.AC1"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("AC", address[1]); Assert.assertEquals("1", address[2]); address = table1.splitCellAddress("Table1.B34"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("B", address[1]); Assert.assertEquals("34", address[2]); address = table1.splitCellAddress("Table1.AC29"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("AC", address[1]); Assert.assertEquals("29", address[2]); address = table1.splitCellAddress("$Table1.$A$1"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("A", address[1]); Assert.assertEquals("1", address[2]); address = table1.splitCellAddress("$Table1.$AC$1"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("AC", address[1]); Assert.assertEquals("1", address[2]); address = table1.splitCellAddress("$Table1.$B$34"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("B", address[1]); Assert.assertEquals("34", address[2]); address = table1.splitCellAddress("$Table1.$AC$29"); Assert.assertEquals("Table1", address[0]); Assert.assertEquals("AC", address[1]); Assert.assertEquals("29", address[2]); }