@@ -0,0 +1,2166 @@
+package com.alexrnl.subtitlecorrector.io.subrip;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.text.ParseException;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;%0A%0Aimport com.alexrnl.subtitlecorrector.common.Subtitle;%0Aimport com.alexrnl.subtitlecorrector.common.SubtitleFile;%0Aimport com.alexrnl.subtitlecorrector.io.SubtitleReader;%0A%0A/**%0A * TODO%0A * @author Alex%0A */%0Apublic class SubRipReader extends SubtitleReader %7B%0A%09/** Logger */%0A%09private static Logger%09%09%09lg%09= Logger.getLogger(SubRipReader.class.getName());%0A%09%0A%09/** The date formatter */%0A%09private final SimpleDateFormat%09dateFormatter;%0A%09%0A%09/**%0A%09 * Constructor #1.%3Cbr /%3E%0A%09 */%0A%09private SubRipReader () %7B%0A%09%09super();%0A%09%09dateFormatter = new SimpleDateFormat(SubRip.SUBRIP_DATE_FORMAT);%0A%09%7D%0A%0A%0A%0A%09@Override%0A%09protected Subtitle readSubtitle (final SubtitleFile subtitleFile, final BufferedReader reader)%0A%09%09%09throws IOException %7B%0A%09%09final long begin;%0A%09%09final long end;%0A%09%09final StringBuilder content = new StringBuilder();%0A%09%09String currentLine;%0A%09%09%0A%09%09// Removing empty lines%0A%09%09do %7B%0A%09%09%09currentLine = reader.readLine().trim();%0A%09%09%7D while (!currentLine.isEmpty());%0A%09%09// Get the subtitle number%0A%09%09final int subtitleIndex = Integer.parseInt(currentLine);%0A%09%09if (lg.isLoggable(Level.INFO)) %7B%0A%09%09%09lg.info(%22Reading subtitle#%22 + subtitleIndex);%0A%09%09%7D%0A%09%09%0A%09%09// Get the begin and end dates of the subtitle%0A%09%09currentLine = reader.readLine().trim();%0A%09%09final String%5B%5D dates = currentLine.split(SubRip.SUBRIP_DATE_SEPARATOR);%0A%09%09if (dates.length %3C 2) %7B%0A%09%09%09throw new IOException(%22Could not parse %22 + currentLine + %22 as a valid line in the subrip format%22);%0A%09%09%7D%0A%09%09try %7B%0A%09%09%09begin = dateFormatter.parse(dates%5B0%5D).getTime();%0A%09%09%09end = dateFormatter.parse(dates%5B1%5D).getTime();%0A%09%09%7D catch (final ParseException e) %7B%0A%09%09%09lg.warning(%22Could not parse either %22 + dates%5B0%5D + %22 or %22 + dates%5B1%5D + %22 as a date%22);%0A%09%09%09throw new IOException(%22Problem while parsing a date%22, e);%0A%09%09%7D%0A%09%09// Get the content of the subtitle%0A%09%09do %7B%0A%09%09%09currentLine = reader.readLine().trim();%0A%09%09%09content.append(currentLine);%0A%09%09%7D while (!currentLine.isEmpty());%0A%09%09%0A%09%09return new Subtitle(begin, end, content.toString());%0A%09%7D%0A%7D%0A

Add the Reader implementation for the SubRip format