public class ScheduleFactory {
protected static final IProgrammesBlockReader programmesBlockReader = new ProgrammesBlockReaderImpl();
public static Schedule createSchedule(final IStorage st) {
Schedule result;
if (st != null) {
result = new Schedule(st, programmesBlockReader);
} else {
result = new Schedule(new StorageInRecordStores(), programmesBlockReader);
if (result.getState() != Schedule.STATE_DATA) {
result = new Schedule(new StorageInClasspath(), programmesBlockReader);
}
byte state = Schedule.STATE_EMPTY;
if (result.getState() != Schedule.STATE_DATA) {
try {
result = new Schedule(new StorageInFilesystem(), programmesBlockReader);
state = result.getState();
} catch (IOException e) {
state = Schedule.STATE_EMPTY;
}
}
if (state != Schedule.STATE_DATA) {
result = new Schedule(new StorageInRecordStores(), programmesBlockReader);
}
}
return result;
}