@Override public String encode(JainMgcpResponseEvent event) { RestartInProgressResponse response = (RestartInProgressResponse) event; ReturnCode returnCode = response.getReturnCode(); StringBuffer s = new StringBuffer(); s.append(returnCode.getValue()).append(SINGLE_CHAR_SPACE).append(response.getTransactionHandle()).append( SINGLE_CHAR_SPACE).append(returnCode.getComment()).append(NEW_LINE); // TODO should utils.encodeNotifiedEntity decide on port? if (response.getNotifiedEntity() != null) { Utils utils = utilsFactory.allocate(); s.append("N:").append(utils.encodeNotifiedEntity(response.getNotifiedEntity())).append(NEW_LINE); utilsFactory.deallocate(utils); } return s.toString(); // return msg; }
@Override public int encode(JainMgcpResponseEvent event,byte[] array) { RestartInProgressResponse response = (RestartInProgressResponse) event; ReturnCode returnCode = response.getReturnCode(); int totalLength=ReturnCodeHandler.encode(array,0,returnCode); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,totalLength,response.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; byte[] commentBytes=returnCode.getComment().getBytes(); System.arraycopy(commentBytes, 0, array,totalLength, commentBytes.length); totalLength+=commentBytes.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; if (response.getNotifiedEntity() != null) { array[totalLength++]=StringFunctions.HIGH_N_BYTE; array[totalLength++]=StringFunctions.COLON_BYTE; totalLength+=NotifiedEntityHandler.encode(array,totalLength,response.getNotifiedEntity()); array[totalLength++]=StringFunctions.NEWLINE_BYTE; } return totalLength; }
@Override public int encode(JainMgcpResponseEvent event,byte[] array) { RestartInProgressResponse response = (RestartInProgressResponse) event; ReturnCode returnCode = response.getReturnCode(); int totalLength=ReturnCodeHandler.encode(array,0,returnCode); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,totalLength,response.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; byte[] commentBytes=returnCode.getComment().getBytes(); System.arraycopy(commentBytes, 0, array,totalLength, commentBytes.length); totalLength+=commentBytes.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; if (response.getNotifiedEntity() != null) { array[totalLength++]=StringFunctions.HIGH_N_BYTE; array[totalLength++]=StringFunctions.COLON_BYTE; totalLength+=NotifiedEntityHandler.encode(array,totalLength,response.getNotifiedEntity()); array[totalLength++]=StringFunctions.NEWLINE_BYTE; } return totalLength; }