Parses an object identifier except for the first octet, which is parsed
differently. This way relative object identifiers can also be parsed
using this.

@param $binaryData
@param $offsetIndex
@param $octetsToRead

@throws ParserException

@return string
969533
protected static function parseOid(&$binaryData, &$offsetIndex, $octetsToRead)
    {
        $oid = '';

        while ($octetsToRead > 0) {
            $octets = '';

            do {
                if (0 === $octetsToRead) {
                    throw new ParserException('Malformed ASN.1 Object Identifier', $offsetIndex - 1);
                }

                $octetsToRead--;
                $octet = $binaryData[$offsetIndex++];
                $octets .= $octet;
            } while (ord($octet) & 0x80);

            $oid .= sprintf('%d.', Base128::decode($octets));
        }

        // Remove trailing '.'
        return substr($oid, 0, -1) ?: '';
    }
698708
protected final int readBytesAt(int offset)
        throws IOException
    {
        // shouldn't modify mBytePtr, assumed to be 'offset'
        if (mIn != null) {
            int count = mIn.read(mByteBuffer, offset, mByteBuffer.length - offset);
            if (count > 0) {
                mByteBufferEnd += count;
            }
            return count;
        }
        return -1;
    }
932936
public String binaryToString(Object objData) 
    {
        initGlobals();
        if (objData == null)
            return Constants.BLANK;
        String strReturn = null;
        synchronized (gIntegerFormat)
        {
            strReturn = gIntegerFormat.format(((Short)objData).shortValue());
        }
        return strReturn;
    }
1294237
private function encodeNonUtf8ToUtf8(array $serializedData)
    {
        $encodedKeys = [];
        $encodedData = [];
        foreach ($serializedData as $key => $value) {
            if (is_array($value)) {
                $value = $this->encodeNonUtf8ToUtf8($value);
            }

            if (!mb_check_encoding($key, 'UTF-8')) {
                $key = mb_convert_encoding($key, 'UTF-8', '8bit');
                $encodedKeys[$key] = (isset($encodedKeys[$key]) ? $encodedKeys[$key] : 0) | static::KEY_UTF8ENCODED;
            }

            if (is_string($value)) {
                if (!mb_check_encoding($value, 'UTF-8')) {
                    $value = mb_convert_encoding($value, 'UTF-8', '8bit');
                    $encodedKeys[$key] = (isset($encodedKeys[$key]) ? $encodedKeys[$key] : 0) | static::VALUE_UTF8ENCODED;
                }
            }

            $encodedData[$key] = $value;
        }

        if (!empty($encodedKeys)) {
            $encodedData[$this->encodingAnnotation] = $encodedKeys;
        }

        return $encodedData;
    }
113417
private function readByteStringShort($subData)
    {
        // offset: 0; size: 1; length of the string (character count)
        $ln = ord($subData[0]);

        // offset: 1: size: var; character array (8-bit characters)
        $value = $this->decodeCodepage(substr($subData, 1, $ln));

        return array(
            'value' => $value,
            'size' => 1 + $ln, // size in bytes of data structure
        );
    }
230204
private static int parseNumber(CharSequence offsetId, int pos, boolean precededByColon) {
        if (precededByColon && offsetId.charAt(pos - 1) != ':') {
            throw new DateTimeException("Invalid ID for ZoneOffset, colon not found when expected: " + offsetId);
        }
        char ch1 = offsetId.charAt(pos);
        char ch2 = offsetId.charAt(pos + 1);
        if (ch1 < '0' || ch1 > '9' || ch2 < '0' || ch2 > '9') {
            throw new DateTimeException("Invalid ID for ZoneOffset, non numeric characters found: " + offsetId);
        }
        return (ch1 - 48) * 10 + (ch2 - 48);
    }
1373101
public function parseKeys($data, $offset)
    {
        $element   = \preg_quote($this->getIndex()->getElement());
        $attribute = \preg_quote($this->getIndex()->getAttribute());
        $pregExp = '/<' . $element . '\s([^>]*\s)?'
            . $attribute . '\s*=\s*([\'"])(.+?)\2[^>]*>/si';

        \preg_match_all(
            $pregExp,
            $data,
            $matches,
            PREG_OFFSET_CAPTURE | PREG_SET_ORDER
        );

        $keys = array();

        foreach ($matches as $match) {
            $keys[] = new FoundKey($match[0][1], $match[3][0]);

        }

        return $keys;
    }
