37 lines
1.1 KiB
Java
37 lines
1.1 KiB
Java
package de.swingbe.ifleet.parser;
|
|
|
|
import de.swingbe.ifleet.model.TcLctMsg;
|
|
import de.swingbe.ifleet.model.Position;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import static de.swingbe.ifleet.model.Position.POSITION_FIELD_NO;
|
|
import static de.swingbe.ifleet.utils.TelegramUtils.popField;
|
|
|
|
class LctMsgParserImpl implements LctMsgParser {
|
|
private final static Logger LOG = LoggerFactory.getLogger(LctMsgParserImpl.class);
|
|
|
|
public final static int DRIVER_NO_FIELD_NO = 1;
|
|
|
|
public TcLctMsg parse(final String type, final String input) {
|
|
LOG.debug("parse() type: " + type);
|
|
|
|
//parse position
|
|
Position position = PositionParserFactory.createPositionParser().parse(input);
|
|
|
|
//parse driver number
|
|
String inputNew = popField(input, POSITION_FIELD_NO);
|
|
|
|
String[] splits = inputNew.split("#");
|
|
|
|
String driverNo = "";
|
|
if (splits.length > 0) {
|
|
driverNo = splits[0];
|
|
}
|
|
|
|
//parse trip
|
|
inputNew = popField(inputNew, DRIVER_NO_FIELD_NO);
|
|
return new TcLctMsg(type, position, driverNo, TripParserFactory.createTripParser().parse(inputNew));
|
|
}
|
|
}
|