/*
(non-Javadoc)

@see org.restcomm.protocols.ss7.isup.ISUPMessageImpl#decodeOptionalBody(byte [], byte)
769568
protected void decodeOptionalBody(ISUPParameterFactory parameterFactory, byte[] parameterBody, byte parameterCode)
            throws ParameterException {
        switch (parameterCode & 0xFF) {
            case OptionalBackwardCallIndicators._PARAMETER_CODE:
                OptionalBackwardCallIndicators optionalBackwardCallIndicators = parameterFactory
                        .createOptionalBackwardCallIndicators();
                ((AbstractISUPParameter) optionalBackwardCallIndicators).decode(parameterBody);
                this.setOptionalBackwardCallIndicators(optionalBackwardCallIndicators);
                break;
            case BackwardGVNS._PARAMETER_CODE:
                BackwardGVNS backwardGVNS = new BackwardGVNSImpl(parameterBody);
                parameterFactory.createBackwardGVNS();
                ((AbstractISUPParameter) backwardGVNS).decode(parameterBody);
                this.setBackwardGVNS(backwardGVNS);
                break;
            case ConnectedNumber._PARAMETER_CODE:
                ConnectedNumber connectedNumber = parameterFactory.createConnectedNumber();
                ((AbstractISUPParameter) connectedNumber).decode(parameterBody);
                this.setConnectedNumber(connectedNumber);
                break;
            case CallReference._PARAMETER_CODE:
                CallReference callReference = parameterFactory.createCallReference();
                ((AbstractISUPParameter) callReference).decode(parameterBody);
                this.setCallReference(callReference);
                break;
            case UserToUserIndicators._PARAMETER_CODE:
                UserToUserIndicators userToUserIndicators = parameterFactory.createUserToUserIndicators();
                ((AbstractISUPParameter) userToUserIndicators).decode(parameterBody);
                this.setUserToUserIndicators(userToUserIndicators);
                break;
            case UserToUserInformation._PARAMETER_CODE:
                UserToUserInformation userToUserInformation = parameterFactory.createUserToUserInformation();
                ((AbstractISUPParameter) userToUserInformation).decode(parameterBody);
                this.setUserToUserInformation(userToUserInformation);
                break;
            case AccessTransport._PARAMETER_CODE:
                AccessTransport accessTransport = parameterFactory.createAccessTransport();
                ((AbstractISUPParameter) accessTransport).decode(parameterBody);
                this.setAccessTransport(accessTransport);
                break;
            case NetworkSpecificFacility._PARAMETER_CODE:
                NetworkSpecificFacility networkSpecificFacility = parameterFactory.createNetworkSpecificFacility();
                ((AbstractISUPParameter) networkSpecificFacility).decode(parameterBody);
                this.setNetworkSpecificFacility(networkSpecificFacility);
                break;
            case GenericNotificationIndicator._PARAMETER_CODE:
                GenericNotificationIndicator genericNotificationIndicator = parameterFactory
                        .createGenericNotificationIndicator();
                ((AbstractISUPParameter) genericNotificationIndicator).decode(parameterBody);
                this.setGenericNotificationIndicator(genericNotificationIndicator);
                break;
            case RemoteOperations._PARAMETER_CODE:
                RemoteOperations remoteOperations = parameterFactory.createRemoteOperations();
                ((AbstractISUPParameter) remoteOperations).decode(parameterBody);
                this.setRemoteOperations(remoteOperations);
                break;
            case TransmissionMediumUsed._PARAMETER_CODE:
                TransmissionMediumUsed transmissionMediumUsed = parameterFactory.createTransmissionMediumUsed();
                ((AbstractISUPParameter) transmissionMediumUsed).decode(parameterBody);
                this.setTransmissionMediumUsed(transmissionMediumUsed);
                break;
            case EchoControlInformation._PARAMETER_CODE:
                EchoControlInformation echoControlInformation = parameterFactory.createEchoControlInformation();
                ((AbstractISUPParameter) echoControlInformation).decode(parameterBody);
                this.setEchoControlInformation(echoControlInformation);
                break;
            case AccessDeliveryInformation._PARAMETER_CODE:
                AccessDeliveryInformation accessDeliveryInformation = parameterFactory.createAccessDeliveryInformation();
                ((AbstractISUPParameter) accessDeliveryInformation).decode(parameterBody);
                this.setAccessDeliveryInformation(accessDeliveryInformation);
                break;
            case CallHistoryInformation._PARAMETER_CODE:
                CallHistoryInformation callHistoryInformation = parameterFactory.createCallHistoryInformation();
                ((AbstractISUPParameter) callHistoryInformation).decode(parameterBody);
                this.setCallHistoryInformation(callHistoryInformation);
                break;
            case ParameterCompatibilityInformation._PARAMETER_CODE:
                ParameterCompatibilityInformation parameterCompatibilityInformation = parameterFactory
                        .createParameterCompatibilityInformation();
                ((AbstractISUPParameter) parameterCompatibilityInformation).decode(parameterBody);
                this.setParameterCompatibilityInformation(parameterCompatibilityInformation);
                break;
            case ServiceActivation._PARAMETER_CODE:
                ServiceActivation serviceActivation = parameterFactory.createServiceActivation();
                ((AbstractISUPParameter) serviceActivation).decode(parameterBody);
                this.setServiceActivation(serviceActivation);
                break;
            case GenericNumber._PARAMETER_CODE:
                GenericNumber genericNumber = parameterFactory.createGenericNumber();
                ((AbstractISUPParameter) genericNumber).decode(parameterBody);
                this.setGenericNumber(genericNumber);
                break;
            case RedirectionNumberRestriction._PARAMETER_CODE:
                RedirectionNumberRestriction redirectionNumberRestriction = parameterFactory
                        .createRedirectionNumberRestriction();
                ((AbstractISUPParameter) redirectionNumberRestriction).decode(parameterBody);
                this.setRedirectionNumberRestriction(redirectionNumberRestriction);
                break;
            case ConferenceTreatmentIndicators._PARAMETER_CODE:
                ConferenceTreatmentIndicators conferenceTreatmentIndicators = parameterFactory
                        .createConferenceTreatmentIndicators();
                ((AbstractISUPParameter) conferenceTreatmentIndicators).decode(parameterBody);
                this.setConferenceTreatmentIndicators(conferenceTreatmentIndicators);
                break;
            case ApplicationTransport._PARAMETER_CODE:
                ApplicationTransport applicationTransportParameter = parameterFactory
                        .createApplicationTransport();
                ((AbstractISUPParameter) applicationTransportParameter).decode(parameterBody);
                this.setApplicationTransportParameter(applicationTransportParameter);
                break;
            case HTRInformation._PARAMETER_CODE:
                HTRInformation htrInformation = parameterFactory.createHTRInformation();
                ((AbstractISUPParameter) htrInformation).decode(parameterBody);
                this.setHTRInformation(htrInformation);
                break;
            case PivotRoutingBackwardInformation._PARAMETER_CODE:
                PivotRoutingBackwardInformation pivotRoutingBackwardInformation = parameterFactory
                        .createPivotRoutingBackwardInformation();
                ((AbstractISUPParameter) pivotRoutingBackwardInformation).decode(parameterBody);
                this.setPivotRoutingBackwardInformation(pivotRoutingBackwardInformation);
                break;
            case RedirectStatus._PARAMETER_CODE:
                RedirectStatus redirectStatus = parameterFactory.createRedirectStatus();
                ((AbstractISUPParameter) redirectStatus).decode(parameterBody);
                this.setRedirectStatus(redirectStatus);
                break;
            default:
                throw new ParameterException("Unrecognized parameter code for optional part: " + parameterCode);
        }
    }
1216043
public static boolean decodeBooleanDesc(byte[] src, int srcOffset)
        throws CorruptEncodingException
    {
        try {
            return src[srcOffset] == 127;
        } catch (IndexOutOfBoundsException e) {
            throw new CorruptEncodingException(null, e);
        }
    }
1017093
private function decodeBody(): void
    {
        if (empty($this->body) || $this->body === null) {
            $this->decodedBody = [];

            return;
        }

        $this->decodedBody = json_decode($this->body, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new JsonException('The body of the response could not be decoded as JSON.');
        }

        if (!\is_array($this->decodedBody)) {
            $this->decodedBody = [];
        }
    }
436394
protected void decodeOptionalBody(ISUPParameterFactory parameterFactory, byte[] parameterBody, byte parameterCode)
            throws ParameterException {

        switch (parameterCode & 0xFF) {
            case RedirectionNumber._PARAMETER_CODE:
                RedirectionNumber rn = parameterFactory.createRedirectionNumber();
                ((AbstractISUPParameter) rn).decode(parameterBody);
                this.setRedirectionNumber(rn);
                break;
            case RedirectionInformation._PARAMETER_CODE:
                RedirectionInformation ri = parameterFactory.createRedirectionInformation();
                ((AbstractISUPParameter) ri).decode(parameterBody);
                this.setRedirectionInformation(ri);
                break;
            case AccessTransport._PARAMETER_CODE:
                AccessTransport at = parameterFactory.createAccessTransport();
                ((AbstractISUPParameter) at).decode(parameterBody);
                this.setAccessTransport(at);
                break;
            case SignalingPointCode._PARAMETER_CODE:
                SignalingPointCode v = parameterFactory.createSignalingPointCode();
                ((AbstractISUPParameter) v).decode(parameterBody);
                this.setSignalingPointCode(v);
                break;
            case UserToUserInformation._PARAMETER_CODE:
                UserToUserInformation u2ui = parameterFactory.createUserToUserInformation();
                ((AbstractISUPParameter) u2ui).decode(parameterBody);
                this.setU2UInformation(u2ui);
                break;
            case AutomaticCongestionLevel._PARAMETER_CODE:
                AutomaticCongestionLevel acl = parameterFactory.createAutomaticCongestionLevel();
                ((AbstractISUPParameter) acl).decode(parameterBody);
                this.setAutomaticCongestionLevel(acl);
                break;
            case NetworkSpecificFacility._PARAMETER_CODE:
                NetworkSpecificFacility nsf = parameterFactory.createNetworkSpecificFacility();
                ((AbstractISUPParameter) nsf).decode(parameterBody);
                this.setNetworkSpecificFacility(nsf);
                break;
            case AccessDeliveryInformation._PARAMETER_CODE:
                AccessDeliveryInformation adi = parameterFactory.createAccessDeliveryInformation();
                ((AbstractISUPParameter) adi).decode(parameterBody);
                this.setAccessDeliveryInformation(adi);
                break;
            case ParameterCompatibilityInformation._PARAMETER_CODE:
                ParameterCompatibilityInformation pci = parameterFactory.createParameterCompatibilityInformation();
                ((AbstractISUPParameter) pci).decode(parameterBody);
                this.setParameterCompatibilityInformation(pci);
                break;
            case UserToUserIndicators._PARAMETER_CODE:
                UserToUserIndicators utui = parameterFactory.createUserToUserIndicators();
                ((AbstractISUPParameter) utui).decode(parameterBody);
                this.setU2UIndicators(utui);
                break;
            case DisplayInformation._PARAMETER_CODE:
                DisplayInformation di = parameterFactory.createDisplayInformation();
                ((AbstractISUPParameter) di).decode(parameterBody);
                this.setDisplayInformation(di);
                break;
            case RemoteOperations._PARAMETER_CODE:
                RemoteOperations ro = parameterFactory.createRemoteOperations();
                ((AbstractISUPParameter) ro).decode(parameterBody);
                this.setRemoteOperations(ro);
                break;
            case HTRInformation._PARAMETER_CODE:
                HTRInformation htri = parameterFactory.createHTRInformation();
                ((AbstractISUPParameter) htri).decode(parameterBody);
                this.setHTRInformation(htri);
                break;
            case RedirectBackwardInformation._PARAMETER_CODE:
                RedirectBackwardInformation rbi = parameterFactory.createRedirectBackwardInformation();
                ((AbstractISUPParameter) rbi).decode(parameterBody);
                this.setRedirectBackwardInformation(rbi);
                break;
            case RedirectCounter._PARAMETER_CODE:
                RedirectCounter rc = parameterFactory.createRedirectCounter();
                ((AbstractISUPParameter) rc).decode(parameterBody);
                this.setRedirectCounter(rc);
                break;

            default:
                throw new ParameterException("Unrecognized parameter code for optional part: " + parameterCode);
        }

    }
1050149
public static void decodeUISelectOne(FacesContext facesContext, UIComponent component)
    {
        if (!(component instanceof EditableValueHolder))
        {
            throw new IllegalArgumentException("Component "
                    + component.getClientId(facesContext)
                    + " is not an EditableValueHolder");
        }
        if (isDisabledOrReadOnly(component))
        {
            return;
        }
        Map paramMap = facesContext.getExternalContext().getRequestParameterMap();
        String clientId = component.getClientId(facesContext);
        if (paramMap.containsKey(clientId))
        {
            //request parameter found, set submitted value
            ((EditableValueHolder) component).setSubmittedValue(paramMap.get(clientId));
        }
        else
        {
            //see reason for this action at decodeUISelectMany
            ((EditableValueHolder) component).setSubmittedValue(STR_EMPTY);
        }
    }
1070194
public int decode(byte[] b) throws ParameterException {
        if (b == null || b.length != 1) {
            throw new ParameterException("byte[] must  not be null and length must  be 1");
        }

        this.transimissionMediumRequirement = b[0];

        return 1;
    }
398305
public static Optional<String> readOptString(ByteBuf bf) {
      Optional<byte[]> bytes = readOptRangedBytes(bf);
      return bytes.map(b -> new String(b, CharsetUtil.UTF_8));
   }
697027
public static Boolean decodeBooleanObj(byte[] src, int srcOffset)
        throws CorruptEncodingException
    {
        try {
            switch (src[srcOffset]) {
            case NULL_BYTE_LOW: case NULL_BYTE_HIGH:
                return null;
            case (byte)128:
                return Boolean.TRUE;
            default:
                return Boolean.FALSE;
            }
        } catch (IndexOutOfBoundsException e) {
            throw new CorruptEncodingException(null, e);
        }
    }
349850
@Override
    public int decode ( byte[] buffer, int bufferIndex ) throws SMBProtocolDecodingException {
        int start = this.headerStart = bufferIndex;

        bufferIndex += readHeaderWireFormat(buffer, bufferIndex);
        bufferIndex += readAndXWireFormat(buffer, bufferIndex);

        int len = bufferIndex - start;
        this.length = len;

        if ( isRetainPayload() ) {
            byte[] payload = new byte[len];
            System.arraycopy(buffer, 4, payload, 0, len);
            setRawPayload(payload);
        }

        if ( !verifySignature(buffer, 4, len) ) {
            throw new SMBProtocolDecodingException("Signature verification failed for " + this.getClass().getName());
        }
        return len;
    }
813836
@Override
  public NetworkConnectionServiceMessage decode(final byte[] data) {
    try (final ByteArrayInputStream bais = new ByteArrayInputStream(data)) {
      try (final DataInputStream dais = new DataInputStream(bais)) {
        final String connFactoryId = dais.readUTF();
        final Identifier srcId = factory.getNewInstance(dais.readUTF());
        final Identifier destId = factory.getNewInstance(dais.readUTF());
        final int size = dais.readInt();
        final List list = new ArrayList(size);
        final Codec codec = connFactoryMap.get(connFactoryId).getCodec();
        Boolean isStreamingCodec = isStreamingCodecMap.get(codec);
        if (isStreamingCodec == null) {
          isStreamingCodec = codec instanceof StreamingCodec;
          isStreamingCodecMap.putIfAbsent(codec, isStreamingCodec);
        }

        if (isStreamingCodec) {
          for (int i = 0; i < size; i++) {
            list.add(((StreamingCodec) codec).decodeFromStream(dais));
          }
        } else {
          for (int i = 0; i < size; i++) {
            final int byteSize = dais.readInt();
            final byte[] bytes = new byte[byteSize];
            if (dais.read(bytes) == -1) {
              LOG.log(Level.FINE, "No data read because end of stream was reached");
            }
            list.add(codec.decode(bytes));
          }
        }

        return new NetworkConnectionServiceMessage(
            connFactoryId,
            srcId,
            destId,
            list
        );
      }
    } catch (final IOException e) {
      throw new RuntimeException("IOException", e);
    }
  }
1130210
private static JsJmsMessage decodeStreamBody(String body) throws MessageDecodeFailedException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "decodeStreamBody");
        JsJmsStreamMessage result = new JsJmsStreamMessageImpl(MfpConstants.CONSTRUCTOR_NO_OP);
        if (body != null) {
            try {
                StringTokenizer st = new StringTokenizer(body, "&");
                while (st.hasMoreTokens())
                    result.writeObject(decodeObject(st.nextToken()));
            } catch (UnsupportedEncodingException e) {
                FFDCFilter.processException(e, "com.ibm.ws.sib.mfp.impl.WebJsJmsMessageFactoryImpl.decodeStreamBody", "196");
                // This can't happen, as the Exception can only be thrown for an MQ message
                // which isn't what we have.
            }
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "decodeStreamBody");
        return result;
    }
1224972
@Internal
    public void setBody(T body) {
        this.body = () -> Optional.ofNullable(body);
        this.convertedBodies.clear();
    }
1236489
def decode_body(body, content_type):
        """"""

        if isinstance(body, dict):
            return body
        else:
            try:
                decoded_body = base64.b64decode(body)
            except:
                return body

            if content_type == 'application/json':
                try:
                    return json.loads(decoded_body)
                except:
                    pass

            return decoded_body
118475
public static function decodeChunkedBody($body)
    {
        $decBody = '';
        
        while (trim($body)) {
            if (! preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m)) {
                require_once 'Zend/Http/Exception.php';
                throw new Zend_Http_Exception("Error parsing body - doesn't seem to be a chunked message");
            }

            $length = hexdec(trim($m[1]));
            $cut = strlen($m[0]);

            $decBody .= substr($body, $cut, $length);
            $body = substr($body, $cut + $length + 2);
        }

        return $decBody;
    }
829038
def _decode_body(content_type: Optional[str], body: bytes,
                 *, strict: bool = False) -> Any:
    
    type_, encoding = _parse_content_type(content_type)
    if not len(body) or not content_type:
        return None
    decoded_body = body.decode(encoding)
    if type_ == "application/json":
        return json.loads(decoded_body)
    elif type_ == "application/x-www-form-urlencoded":
        return json.loads(urllib.parse.parse_qs(decoded_body)["payload"][0])
    elif strict:
        raise ValueError(f"unrecognized content type: {type_!r}")
    return decoded_body
1151891
protected void encodeOptionalParameters(Map<Integer, ISUPParameter> parameters, ByteArrayOutputStream bos)
            throws ParameterException {

        // NOTE: parameters MUST have as last endOfOptionalParametersParameter+1
        // param
        for (ISUPParameter p : parameters.values()) {

            if (p == null)
                continue;

            byte[] b = ((AbstractISUPParameter) p).encode();
            // System.err.println("ENCODE O: "+p.getCode()+"---> "+Utils.toHex(b));
            // FIXME: this can be slow, maybe we shoudl remove that, and code
            // this explicitly?
            if (b.length > 255) {
                throw new ParameterException("Parameter length is over 255: " + p);
            }
            if (!(p instanceof EndOfOptionalParametersImpl)) {
                bos.write(p.getCode());

                bos.write(b.length);
            }
            try {
                bos.write(b);
            } catch (IOException e) {
                throw new ParameterException("Failed to encode optional parameters.", e);
            }
        }

    }
427593
Object decodeProperty(MsgDestEncodingUtilsImpl.PropertyInputStream stream) throws JMSException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "decodeProperty", stream);

    Object value = super.decodeProperty(stream);
    if (SHORT_ON.equals(value)) {
      value = ApiJmsConstants.ON;
    }
    else {
      value = ApiJmsConstants.OFF;
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "decodeProperty", value);
    return value;
  }