public static Trigger readTrigger(MarshallerReaderContext inCtx,
ProtobufMessages.Trigger _trigger) {
switch ( _trigger.getType() ) {
case CRON : {
ProtobufMessages.Trigger.CronTrigger _cron = _trigger.getCron();
CronTrigger trigger = new CronTrigger();
trigger.setStartTime( new Date( _cron.getStartTime() ) );
if ( _cron.hasEndTime() ) {
trigger.setEndTime( new Date( _cron.getEndTime() ) );
}
trigger.setRepeatLimit( _cron.getRepeatLimit() );
trigger.setRepeatCount( _cron.getRepeatCount() );
trigger.setCronExpression( _cron.getCronExpression() );
if ( _cron.hasNextFireTime() ) {
trigger.setNextFireTime( new Date( _cron.getNextFireTime() ) );
}
String[] calendarNames = new String[_cron.getCalendarNameCount()];
for ( int i = 0; i < calendarNames.length; i++ ) {
calendarNames[i] = _cron.getCalendarName( i );
}
trigger.setCalendarNames( calendarNames );
return trigger;
}
case INTERVAL : {
ProtobufMessages.Trigger.IntervalTrigger _interval = _trigger.getInterval();
IntervalTrigger trigger = new IntervalTrigger();
trigger.setStartTime( new Date( _interval.getStartTime() ) );
if ( _interval.hasEndTime() ) {
trigger.setEndTime( new Date( _interval.getEndTime() ) );
}
trigger.setRepeatLimit( _interval.getRepeatLimit() );
trigger.setRepeatCount( _interval.getRepeatCount() );
if ( _interval.hasNextFireTime() ) {
trigger.setNextFireTime( new Date( _interval.getNextFireTime() ) );
}
trigger.setPeriod( _interval.getPeriod() );
String[] calendarNames = new String[_interval.getCalendarNameCount()];
for ( int i = 0; i < calendarNames.length; i++ ) {
calendarNames[i] = _interval.getCalendarName( i );
}
trigger.setCalendarNames( calendarNames );
return trigger;
}
case POINT_IN_TIME : {
PointInTimeTrigger trigger = new PointInTimeTrigger( _trigger.getPit().getNextFireTime(), null, null );
return trigger;
}
case COMPOSITE_MAX_DURATION : {
ProtobufMessages.Trigger.CompositeMaxDurationTrigger _cmdTrigger = _trigger.getCmdt();
CompositeMaxDurationTrigger trigger = new CompositeMaxDurationTrigger();
if ( _cmdTrigger.hasMaxDurationTimestamp() ) {
trigger.setMaxDurationTimestamp( new Date( _cmdTrigger.getMaxDurationTimestamp() ) );
}
if ( _cmdTrigger.hasTimerCurrentDate() ) {
trigger.setTimerCurrentDate( new Date( _cmdTrigger.getTimerCurrentDate() ) );
}
if ( _cmdTrigger.hasTimerTrigger() ) {
trigger.setTimerTrigger( readTrigger( inCtx, _cmdTrigger.getTimerTrigger() ) );
}
return trigger;
}
}
throw new RuntimeException( "Unable to deserialize Trigger for type: " + _trigger.getType() );