Source:
private Position decodeU01(String sentence, Channel channel, SocketAddress remoteAddress) { Parser parser = new Parser(PATTERN_U01, sentence); if (!parser.matches()) { return null; } DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); if (deviceSession == null) { return null; } String messageType = parser.next(); Position position = new Position(); position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); DateBuilder dateBuilder = new DateBuilder() .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()) .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); position.setTime(dateBuilder.getDate()); position.setValid(parser.next().equals("T")); position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble())); position.setCourse(parser.nextDouble()); position.set(Position.KEY_SATELLITES, parser.nextInt()); position.set(Position.KEY_BATTERY, parser.next()); position.set(Position.KEY_STATUS, parser.nextInt(2)); position.set(Position.KEY_CID, parser.nextInt()); position.set(Position.KEY_LAC, parser.nextInt()); position.set(Position.KEY_GSM, parser.nextInt()); position.set(Position.KEY_ODOMETER, parser.nextLong() * 100); position.set(Position.KEY_INDEX, parser.nextInt()); switch (messageType) { case "U01": case "U02": case "U03": String checkSum = parser.next(); int calculatedCheckSum = checkSum(sentence.substring(1, sentence.length() - checkSum.length() - 1)); if (Integer.parseInt(checkSum, 16) == calculatedCheckSum) { sendResponse(channel, "(S39)"); return position; } else { return null; } case "U06": sendResponse(channel, "(S20)"); return position; default: return null; } }

Target:
private Position decodeU01(String sentence, Channel channel, SocketAddress remoteAddress) { Parser parser = new Parser(PATTERN_U01, sentence); if (!parser.matches()) { return null; } DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); if (deviceSession == null) { return null; } String messageType = parser.next(); Position position = new Position(); position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); DateBuilder dateBuilder = new DateBuilder() .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()) .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); position.setTime(dateBuilder.getDate()); position.setValid(parser.next().equals("T")); position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble())); position.setCourse(parser.nextDouble()); position.set(Position.KEY_SATELLITES, parser.nextInt()); position.set(Position.KEY_BATTERY, parser.next()); position.set(Position.KEY_STATUS, parser.nextInt(2)); position.set(Position.KEY_CID, parser.nextInt()); position.set(Position.KEY_LAC, parser.nextInt()); position.set(Position.KEY_GSM, parser.nextInt()); position.set(Position.KEY_ODOMETER, parser.nextLong() * 1000); position.set(Position.KEY_INDEX, parser.nextInt()); switch (messageType) { case "U01": case "U02": case "U03": if (parser.hasNext(2)) { int checkSum = parser.nextInt(16); int calculatedCheckSum = Checksum.xor(sentence.substring(1, sentence.length() - 3)); if (checkSum == calculatedCheckSum) { sendResponse(channel, "(S39)"); return position; } else { return null; } } else { return position; } case "U06": sendResponse(channel, "(S20)"); return position; default: return null; } }