{@literal '[$-403]'}などのロケールの条件を組み立てる
@param formatter 現在の組み立て中のフォーマッタのインスタンス。
@param token 条件式のトークン。
@return ロケールの条件式。
@throws IllegalArgumentException 処理対象の条件として一致しない場合
779027
protected MSLocale setupConditionLocale(final ConditionFormatter formatter, final Token.Condition token) {

        final Matcher matcher = PATTERN_CONDITION_LOCALE.matcher(token.getValue());
        if(!matcher.matches()) {
            throw new IllegalArgumentException("not match condition:" + token.getValue());
        }

        final String number = matcher.group(1);

        // 16進数=>10進数に直す
        final int value = Integer.valueOf(number, 16);
        MSLocale locale = MSLocale.createKnownLocale(value);
        if(locale == null) {
            locale = new MSLocale(value);
        }

        formatter.setLocale(locale);

        return locale;

    }
1174044
function formatReportedHTMLToken(token) {
            const valueLines = sourceCode.getText(token).split("\n")
            const value = valueLines[0]
            return value
        }
276458
@Override
	public Map<String, String> convert(String token) {
		Map<String, String> headers;

		int headerEndIndex = token.indexOf('.');
		if (headerEndIndex == -1) {
			throw new InvalidTokenException("Invalid JWT. Missing JOSE Header.");
		}

		byte[] decodedHeader;

		try {
			decodedHeader = Codecs.b64UrlDecode(token.substring(0, headerEndIndex));
		} catch (IllegalArgumentException ex) {
			throw new InvalidTokenException("Invalid JWT. Malformed JOSE Header.", ex);
		}

		JsonParser parser = null;

		try {
			parser = this.factory.createParser(decodedHeader);
			headers = new HashMap<String, String>();
			if (parser.nextToken() == JsonToken.START_OBJECT) {
				while (parser.nextToken() == JsonToken.FIELD_NAME) {
					String headerName = parser.getCurrentName();
					parser.nextToken();
					String headerValue = parser.getValueAsString();
					headers.put(headerName, headerValue);
				}
			}

		} catch (IOException ex) {
			throw new InvalidTokenException("An I/O error occurred while reading the JWT: " + ex.getMessage(), ex);
		} finally {
			try {
				if (parser != null) parser.close();
			} catch (IOException ex) { }
		}

		return headers;
	}
188943
protected Callback<?> setupConditionDbNum(final ConditionFormatter formatter, final Token.Condition token) {

        final Matcher matcher = PATTERN_CONDITION_DBNUM.matcher(token.getValue());
        if(!matcher.matches()) {
            throw new IllegalArgumentException("not match condition:" + token.getValue());
        }

        Callback<?> callback = null;
        final String number = matcher.group(1);
        if(number.startsWith("1")) {
            callback = DBNum1.create();

        } else if(number.startsWith("2")) {
            callback = DBNum2.create();

        } else if(number.startsWith("3")) {
            callback = DBNum3.create();
        }

        if(callback != null) {
            formatter.addCallback(callback);
        }

        return callback;
    }
895435
final Token currentToken() throws IllegalStateException, NoSuchElementException {
        if (currentToken == null) {
            if (completed) {
                throw new NoSuchElementException(CommonI18n.noMoreContent.text());
            }
            throw new IllegalStateException(CommonI18n.startMethodMustBeCalledBeforeConsumingOrMatching.text());
        }
        assert currentToken != null;
        return currentToken;
    }
33798
protected function getTokenFormatter($token)
    {
        $formatters = $this->getTokenFormatters();

        if (!array_key_exists($token, $formatters)) {
            $message = "The class %s does not know how to format the %s token\n".
                       "Have you added it in the getTokenFormatters() method?";

            throw new Exception(sprintf($message, get_called_class(), $token));
        }

        return $formatters[$token];
    }
