/*
(non-Javadoc)

@see org.mobicents.isup.messages.ISUPMessage#decodeOptionalBody(byte[], byte)
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);
        }

    }
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
614919
def decode_body(headers: MutableMapping, body: bytes) -> dict:
    

    type_, encoding = parse_content_type(headers)
    decoded_body = body.decode(encoding)

    # There is one api that just returns `ok` instead of json. In order to have a consistent API we decided to modify the returned payload into a dict.
    if type_ == "application/json":
        payload = json.loads(decoded_body)
    else:
        if decoded_body == "ok":
            payload = {"ok": True}
        else:
            payload = {"ok": False, "data": decoded_body}

    return payload
321867
public String getStringBody() throws UnsupportedEncodingException {
        if (mStringBody != null)
            return mStringBody;

        if (mContentType != null) {
            switch (mContentType) {
                case JSON:
                    JsonObject jsonBody = new JsonObject();
                    for (Map.Entry<String, Object> entry : mBodyMap.entrySet()) {
                        parseHashMapEntry(jsonBody, entry);
                    }
                    mStringBody = jsonBody.toString();
                    break;
                case URL_ENCODED:
                    HashMap<String, String> stringMap = new HashMap<String, String>();
                    for (Map.Entry<String, Object> entry : mBodyMap.entrySet()) {
                        stringMap.put(entry.getKey(), (String) entry.getValue());
                    }
                    mStringBody = createQuery(stringMap);
                    break;
                case JSON_PATCH:
                    mStringBody = ((BoxArray) mBodyMap.get(JSON_OBJECT)).toJson();
                    break;
            }
        }

        return mStringBody;
    }
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;
    }
23374
@Override
	public void decode(FacesContext context, UIComponent component) {
		SelectMultiMenu menu = (SelectMultiMenu) component;
		if (menu.isDisabled() || menu.isReadonly()) {
			return;
		}
		List<String> submittedValues = new ArrayList<String>();
		String clientId = menu.getClientId().replace(":", "-");
		Map<String, String> map = context.getExternalContext().getRequestParameterMap();
		for (String key : map.keySet()) {
			if (key.startsWith(clientId + ":")) {
				submittedValues.add(map.get(key));
			}
		}
		Converter converter = menu.getConverter();
		List<SelectItemAndComponent> items = SelectItemUtils.collectOptions(context, menu, converter);


		if (!submittedValues.isEmpty()) {
			// check for manipulated input
			String result = null;
			for (String submittedOptionValue : submittedValues) {
				boolean found = false;
				for (int index = 0; index < items.size(); index++) {
					Object currentOption = items.get(index).getSelectItem();
					String currentOptionValueAsString;
					Object currentOptionValue;
					if (currentOption instanceof SelectItem) {
						currentOptionValue = ((SelectItem) currentOption).getValue();
					} else {
						currentOptionValue = ((UISelectItem) currentOption).getItemValue();
					}
					if (currentOptionValue instanceof String) {
						currentOptionValueAsString = (String) currentOptionValue;
					} else if (currentOptionValue instanceof Number) {
						currentOptionValueAsString = currentOptionValue.toString();
					} else
						currentOptionValueAsString = String.valueOf(index);
					if ("".equals(currentOptionValueAsString) && submittedOptionValue.equalsIgnoreCase("on")) {
						// this is a special case which occurs when the value is
						// set to "".
						// In this case, the browser sends "on" instead of the
						// empty string.
						submittedOptionValue = "";
					}
					if (submittedOptionValue.equals(currentOptionValueAsString)) {
						if (null == result)
							result = currentOptionValueAsString;
						else
							result += "," + currentOptionValue;
						found = true;
						break;
					}
				}
				if (!found) {
					FacesMessages.error(clientId, "Invalid data",
							"Couldn't set the value of the b:selectMultiMenu because an option that wasn't defined by the JSF source code was passed.");
					menu.setSubmittedValue(result);
					menu.setValid(false);
					return;
				}
			}
			menu.setSubmittedValue(result);
			menu.setValid(true);
			new AJAXRenderer().decode(context, component, clientId);
			return;
		}

		menu.setSubmittedValue("");
		menu.setValid(true);
		new AJAXRenderer().decode(context, component, clientId);
	}
171063
byte[] decodeLikeABoss(final byte[] input) {

        if (input == null) {
            throw new NullPointerException("input");
        }

        if ((input.length & 0x01) == 0x01) {
            throw new IllegalArgumentException(
                "input.length(" + input.length + ") is not even");
        }

        final byte[] output = new byte[input.length / 2];

        int index = 0; // index in input
        for (int i = 0; i < output.length; i++) {
            final String s = new String(
                input, index, 2, StandardCharsets.US_ASCII);
            output[i] = (byte) Integer.parseInt(s, 16);
            index += 2;
        }

        return output;
    }
435223
public function decodeBody()
    {
        $this->decodedBody = json_decode($this->body, true);

        if ($this->decodedBody === null) {
            $this->decodedBody = [];
            parse_str($this->body, $this->decodedBody);
        }

        if (!is_array($this->decodedBody)) {
            $this->decodedBody = [];
        }

        if ($this->isError()) {
            $this->makeException();
        }
    }
1218333
private static RLPElement decodeRLPElement(ByteBuffer bb) {
	RLPElement result=null;
	byte firstByte = bb.get();
	int firstByteUnsigned = firstByte & 0xFF;

	if (firstByteUnsigned <= 0x7F) {
		result=new RLPElement(new byte[] {firstByte},new byte[] {firstByte});
	} else if ((firstByteUnsigned>=0x80) && (firstByteUnsigned<=0xb7)) {
		// read indicator
		byte[] indicator=new byte[]{firstByte};
		int noOfBytes = firstByteUnsigned - 0x80;
		// read raw data
		byte[] rawData = new byte[noOfBytes];
		if (noOfBytes > 0) {
			bb.get(rawData);
		}
		result=new RLPElement(indicator,rawData);
	} else if ((firstByteUnsigned>=0xb8) && (firstByteUnsigned<=0xbf)) {
		// read size of indicator (size of the size)
		int NoOfBytesSize = firstByteUnsigned-0xb7;
		byte[] indicator = new byte[NoOfBytesSize+1];
		indicator[0]=firstByte;
		bb.get(indicator, 1, NoOfBytesSize);
		long noOfBytes = convertIndicatorToRLPSize(indicator);

		// read the data
		byte[] rawData=new byte[(int) noOfBytes];
		bb.get(rawData);
		result= new RLPElement(indicator,rawData);
	} else {
		result=null;
	}
	return result;
}
13248
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.transimissionMediumUsed = b[0];

        return 1;
    }
1314682
function decode (param) {
  try {
    return decodeURIComponent(param)
  } catch (_) {
    var err = new Error('Failed to decode param "' + param + '"')
    err.status = 400
    throw err
  }
}
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);
    }
  }
21506
@Override
  public NSMessage<T> decode(final byte[] buf) {
    if (isStreamingCodec) {
      final StreamingCodec<T> streamingCodec = (StreamingCodec<T>) codec;
      try (ByteArrayInputStream bais = new ByteArrayInputStream(buf)) {
        try (DataInputStream dais = new DataInputStream(bais)) {
          final Identifier srcId = factory.getNewInstance(dais.readUTF());
          final Identifier destId = factory.getNewInstance(dais.readUTF());
          final int size = dais.readInt();
          final List<T> list = new ArrayList<>(size);
          for (int i = 0; i < size; i++) {
            list.add(streamingCodec.decodeFromStream(dais));
          }
          return new NSMessage<>(srcId, destId, list);
        }
      } catch (final IOException e) {
        throw new RuntimeException("IOException", e);
      }
    } else {
      final NSMessagePBuf pbuf;
      try {
        pbuf = NSMessagePBuf.parseFrom(buf);
      } catch (final InvalidProtocolBufferException e) {
        e.printStackTrace();
        throw new NetworkRuntimeException(e);
      }
      final List<T> list = new ArrayList<>();
      for (final NSRecordPBuf rbuf : pbuf.getMsgsList()) {
        list.add(codec.decode(rbuf.getData().toByteArray()));
      }
      return new NSMessage<>(factory.getNewInstance(pbuf.getSrcid()), factory.getNewInstance(pbuf.getDestid()), list);
    }
  }
1005858
function bodyParser(options) {
    assert.optionalObject(options, 'options');
    var opts = options || {};
    opts.bodyReader = true;

    var read = bodyReader(opts);
    var parseForm = formParser(opts);
    var parseJson = jsonParser(opts);
    var parseMultipart = multipartParser(opts);
    var parseFieldedText = fieldedTextParser(opts);

    function parseBody(req, res, next) {
        // #100 don't parse the body again if we've read it once
        if (req._parsedBody) {
            next();
            return;
        } else {
            req._parsedBody = true;
        }
        // Allow use of 'requestBodyOnGet' flag to allow for merging of
        // the request body of a GET request into req.params
        if (req.method === 'HEAD') {
            next();
            return;
        }

        if (req.method === 'GET') {
            if (!opts.requestBodyOnGet) {
                next();
                return;
            }
        }

        if (req.contentLength() === 0 && !req.isChunked()) {
            next();
            return;
        }

        var parser;
        var type = req.contentType().toLowerCase();

        switch (type) {
            case 'application/json':
                parser = parseJson[0];
                break;
            case 'application/x-www-form-urlencoded':
                parser = parseForm[0];
                break;
            case 'multipart/form-data':
                parser = parseMultipart;
                break;
            case 'text/tsv':
                parser = parseFieldedText;
                break;
            case 'text/tab-separated-values':
                parser = parseFieldedText;
                break;
            case 'text/csv':
                parser = parseFieldedText;
                break;

            default:
                break;
        }

        if (parser) {
            parser(req, res, next);
        } else if (opts && opts.rejectUnknown) {
            next(new UnsupportedMediaTypeError(type));
        } else {
            next();
        }
    }

    return ([read, parseBody]);
}
202246
private void encodeBytesBody(StringBuffer result, JsJmsBytesMessage msg) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "encodeBytesBody");
    byte[] body = msg.getBytes();
    if (body != null) {
      result.append('~');
      HexString.binToHex(body, 0, body.length, result);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "encodeBytesBody");
  }
229817
@SuppressWarnings("StatementWithEmptyBody")
    public static byte[] decode(final String input) {
        ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes());
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            while (decodeChunk(out, in)) {
                // do nothing
            }
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }

        return out.toByteArray();
    }
1248036
private static Map decodeComponent(String component) {
        byte[] bodyData = Base64.decode(component, Base64.DEFAULT);
        if (bodyData == null)
            return null;
        try {
            return Manager.getObjectMapper().readValue(bodyData, Map.class);
        } catch (IOException e) {
            Log.w(TAG, "Failed decode component: %s", e, component);
            return null;
        }
    }