private Program createProgramFromFrame(ProgramFrame frame, Date date,
Channel channel)
throws TvBrowserException
{
ProgramField field;
// start time
field = frame.getProgramFieldOfType(ProgramFieldType.START_TIME_TYPE);
if (field == null) {
throw new TvBrowserException(getClass(), "error.3",
"Program frame with ID {0} has no start time.", frame.getId());
}
int startTime = field.getTimeData();
MutableProgram program
= new MutableProgram(channel, date, startTime / 60, startTime % 60, true);
int fieldCount = frame.getProgramFieldCount();
for (int i = 0; i < fieldCount; i++) {
field = frame.getProgramFieldAt(i);
ProgramFieldType type = field.getType();
if (type.getFormat() == ProgramFieldType.BINARY_FORMAT) {
program.setBinaryField(type, field.getBinaryData());
}
else if (type.getFormat() == ProgramFieldType.TEXT_FORMAT) {
program.setTextField(type, field.getTextData());
}
else if (type.getFormat() == ProgramFieldType.INT_FORMAT) {
program.setIntField(type, field.getIntData());
}
else if (type.getFormat() == ProgramFieldType.TIME_FORMAT) {
program.setTimeField(type, field.getTimeData());
}
}
program.setProgramLoadingIsComplete();