@Test public void testInsertSubtitle2() throws Exception { SRTInfo srtInfo = new SRTInfo(); for (int i = 1; i <= 4; i++) { srtInfo.add(new SRT(i, SRTTimeFormat.parse("00:00:24,600"), SRTTimeFormat.parse("00:00:26,600"), "Foo" + i)); } SRTEditor.insertSubtitle(srtInfo, new SRT(3, SRTTimeFormat.parse("00:00:24,600"), SRTTimeFormat.parse("00:00:26,600"), Arrays.asList("Foo100"))); assertEquals(5, srtInfo.size()); SRT srt = srtInfo.get(1); assertEquals("Foo1", StringUtils.join(srt.text, "")); srt = srtInfo.get(2); assertEquals("Foo2", StringUtils.join(srt.text, "")); srt = srtInfo.get(3); assertEquals("Foo100", StringUtils.join(srt.text, "")); srt = srtInfo.get(4); assertEquals("Foo3", StringUtils.join(srt.text, "")); srt = srtInfo.get(5); assertEquals("Foo4", StringUtils.join(srt.text, "")); }
public static void insertSubtitle(SRTInfo info, int subtitleNumber, String startTime, String endTime, List<String> text) { if (!info.contains(subtitleNumber)) { throw new SRTEditorException(subtitleNumber + " could not be found"); } for (int i = info.size(); i >= subtitleNumber; i--) { SRT tmp = info.get(i); info.add(new SRT(tmp.number+1, tmp.startTime, tmp.endTime, tmp.text)); } try { info.add(new SRT(subtitleNumber, SRTTimeFormat.parse(startTime), SRTTimeFormat.parse(endTime), text)); } catch (ParseException e) { throw new SRTEditorException(e); } }
SRTEditor { public static void insertSubtitle(SRTInfo info, int subtitleNumber, String startTime, String endTime, List<String> text) { if (!info.contains(subtitleNumber)) { throw new SRTEditorException(subtitleNumber + " could not be found"); } for (int i = info.size(); i >= subtitleNumber; i--) { SRT tmp = info.get(i); info.add(new SRT(tmp.number+1, tmp.startTime, tmp.endTime, tmp.text)); } try { info.add(new SRT(subtitleNumber, SRTTimeFormat.parse(startTime), SRTTimeFormat.parse(endTime), text)); } catch (ParseException e) { throw new SRTEditorException(e); } } }
SRTEditor { public static void insertSubtitle(SRTInfo info, int subtitleNumber, String startTime, String endTime, List<String> text) { if (!info.contains(subtitleNumber)) { throw new SRTEditorException(subtitleNumber + " could not be found"); } for (int i = info.size(); i >= subtitleNumber; i--) { SRT tmp = info.get(i); info.add(new SRT(tmp.number+1, tmp.startTime, tmp.endTime, tmp.text)); } try { info.add(new SRT(subtitleNumber, SRTTimeFormat.parse(startTime), SRTTimeFormat.parse(endTime), text)); } catch (ParseException e) { throw new SRTEditorException(e); } } private  SRTEditor(); }
SRTEditor { public static void insertSubtitle(SRTInfo info, int subtitleNumber, String startTime, String endTime, List<String> text) { if (!info.contains(subtitleNumber)) { throw new SRTEditorException(subtitleNumber + " could not be found"); } for (int i = info.size(); i >= subtitleNumber; i--) { SRT tmp = info.get(i); info.add(new SRT(tmp.number+1, tmp.startTime, tmp.endTime, tmp.text)); } try { info.add(new SRT(subtitleNumber, SRTTimeFormat.parse(startTime), SRTTimeFormat.parse(endTime), text)); } catch (ParseException e) { throw new SRTEditorException(e); } } private  SRTEditor(); static void updateTime(SRTInfo info, int subtitleNumber,
        SRTTimeFormat.Type type, int value); static void updateTimes(SRTInfo info, SRTTimeFormat.Type type, int value); static void updateText(SRTInfo info, int subtitleNumber, int width); static void updateTexts(SRTInfo info, int width); static void appendSubtitle(SRTInfo info, String startTime,
        String endTime, List<String> text); static void prependSubtitle(SRTInfo info, String startTime,
        String endTime, List<String> text); static void insertSubtitle(SRTInfo info, int subtitleNumber,
        String startTime, String endTime, List<String> text); static void insertSubtitle(SRTInfo info, SRT newSRT); static void removeSubtitle(SRTInfo info, int subtitleNumber); static void updateSubtitle(SRTInfo info, SRT srt); }
SRTEditor { public static void insertSubtitle(SRTInfo info, int subtitleNumber, String startTime, String endTime, List<String> text) { if (!info.contains(subtitleNumber)) { throw new SRTEditorException(subtitleNumber + " could not be found"); } for (int i = info.size(); i >= subtitleNumber; i--) { SRT tmp = info.get(i); info.add(new SRT(tmp.number+1, tmp.startTime, tmp.endTime, tmp.text)); } try { info.add(new SRT(subtitleNumber, SRTTimeFormat.parse(startTime), SRTTimeFormat.parse(endTime), text)); } catch (ParseException e) { throw new SRTEditorException(e); } } private  SRTEditor(); static void updateTime(SRTInfo info, int subtitleNumber,
        SRTTimeFormat.Type type, int value); static void updateTimes(SRTInfo info, SRTTimeFormat.Type type, int value); static void updateText(SRTInfo info, int subtitleNumber, int width); static void updateTexts(SRTInfo info, int width); static void appendSubtitle(SRTInfo info, String startTime,
        String endTime, List<String> text); static void prependSubtitle(SRTInfo info, String startTime,
        String endTime, List<String> text); static void insertSubtitle(SRTInfo info, int subtitleNumber,
        String startTime, String endTime, List<String> text); static void insertSubtitle(SRTInfo info, SRT newSRT); static void removeSubtitle(SRTInfo info, int subtitleNumber); static void updateSubtitle(SRTInfo info, SRT srt);  }