CellAddressParser { public CellRef parse(final String address) throws ParseException, UnsupportedEncodingException { final int dotIndex = address.lastIndexOf(CellRef.TABLE_CELL_SEP); final String localCellAddress; final TableRef tableRef; if (dotIndex == -1) { tableRef = null; localCellAddress = address; } else { final String tableAddress = address.substring(0, dotIndex); tableRef = this.tableAddressParser.parse(tableAddress); localCellAddress = address.substring(dotIndex + 1); } final LocalCellRef localCellRef = this.localCellAddressParser.parse(localCellAddress); return new CellRef(tableRef, localCellRef); } CellAddressParser(final TableAddressParser tableAddressParser,
                             final LocalCellAddressParser localCellAddressParser); static CellAddressParser create(final TableNameUtil tableNameUtil); CellRef parse(final String address);  }
@Test(expected = ParseException.class) public void testMissingQuote() throws ParseException, IOException { this.parser.parse("'f'f'#t.D3"); }
@Test(expected = ParseException.class) public void testMissingQuote2() throws ParseException, IOException { this.parser.parse("'f''#t.D3"); }
@Test(expected = ParseException.class) public void testRandomQuote2() throws ParseException, IOException { this.parser.parse("f'f#t.D3"); }
@Test public void test() throws ParseException, IOException { final TableRef tableRef = new TableRef(this.tableNameUtil, "f'", "t't", 4); final LocalCellRef localCellRef = new LocalCellRef(2, 3, 3); Assert.assertEquals(new CellRef(tableRef, localCellRef), this.parser.parse("'f'''#'$t''t'.$D$3")); }
@Test public void testShort() throws ParseException, UnsupportedEncodingException { this.exception.expect(ParseException.class); this.exception.expectMessage("Address too short, expected digit: $D$[]"); this.parser.parse("$D$"); }
@Test public void testWrongChar() throws ParseException, UnsupportedEncodingException { this.exception.expect(ParseException.class); this.exception.expectMessage("Expected digit (not 0) or $: $D[@]$5"); this.parser.parse("$D@$5"); }
@Test public void testA0() throws ParseException, UnsupportedEncodingException { this.exception.expect(ParseException.class); this.exception.expectMessage("Expected digit (not 0) or $: A[0]"); this.parser.parse("A0"); }
@Test public void test0A() throws ParseException, UnsupportedEncodingException { this.exception.expect(ParseException.class); this.exception.expectMessage("Expected letter or $: [0]A"); this.parser.parse("0A"); }
@Test public void testA1A() throws ParseException, UnsupportedEncodingException { this.exception.expect(ParseException.class); this.exception.expectMessage("Expected digit: A1[A]"); this.parser.parse("A1A"); }