1232669
@Override
    public boolean parseBinaryFirstLine(WsByteBuffer buff) throws MalformedMessageException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "parseBinaryFirstLine for " + this);
            Tr.debug(tc, "Buffer: " + buff);
        }
        if (getBinaryParseState() == HttpInternalConstants.PARSING_BINARY_VERSION) {
            if (!buff.hasRemaining()) {
                return false;
            }
            byte version = buff.get();
            if (version != HttpInternalConstants.BINARY_TRANSPORT_V1) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Unsupported binary version in message: " + version);
                }
                throw new MalformedMessageException("Invalid binary message");
            }
            setBinaryParseState(HttpInternalConstants.PARSING_METHOD_ID_OR_LEN);
            resetCacheToken(4);
        }

        boolean complete = false;
        int value;
        while (!complete) {
            // at this point, the parsed token array is always set up, so we
            // can try to fill it now
            if (!fillCacheToken(buff)) {
                return false;
            }
            switch (getBinaryParseState()) {
                case HttpInternalConstants.PARSING_METHOD_ID_OR_LEN:
                    value = GenericUtils.asInt(getParsedToken());
                    if (0 == (value & GenericConstants.KNOWN_MASK)) {
                        setMethod(MethodValues.getByOrdinal(value));
                        setBinaryParseState(HttpInternalConstants.PARSING_URI_LEN);
                        resetCacheToken(4);
                    } else {
                        setBinaryParseState(HttpInternalConstants.PARSING_UNKNOWN_METHOD);
                        resetCacheToken(value & GenericConstants.UNKNOWN_MASK);
                    }
                    break;
                case HttpInternalConstants.PARSING_UNKNOWN_METHOD:
                    setMethod(MethodValues.find(getParsedToken()));
                    setBinaryParseState(HttpInternalConstants.PARSING_URI_LEN);
                    createCacheToken(4);
                    break;

                case HttpInternalConstants.PARSING_URI_LEN:
                    setBinaryParseState(HttpInternalConstants.PARSING_URI);
                    resetCacheToken(GenericUtils.asInt(getParsedToken()));
                    break;

                case HttpInternalConstants.PARSING_URI:
                    setRequestURL(getParsedToken());
                    setBinaryParseState(HttpInternalConstants.PARSING_VERSION_ID_OR_LEN);
                    createCacheToken(4);
                    break;

                case HttpInternalConstants.PARSING_VERSION_ID_OR_LEN:
                    value = GenericUtils.asInt(getParsedToken());
                    if (0 == (value & GenericConstants.KNOWN_MASK)) {
                        setVersion(VersionValues.getByOrdinal(value));
                        setBinaryParseState(GenericConstants.PARSING_HDR_FLAG);
                        resetCacheToken(4);
                        complete = true;
                    } else {
                        setBinaryParseState(HttpInternalConstants.PARSING_UNKNOWN_VERSION);
                        resetCacheToken(value & GenericConstants.UNKNOWN_MASK);
                    }
                    break;

                case HttpInternalConstants.PARSING_UNKNOWN_VERSION:
                    setVersion(VersionValues.find(getParsedToken()));
                    setBinaryParseState(GenericConstants.PARSING_HDR_FLAG);
                    createCacheToken(4);
                    complete = true;
                    break;

                default:
                    throw new MalformedMessageException("Invalid state in first line: " + getBinaryParseState());
            } // end of switch block

        } // end of while loop

        setFirstLineComplete(true);
        return true;
    }
79402
public function usesBinaryData()
    {
        $isBinary = false;
        if ($this->getInnerIterator() instanceof UsesBinaryDataInterface) {
            $isBinary = $this->getInnerIterator()->usesBinaryData();
        }
        return $isBinary;
    }
446432
private function _parseName(int &$offset): array
    {
        $idx = $offset;
        $names = array();
        while ($idx < $this->_len) {
            $names[] = $this->_parseNameComponent($idx);
            if ($idx >= $this->_len) {
                break;
            }
            $this->_skipWs($idx);
            if ("," != $this->_dn[$idx] && ";" != $this->_dn[$idx]) {
                break;
            }
            $idx++;
            $this->_skipWs($idx);
        }
        $offset = $idx;
        return array_reverse($names);
    }
1271609
public function getIndexName($indexIdentifier, $storeId, $date)
    {
        $indexAlias = $this->getIndexAlias($indexIdentifier, $storeId);
        $date       = substr($date, 0, 10);

        return sprintf("%s_%s", $indexAlias, str_replace("-", "", $date));
    }
427434
private function _readByteStringShort($subData)
	{
		// offset: 0; size: 1; length of the string (character count)
		$ln = ord($subData[0]);

		// offset: 1: size: var; character array (8-bit characters)
		$value = $this->_decodeCodepage(substr($subData, 1, $ln));

		return array(
			'value' => $value,
			'size' => 1 + $ln, // size in bytes of data structure
		);
	}
800507
private function parseConnectionData(\stdClass $initData)
    {
        $return = new \stdClass;
        $return->host = isset($initData->host) ? $initData->host : self::DEFAULT_HOST;
        $return->port = isset($initData->port) ? $initData->port : null;
        $return->timeout = isset($initData->timeoutInSeconds) ? $initData->timeoutInSeconds : null;

        return $return;
    }