303015
function saveCRL($crl, $format = self::FORMAT_PEM)
    {
        if (!is_array($crl) || !isset($crl['tbsCertList'])) {
            return false;
        }

        $asn1 = new ASN1();

        $asn1->loadOIDs($this->oids);

        $filters = array();
        $filters['tbsCertList']['issuer']['rdnSequence']['value']
            = array('type' => ASN1::TYPE_UTF8_STRING);
        $filters['tbsCertList']['signature']['parameters']
            = array('type' => ASN1::TYPE_UTF8_STRING);
        $filters['signatureAlgorithm']['parameters']
            = array('type' => ASN1::TYPE_UTF8_STRING);

        if (empty($crl['tbsCertList']['signature']['parameters'])) {
            $filters['tbsCertList']['signature']['parameters']
                = array('type' => ASN1::TYPE_NULL);
        }

        if (empty($crl['signatureAlgorithm']['parameters'])) {
            $filters['signatureAlgorithm']['parameters']
                = array('type' => ASN1::TYPE_NULL);
        }

        $asn1->loadFilters($filters);

        $this->_mapOutDNs($crl, 'tbsCertList/issuer/rdnSequence', $asn1);
        $this->_mapOutExtensions($crl, 'tbsCertList/crlExtensions', $asn1);
        $rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates');
        if (is_array($rclist)) {
            foreach ($rclist as $i => $extension) {
                $this->_mapOutExtensions($rclist, "$i/crlEntryExtensions", $asn1);
            }
        }

        $crl = $asn1->encodeDER($crl, $this->CertificateList);

        switch ($format) {
            case self::FORMAT_DER:
                return $crl;
            // case self::FORMAT_PEM:
            default:
                return "-----BEGIN X509 CRL-----\r\n" . chunk_split(base64_encode($crl), 64) . '-----END X509 CRL-----';
        }
    }
420156
static String formatParseException(String pExpressionString,
                                       ParseException pExc) {
        // Generate the String of expected tokens
        StringBuffer expectedBuf = new StringBuffer();
        int maxSize = 0;
        boolean printedOne = false;

        if (pExc.expectedTokenSequences == null) {
            return pExc.toString();
        }

        for (int i = 0; i < pExc.expectedTokenSequences.length; i++) {
            if (maxSize < pExc.expectedTokenSequences[i].length) {
                maxSize = pExc.expectedTokenSequences[i].length;
            }
            for (int j = 0; j < pExc.expectedTokenSequences[i].length; j++) {
                if (printedOne) {
                    expectedBuf.append(", ");
                }
                expectedBuf.append
                        (pExc.tokenImage[pExc.expectedTokenSequences[i][j]]);
                printedOne = true;
            }
        }
        String expected = expectedBuf.toString();

        // Generate the String of encountered tokens
        StringBuffer encounteredBuf = new StringBuffer();
        Token tok = pExc.currentToken.next;
        for (int i = 0; i < maxSize; i++) {
            if (i != 0) {
                encounteredBuf.append(" ");
            }
            if (tok.kind == 0) {
                encounteredBuf.append(pExc.tokenImage[0]);
                break;
            }
            encounteredBuf.append(addEscapes(tok.image));
            tok = tok.next;
        }
        String encountered = encounteredBuf.toString();

        // Format the error message
        return MessageFormat.format
                (Constants.PARSE_EXCEPTION,
                        new Object[]{
                                expected,
                                encountered,
                        });
    }
1126721
public String getHtml(Formatter formatter, String value) {
        String result = null;
        if (value != null) {
            if ("".equals(value)) {
                result = "";
            } else {
                String formattedResponse = formatter.format(value);
                result = "<pre>" + StringEscapeUtils.escapeHtml4(formattedResponse) + "</pre>";
            }
        }
        return result;
    }
713547
@Transactional(readOnly = true)
    public void validateToken(E token) throws Exception {

        if (token == null) {
            throw new Exception("The provided token is null.");
        }

        DateTime expirationDate = (DateTime) token.getExpirationDate();

        String tokenValue = token.getToken();

        // check if the token expire date is valid
        if (expirationDate.isBeforeNow()) {
            throw new Exception("The token '" + tokenValue + "' expired on '"
                + expirationDate + "'");
        }

    }
