Source:
public String formatRequest(Position position) { Device device = Context.getIdentityManager().getById(position.getDeviceId()); String request = url .replace("{name}", device.getName()) .replace("{uniqueId}", device.getUniqueId()) .replace("{deviceId}", String.valueOf(position.getDeviceId())) .replace("{protocol}", String.valueOf(position.getProtocol())) .replace("{deviceTime}", String.valueOf(position.getDeviceTime().getTime())) .replace("{fixTime}", String.valueOf(position.getFixTime().getTime())) .replace("{valid}", String.valueOf(position.getValid())) .replace("{latitude}", String.valueOf(position.getLatitude())) .replace("{longitude}", String.valueOf(position.getLongitude())) .replace("{altitude}", String.valueOf(position.getAltitude())) .replace("{speed}", String.valueOf(position.getSpeed())) .replace("{course}", String.valueOf(position.getCourse())) .replace("{statusCode}", calculateStatus(position)) .replace("{status}", device.getStatus()); if (position.getAddress() != null) { try { request = request.replace( "{address}", URLEncoder.encode(position.getAddress(), StandardCharsets.UTF_8.name())); } catch (UnsupportedEncodingException error) { Log.warning(error); } } if (request.contains("{attributes}")) { try { String attributes = Context.getObjectMapper().writeValueAsString(position.getAttributes()); request = request.replace( "{attributes}", URLEncoder.encode(attributes, StandardCharsets.UTF_8.name())); } catch (UnsupportedEncodingException | JsonProcessingException error) { Log.warning(error); } } if (request.contains("{gprmc}")) { request = request.replace("{gprmc}", formatSentence(position)); } return request; }

Target:
public String formatRequest(Position position) { Device device = Context.getIdentityManager().getById(position.getDeviceId()); String request = url .replace("{name}", device.getName()) .replace("{uniqueId}", device.getUniqueId()) .replace("{status}", device.getStatus()) .replace("{deviceId}", String.valueOf(position.getDeviceId())) .replace("{protocol}", String.valueOf(position.getProtocol())) .replace("{deviceTime}", String.valueOf(position.getDeviceTime().getTime())) .replace("{fixTime}", String.valueOf(position.getFixTime().getTime())) .replace("{valid}", String.valueOf(position.getValid())) .replace("{latitude}", String.valueOf(position.getLatitude())) .replace("{longitude}", String.valueOf(position.getLongitude())) .replace("{altitude}", String.valueOf(position.getAltitude())) .replace("{speed}", String.valueOf(position.getSpeed())) .replace("{course}", String.valueOf(position.getCourse())) .replace("{statusCode}", calculateStatus(position)); if (position.getAddress() != null) { try { request = request.replace( "{address}", URLEncoder.encode(position.getAddress(), StandardCharsets.UTF_8.name())); } catch (UnsupportedEncodingException error) { Log.warning(error); } } if (request.contains("{attributes}")) { try { String attributes = Context.getObjectMapper().writeValueAsString(position.getAttributes()); request = request.replace( "{attributes}", URLEncoder.encode(attributes, StandardCharsets.UTF_8.name())); } catch (UnsupportedEncodingException | JsonProcessingException error) { Log.warning(error); } } if (request.contains("{gprmc}")) { request = request.replace("{gprmc}", formatSentence(position)); } return request; }