code: public int getMessageUserDataLengthOnClose(boolean prearrangedEnd) throws MAPException {
  
          if (prearrangedEnd)
              // we do not send any data in prearrangedEnd dialog termination
              return 0;
  
          try {
              switch (this.tcapDialog.getState()) {
                  case InitialReceived:
                      ApplicationContextName acn = this.mapProviderImpl.getTCAPProvider().getDialogPrimitiveFactory()
                              .createApplicationContextName(this.appCntx.getOID());
  
                      TCEndRequest te = this.mapProviderImpl.encodeTCEnd(this.getTcapDialog(), true, prearrangedEnd, acn,
                              this.extContainer);
                      return tcapDialog.getDataLength(te);
  
                  case Active:
                      te = this.mapProviderImpl.encodeTCEnd(this.getTcapDialog(), false, prearrangedEnd, null, null);
                      return tcapDialog.getDataLength(te);
              }
          } catch (TCAPSendException e) {
              throw new MAPException("TCAPSendException when getMessageUserDataLengthOnSend", e);
          }
  
          throw new MAPException("Bad TCAP Dialog state: " + this.tcapDialog.getState());
      }
docs: Return the MAP message length (in bytes) that will be after encoding if TC-END case This value must not exceed
  getMaxUserDataLength() value
  
  @param prearrangedEnd
  @return