1105456
static UserLimits getLimitsFromToken(HTTPServerConfig config, String jwtToken) {
    Objects.requireNonNull(jwtToken);
    try {
      String secretKey = config.getSecretTokenKey();
      if (secretKey == null) {
        throw new RuntimeException("You specified a 'token' parameter but this server doesn't accept tokens");
      }
      Algorithm algorithm = Algorithm.HMAC256(secretKey);
      DecodedJWT decodedToken;
      try {
        JWT.require(algorithm).build().verify(jwtToken);
        decodedToken = JWT.decode(jwtToken);
      } catch (JWTDecodeException e) {
        throw new AuthException("Could not decode token '" + jwtToken + "'", e);
      }
      Claim maxTextLengthClaim = decodedToken.getClaim("maxTextLength");
      Claim premiumClaim = decodedToken.getClaim("premium");
      boolean hasPremium = !premiumClaim.isNull() && premiumClaim.asBoolean();
      Claim uidClaim = decodedToken.getClaim("uid");
      long uid = uidClaim.isNull() ? -1 : uidClaim.asLong();
      return new UserLimits(
              maxTextLengthClaim.isNull() ? config.maxTextLength : maxTextLengthClaim.asInt(),
              config.maxCheckTimeMillis,
              hasPremium ? uid : null);
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
  }
509974
private Formatter createFormatter(Method method, Class<?>[] sig, int prio)
    {
        if (method.getReturnType() != Component.class)
        {
            throw new InvalidFormatMethodException(getClass(), method, "Format methods must return Component!");
        }

        final Invoker invoker;
        if (sig.length == 1)
        {
            invoker = new InputOnly();
        }
        else if (sig.length == 2)
        {
            if (sig[1] == Context.class)
            {
                invoker = new ContextOnly();
            }
            else if (sig[1] == Arguments.class)
            {
                invoker = new ArgsOnly();
            }
            else
            {
                throw new InvalidFormatMethodException(getClass(), method,
                                                       "Format methods may only take Context and Arguments parameters!");
            }
        }
        else if (sig.length == 3)
        {
            if (sig[1] == Context.class && sig[2] == Arguments.class)
            {
                invoker = new CompleteContextFirst();
            }
            else if (sig[1] == Arguments.class && sig[2] == Context.class)
            {
                invoker = new CompleteArgsFirst();
            }
            else
            {
                throw new InvalidFormatMethodException(getClass(), method,
                                                       "Format methods may only take Context and Arguments parameters!");
            }
        }
        else
        {
            throw new InvalidFormatMethodException(getClass(), method,
                                                   "Format methods must take at most 3 parameters!");
        }
        return new Formatter(this, method, prio, invoker);
    }
204919
public final void mJavaLetter() throws RecognitionException {
		try {
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1379:2: ( ( 'a' .. 'z' | 'A' .. 'Z' | '$' | '_' ) |{...}?~ ( '\\u0000' .. '\\u007F' | '\\uD800' .. '\\uDBFF' ) |{...}? ( '\\uD800' .. '\\uDBFF' ) ( '\\uDC00' .. '\\uDFFF' ) )
			int alt27=3;
			int LA27_0 = input.LA(1);
			if ( (LA27_0=='$'||(LA27_0 >= 'A' && LA27_0 <= 'Z')||LA27_0=='_'||(LA27_0 >= 'a' && LA27_0 <= 'z')) ) {
				alt27=1;
			}
			else if ( ((LA27_0 >= '\u0080' && LA27_0 <= '\uD7FF')||(LA27_0 >= '\uDC00' && LA27_0 <= '\uFFFF')) ) {
				alt27=2;
			}
			else if ( ((LA27_0 >= '\uD800' && LA27_0 <= '\uDBFF')) ) {
				alt27=3;
			}

			else {
				NoViableAltException nvae =
					new NoViableAltException("", 27, 0, input);
				throw nvae;
			}

			switch (alt27) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1379:4: ( 'a' .. 'z' | 'A' .. 'Z' | '$' | '_' )
					{
					if ( input.LA(1)=='$'||(input.LA(1) >= 'A' && input.LA(1) <= 'Z')||input.LA(1)=='_'||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1380:6: {...}?~ ( '\\u0000' .. '\\u007F' | '\\uD800' .. '\\uDBFF' )
					{
					if ( !((Character.isJavaIdentifierStart(input.LA(1)))) ) {
						throw new FailedPredicateException(input, "JavaLetter", "Character.isJavaIdentifierStart(input.LA(1))");
					}
					if ( (input.LA(1) >= '\u0080' && input.LA(1) <= '\uD7FF')||(input.LA(1) >= '\uDC00' && input.LA(1) <= '\uFFFF') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;
				case 3 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1382:9: {...}? ( '\\uD800' .. '\\uDBFF' ) ( '\\uDC00' .. '\\uDFFF' )
					{
					if ( !((Character.isJavaIdentifierStart(Character.toCodePoint((char)input.LA(-1), (char)input.LA(1))))) ) {
						throw new FailedPredicateException(input, "JavaLetter", "Character.isJavaIdentifierStart(Character.toCodePoint((char)input.LA(-1), (char)input.LA(1)))");
					}
					if ( (input.LA(1) >= '\uD800' && input.LA(1) <= '\uDBFF') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					if ( (input.LA(1) >= '\uDC00' && input.LA(1) <= '\uDFFF') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;

			}
		}
		finally {
			// do for sure before leaving
		}
	}
1347410
@SuppressWarnings("ConstantConditions")
    @Beta
    public static int countToken(@Nullable String target, String token) {
        checkArgument(token != null && !token.isEmpty(), "Expected non-empty token, got: '%s'", token);

        if (isNullOrEmpty(target)) {
            return 0;
        }

        int count = 0;
        int tokenIndex = 0;
        while ((tokenIndex = target.indexOf(token, tokenIndex)) != -1) {
            count++;
            tokenIndex += token.length();
        }
        return count;
    }
181231
List<Token<UriElement>> tokenize(String s) throws IllegalArgumentException {
        if (s == null || s.length() == 0) {
            return new ArrayList<Token<UriElement>>();
        }

        //
        // Make sure if a scheme is not specified, we default one before we parse as a URI.
        //
        if ( !SCHEME_URI_PATTERN.matcher(s).matches()) {
            s = ("http://")+s;
        }

        //
        // Parse as a URI
        //
        URI uri = URI.create(s);

        //
        // Detect what the scheme is, if any.
        //
        List<Token<UriElement>> result = new ArrayList<Token<UriElement>>(10);
        String scheme = "http";
        if (uri.getScheme() != null) {
            scheme = uri.getScheme();
        }


        //
        // A wildcard-ed hostname is parsed as an authority.
        //
        String host = uri.getHost();
        String parsedPortFromAuthority = null;
        String parsedUserInfoFromAuthority = null;
        String userFromAuthority = null;
        String passwordFromAuthority = null;
        if (host == null) {
            String authority = uri.getAuthority();
            if (authority != null) {
                host = authority;
                int asteriskIdx = host.indexOf("@");
                if ( asteriskIdx >= 0) {
                    parsedUserInfoFromAuthority = host.substring(0, asteriskIdx);
                    host = host.substring(asteriskIdx+1);
                    int colonIdx = parsedUserInfoFromAuthority.indexOf(":");
                    if ( colonIdx >= 0) {
                        userFromAuthority = parsedUserInfoFromAuthority.substring(0, colonIdx);
                        passwordFromAuthority = parsedUserInfoFromAuthority.substring(colonIdx+1);
                    }
                }
                int colonIdx = host.indexOf(":");
                if ( colonIdx >=0 ) {
                    parsedPortFromAuthority = host.substring(colonIdx + 1);
                    host = host.substring(0, colonIdx);
                }
            } else {
                throw new IllegalArgumentException("Hostname is required.");
            }
        }

        //
        // Split the host and reverse it for the tokenization.
        //
        List<String> hostParts = Arrays.asList(host.split("\\."));
        Collections.reverse(hostParts);
        for (String hostPart: hostParts) {
            result.add(new Token<UriElement>(hostPart, UriElement.HOST));
        }

        if (parsedPortFromAuthority != null) {
            result.add(new Token<UriElement>(parsedPortFromAuthority, UriElement.PORT));
        } else if (uri.getPort() > 0) {
            result.add(new Token<UriElement>(String.valueOf(uri.getPort()), UriElement.PORT));
        } else if (getDefaultPort(scheme) > 0) {
            result.add(new Token<UriElement>(String.valueOf(getDefaultPort(scheme)), UriElement.PORT));
        }


        if ( parsedUserInfoFromAuthority != null ) {
            if ( userFromAuthority != null) {
                result.add(new Token<UriElement>(userFromAuthority, UriElement.USERINFO));
            }
            if ( passwordFromAuthority != null ) {
                result.add(new Token<UriElement>(passwordFromAuthority, UriElement.USERINFO));
            }
            if ( userFromAuthority == null && passwordFromAuthority == null) {
                result.add(new Token<UriElement>(parsedUserInfoFromAuthority, UriElement.USERINFO));
            }
        } else if (uri.getUserInfo() != null) {
            String userInfo = uri.getUserInfo();
            int colonIdx = userInfo.indexOf(":");
            if ( colonIdx >= 0) {
                result.add(new Token<UriElement>(userInfo.substring(0, colonIdx), UriElement.USERINFO));
                result.add(new Token<UriElement>(userInfo.substring(colonIdx+1), UriElement.USERINFO));
            } else {
                result.add(new Token<UriElement>(uri.getUserInfo(), UriElement.USERINFO));
            }
        }

        if (isNotBlank(uri.getPath())) {
            String path = uri.getPath();
            if (path.startsWith("/")) {
                path = path.substring(1);
            }
            if (isNotBlank(path)) {
                for (String p: path.split("/")) {
                    result.add(new Token<UriElement>(p, UriElement.PATH));
                }
            }
        }
        return result;
    }
49465
private function apiCall(string $url, string $token): DeviceAddressInformation
    {
        $response = $this->client->request('GET', $url, [
            'headers' => [
                'Authorization' => 'Bearer '.$token,
                'Accept'        => 'application/json',
            ],
        ]);

        /*
         * Api Call response codes:
         * 200 OK                    Successfully got the address associated with this deviceId.
         * 204 No Content            The query did not return any results.
         * 403 Forbidden            The authentication token is invalid or doesn’t have access to the resource.
         * 405 Method Not Allowed    The method is not supported.
         * 429 Too Many Requests    The skill has been throttled due to an excessive number of requests.
         * 500 Internal Error        An unexpected error occurred.
         */
        switch ($response->getStatusCode()) {
            case 200:
                break;
            case 204:
            case 403:
            case 405:
            case 429:
            case 500:
            default:
                throw new DeviceApiCallException(sprintf('Error in api call (status code:"%s")', $response->getStatusCode()));
        }

        return DeviceAddressInformation::fromApiResponse(json_decode($response->getBody()->getContents(), true));
    }
619820
@SuppressWarnings("unchecked")
    private BaseDescr lhsPatternBind(PatternContainerDescrBuilder<?, ?> ce,
            final boolean allowOr) throws RecognitionException {
        PatternDescrBuilder<?> pattern = null;
        CEDescrBuilder<?, OrDescr> or = null;
        BaseDescr result = null;

        Token first = input.LT(1);
        pattern = helper.start((DescrBuilder<?, ?>) ce,
                PatternDescrBuilder.class,
                null);
        if (pattern != null) {
            result = pattern.getDescr();
        }

        String label = null;
        boolean isUnification = false;
        if (input.LA(1) == DRL6Lexer.ID && input.LA(2) == DRL6Lexer.COLON && !helper.validateCEKeyword(1)) {
            label = label(DroolsEditorType.IDENTIFIER_PATTERN);
            if (state.failed)
                return null;
        } else if (input.LA(1) == DRL6Lexer.ID && input.LA(2) == DRL6Lexer.UNIFY && !helper.validateCEKeyword(1)) {
            label = unif(DroolsEditorType.IDENTIFIER_PATTERN);
            if (state.failed)
                return null;
            isUnification = true;
        }

        if (input.LA(1) == DRL6Lexer.LEFT_PAREN) {
            try {
                match(input,
                        DRL6Lexer.LEFT_PAREN,
                        null,
                        null,
                        DroolsEditorType.SYMBOL);
                if (state.failed)
                    return null;

                if (helper.validateCEKeyword(1)) {
                    failMismatchedTokenException();
                    return null; // in case it is backtracking
                }

                lhsPattern(pattern,
                        label,
                        isUnification);
                if (state.failed)
                    return null;

                if (allowOr && helper.validateIdentifierKey(DroolsSoftKeywords.OR) && ce instanceof CEDescrBuilder) {
                    if (state.backtracking == 0) {
                        // this is necessary because of the crappy bind with multi-pattern OR syntax
                        or = ((CEDescrBuilder<DescrBuilder<?, ?>, OrDescr>) ce).or();
                        result = or.getDescr();

                        helper.end(PatternDescrBuilder.class,
                                pattern);
                        helper.start(or,
                                CEDescrBuilder.class,
                                null);
                        // adjust real or starting token:
                        helper.setStart(or,
                                first);

                        // remove original pattern from the parent CE child list:
                        ((ConditionalElementDescr) ce.getDescr()).getDescrs().remove(pattern.getDescr());
                        // add pattern to the OR instead
                        or.getDescr().addDescr(pattern.getDescr());
                    }

                    while (helper.validateIdentifierKey(DroolsSoftKeywords.OR)) {
                        match(input,
                                DRL6Lexer.ID,
                                DroolsSoftKeywords.OR,
                                null,
                                DroolsEditorType.KEYWORD);
                        if (state.failed)
                            return null;

                        pattern = helper.start(or,
                                PatternDescrBuilder.class,
                                null);
                        // new pattern, same binding
                        lhsPattern(pattern,
                                label,
                                isUnification);
                        if (state.failed)
                            return null;

                        helper.end(PatternDescrBuilder.class,
                                pattern);
                    }
                }

                match(input,
                        DRL6Lexer.RIGHT_PAREN,
                        null,
                        null,
                        DroolsEditorType.SYMBOL);
                if (state.failed)
                    return null;

            } finally {
                if (or != null) {
                    helper.end(CEDescrBuilder.class,
                            or);
                } else {
                    helper.end(PatternDescrBuilder.class,
                            pattern);
                }
            }

        } else {
            try {
                lhsPattern(pattern,
                        label,
                        isUnification);
                if (state.failed)
                    return null;

            } finally {
                helper.end(PatternDescrBuilder.class,
                        pattern);
            }
        }

        return result;
    }