@Test public void testGetGridIndex() { assertEquals("in", SlstrProductFactory.getGridIndex("a_name_ending_in_in")); assertEquals("io", SlstrProductFactory.getGridIndex("a_name_ending_in_io")); assertEquals("fn", SlstrProductFactory.getGridIndex("a_name_ending_in_fn")); assertEquals("tx", SlstrProductFactory.getGridIndex("a_name_ending_in_tx")); assertEquals("in", SlstrProductFactory.getGridIndex("a_name_ending_in_in_lsb")); assertEquals("io", SlstrProductFactory.getGridIndex("a_name_ending_in_io_msb")); assertEquals("y", SlstrProductFactory.getGridIndex("y")); assertEquals("th", SlstrProductFactory.getGridIndex("th_fetrzgh")); assertEquals("gh", SlstrProductFactory.getGridIndex("the_fetrzgh")); assertEquals("f", SlstrProductFactory.getGridIndex("thtcfzghj_f")); assertEquals("-f", SlstrProductFactory.getGridIndex("thtcfzghj-f")); assertEquals("ao", SlstrProductFactory.getGridIndex("S1_exception_ao_no_parameters")); }
static String getGridIndex(String bandName) { String[] nameParts = bandName.split("_"); int lastPartIndex = nameParts.length - 1; int index = lastPartIndex; int firstIndexOfPartWithTwoLetters = -1; while (index >= 0) { if (ArrayUtils.isMemberOf(nameParts[index], SLSTR_GRID_INDEXES)) { return nameParts[index]; } else if (firstIndexOfPartWithTwoLetters < 0 && nameParts[index].length() == 2) { firstIndexOfPartWithTwoLetters = index; } index--; } if (firstIndexOfPartWithTwoLetters >= 0) { return nameParts[firstIndexOfPartWithTwoLetters]; } if (nameParts[lastPartIndex].length() > 1) { return nameParts[lastPartIndex].substring(nameParts[lastPartIndex].length() - 2); } return nameParts[lastPartIndex]; }
SlstrProductFactory extends AbstractProductFactory { static String getGridIndex(String bandName) { String[] nameParts = bandName.split("_"); int lastPartIndex = nameParts.length - 1; int index = lastPartIndex; int firstIndexOfPartWithTwoLetters = -1; while (index >= 0) { if (ArrayUtils.isMemberOf(nameParts[index], SLSTR_GRID_INDEXES)) { return nameParts[index]; } else if (firstIndexOfPartWithTwoLetters < 0 && nameParts[index].length() == 2) { firstIndexOfPartWithTwoLetters = index; } index--; } if (firstIndexOfPartWithTwoLetters >= 0) { return nameParts[firstIndexOfPartWithTwoLetters]; } if (nameParts[lastPartIndex].length() > 1) { return nameParts[lastPartIndex].substring(nameParts[lastPartIndex].length() - 2); } return nameParts[lastPartIndex]; } }
SlstrProductFactory extends AbstractProductFactory { static String getGridIndex(String bandName) { String[] nameParts = bandName.split("_"); int lastPartIndex = nameParts.length - 1; int index = lastPartIndex; int firstIndexOfPartWithTwoLetters = -1; while (index >= 0) { if (ArrayUtils.isMemberOf(nameParts[index], SLSTR_GRID_INDEXES)) { return nameParts[index]; } else if (firstIndexOfPartWithTwoLetters < 0 && nameParts[index].length() == 2) { firstIndexOfPartWithTwoLetters = index; } index--; } if (firstIndexOfPartWithTwoLetters >= 0) { return nameParts[firstIndexOfPartWithTwoLetters]; } if (nameParts[lastPartIndex].length() > 1) { return nameParts[lastPartIndex].substring(nameParts[lastPartIndex].length() - 2); } return nameParts[lastPartIndex]; } SlstrProductFactory(Sentinel3ProductReader productReader); }
SlstrProductFactory extends AbstractProductFactory { static String getGridIndex(String bandName) { String[] nameParts = bandName.split("_"); int lastPartIndex = nameParts.length - 1; int index = lastPartIndex; int firstIndexOfPartWithTwoLetters = -1; while (index >= 0) { if (ArrayUtils.isMemberOf(nameParts[index], SLSTR_GRID_INDEXES)) { return nameParts[index]; } else if (firstIndexOfPartWithTwoLetters < 0 && nameParts[index].length() == 2) { firstIndexOfPartWithTwoLetters = index; } index--; } if (firstIndexOfPartWithTwoLetters >= 0) { return nameParts[firstIndexOfPartWithTwoLetters]; } if (nameParts[lastPartIndex].length() > 1) { return nameParts[lastPartIndex].substring(nameParts[lastPartIndex].length() - 2); } return nameParts[lastPartIndex]; } SlstrProductFactory(Sentinel3ProductReader productReader);  }
SlstrProductFactory extends AbstractProductFactory { static String getGridIndex(String bandName) { String[] nameParts = bandName.split("_"); int lastPartIndex = nameParts.length - 1; int index = lastPartIndex; int firstIndexOfPartWithTwoLetters = -1; while (index >= 0) { if (ArrayUtils.isMemberOf(nameParts[index], SLSTR_GRID_INDEXES)) { return nameParts[index]; } else if (firstIndexOfPartWithTwoLetters < 0 && nameParts[index].length() == 2) { firstIndexOfPartWithTwoLetters = index; } index--; } if (firstIndexOfPartWithTwoLetters >= 0) { return nameParts[firstIndexOfPartWithTwoLetters]; } if (nameParts[lastPartIndex].length() > 1) { return nameParts[lastPartIndex].substring(nameParts[lastPartIndex].length() - 2); } return nameParts[lastPartIndex]; } SlstrProductFactory(Sentinel3ProductReader productReader);   }