TimeStampExtractor { private void init() { createGroupIndices(); final boolean filenameHasStartTime = filenamePattern.contains(START_DATE_PLACEHOLDER); final boolean filenameHasStopTime = filenamePattern.contains(END_DATE_PLACEHOLDER); if (filenameHasStopTime && filenameHasStartTime) { timeStampAccess = new RangeTimeAccess(); } else if (filenameHasStartTime || filenameHasStopTime) { timeStampAccess = new SingleTimeAccess(); } else { throw new IllegalStateException(MessageFormat.format( "Filename interpretation pattern ''{0} needs to contain at least one of ''{1}'' and ''{2}''.", filenamePattern, START_DATE_PLACEHOLDER, END_DATE_PLACEHOLDER)); } timeStampAccess.init(); } TimeStampExtractor(String dateInterpretationPattern, String filenameInterpretationPattern); ProductData.UTC[] extractTimeStamps(String fileName);  }
@Test public void testInit() throws Exception { new TimeStampExtractor("yyyyMMdd", "*${startDate}*.dim"); new TimeStampExtractor("yyyyMMdd", "*${startDate}*${endDate}.dim"); new TimeStampExtractor("yyyyMMdd", "*${endDate}.dim"); try { new TimeStampExtractor("yyyyMMdd", "something.dim"); fail(); } catch (IllegalStateException expected) { } }