@Override public String encode(JainMgcpCommandEvent event) { Utils utils = utilsFactory.allocate(); // encode message header AuditEndpoint evt = (AuditEndpoint) event; StringBuffer s = new StringBuffer(); s.append("AUEP ").append(evt.getTransactionHandle()).append(SINGLE_CHAR_SPACE).append( evt.getEndpointIdentifier()).append(MGCP_VERSION).append(NEW_LINE); // encode mandatory parameters InfoCode[] requestedInfos = evt.getRequestedInfo(); if (requestedInfos != null) { s.append("F: ").append(utils.encodeInfoCodeList(requestedInfos)); } utilsFactory.deallocate(utils); // return msg; return s.toString(); }
@Override public int encode(JainMgcpCommandEvent event,byte[] array) { AuditEndpoint evt = (AuditEndpoint) event; int totalLength=5; System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,evt.getEndpointIdentifier()); array[totalLength++]=StringFunctions.SPACE_BYTE; System.arraycopy(MGCP_VERSION, 0, array, totalLength, MGCP_VERSION.length); totalLength+=MGCP_VERSION.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; InfoCode[] requestedInfos = evt.getRequestedInfo(); if (requestedInfos != null) { array[totalLength++]=StringFunctions.HIGH_F_BYTE; array[totalLength++]=StringFunctions.COLON_BYTE; array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=InfoCodeHandler.encodeList(array,totalLength,requestedInfos); array[totalLength++]=StringFunctions.NEWLINE_BYTE; } return totalLength; }
@Override public int encode(JainMgcpCommandEvent event,byte[] array) { AuditEndpoint evt = (AuditEndpoint) event; int totalLength=5; System.arraycopy(COMMAND_NAME, 0, array, 0, 4); array[4]=StringFunctions.SPACE_BYTE; totalLength+=StringFunctions.encodeInt(array,5,event.getTransactionHandle()); array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=EndpointIdentifierHandler.encode(array,totalLength,evt.getEndpointIdentifier()); array[totalLength++]=StringFunctions.SPACE_BYTE; System.arraycopy(MGCP_VERSION, 0, array, totalLength, MGCP_VERSION.length); totalLength+=MGCP_VERSION.length; array[totalLength++]=StringFunctions.NEWLINE_BYTE; InfoCode[] requestedInfos = evt.getRequestedInfo(); if (requestedInfos != null) { array[totalLength++]=StringFunctions.HIGH_F_BYTE; array[totalLength++]=StringFunctions.COLON_BYTE; array[totalLength++]=StringFunctions.SPACE_BYTE; totalLength+=InfoCodeHandler.encodeList(array,totalLength,requestedInfos); array[totalLength++]=StringFunctions.NEWLINE_BYTE; } return totalLength; }