826644
private function decode($encData)
    {
        $params = explode(self::ENC_SEPARATOR, $encData);
        if (count($params) < self::ENC_SECTIONS) {
            return false;
        }

        $startIndex = intval(base64_decode($params[self::ENC_STARTINDEX_INDEX]));
        $dataLength = intval(base64_decode($params[self::ENC_DATALENGTH_INDEX]));

        if (empty($startIndex) || empty($dataLength)) {
            return false;
        }

        $data = $params[self::ENC_DATA_INDEX];

        return base64_decode(substr($data, $startIndex, $dataLength));
    }
1031479
public function parseEncodedBinary(&$s, &$p)
    {
        $f = ord(mb_orig_substr($s, $p, 1));
        ++$p;

        if ($f <= 250) {
            return $f;
        }

        if ($s === 251) {
            return null;
        }

        if ($s === 255) {
            return false;
        }

        if ($f === 252) {
            $o = $p;
            $p += 2;

            return $this->bytes2int(mb_orig_substr($s, $o, 2));
        }

        if ($f === 253) {
            $o = $p;
            $p += 3;

            return $this->bytes2int(mb_orig_substr($s, $o, 3));
        }

        $o = $p;
        $p = +8;

        return $this->bytes2int(mb_orig_substr($s, $o, 8));
    }
1085670
public static function parseLabels(&$data, $orig = null)
    {
        $str = '';
        while (mb_orig_strlen($data) > 0) {
            $l = ord($data[0]);

            if ($l >= 192) {
                $pos = Binary::bytes2int(chr($l - 192) . mb_orig_substr($data, 1, 1));
                $data = mb_orig_substr($data, 2);
                $ref = mb_orig_substr($orig, $pos);
                return $str . Binary::parseLabels($ref, $orig);
            }

            $p = mb_orig_substr($data, 1, $l);
            $str .= $p . (($l !== 0) ? '.' : '');
            $data = mb_orig_substr($data, $l + 1);
            if ($l === 0) {
                break;
            }
        }
        return $str;
    }
598843
@Override
    public boolean parseBinaryFirstLine(WsByteBuffer buff) throws MalformedMessageException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "parseBinaryFirstLine for " + this);
            Tr.debug(tc, "Buffer: " + buff);
        }
        // check the version first if we need to
        if (getBinaryParseState() == HttpInternalConstants.PARSING_BINARY_VERSION) {
            if (!buff.hasRemaining()) {
                return false;
            }
            byte version = buff.get();
            if (version != HttpInternalConstants.BINARY_TRANSPORT_V1) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Unsupported binary version in message: " + version);
                }
                throw new MalformedMessageException("Invalid binary message");
            }
            setBinaryParseState(HttpInternalConstants.PARSING_VERSION_ID_OR_LEN);
            resetCacheToken(4);
        }

        // stop parsing the FirstLine when we have parsed the status or the
        // reason header or we hit the end of the buffer and need to read more
        boolean lineEnds = false;
        int value;
        while (!lineEnds) {
            // at this point, the parsed token array is always set up, so we
            // can try to fill it now
            if (!fillCacheToken(buff)) {
                return false;
            }
            switch (getBinaryParseState()) {
                case HttpInternalConstants.PARSING_VERSION_ID_OR_LEN:
                    value = GenericUtils.asInt(getParsedToken());
                    if (0 == (value & GenericConstants.KNOWN_MASK)) {
                        // known version ordinal
                        setVersion(VersionValues.getByOrdinal(value));
                        setBinaryParseState(HttpInternalConstants.PARSING_STATUS);
                        resetCacheToken(4);
                    } else {
                        // unknown version length
                        setBinaryParseState(HttpInternalConstants.PARSING_UNKNOWN_VERSION);
                        resetCacheToken(value & GenericConstants.UNKNOWN_MASK);
                    }
                    break;

                case HttpInternalConstants.PARSING_UNKNOWN_VERSION:
                    setVersion(VersionValues.find(getParsedToken()));
                    setBinaryParseState(HttpInternalConstants.PARSING_STATUS);
                    createCacheToken(4);
                    break;

                case HttpInternalConstants.PARSING_STATUS:
                    setStatusCode(GenericUtils.asInt(getParsedToken()));
                    setBinaryParseState(HttpInternalConstants.PARSING_REASON_LEN);
                    resetCacheToken(4);
                    break;

                case HttpInternalConstants.PARSING_REASON_LEN:
                    value = GenericUtils.asInt(getParsedToken());
                    if (0 == value) {
                        // end of first line response headers
                        setBinaryParseState(GenericConstants.PARSING_HDR_FLAG);
                        resetCacheToken(4);
                        lineEnds = true;
                    } else {
                        setBinaryParseState(HttpInternalConstants.PARSING_REASON);
                        resetCacheToken(value);
                    }
                    break;

                case HttpInternalConstants.PARSING_REASON:
                    setReasonPhrase(getParsedToken());
                    setBinaryParseState(GenericConstants.PARSING_HDR_FLAG);
                    createCacheToken(4);
                    lineEnds = true;
                    break;

                default:
                    throw new MalformedMessageException("Invalid state in line: " + getBinaryParseState());
            } // end of switch

        } // end of while loop

        setFirstLineComplete(true);
        return true;
    }