Splits the cookie token into attributes pairs.
@param str input token.
@return a map with the attribute pairs of the token if the input is valid.
Else, returns null.
435170
private static Map<String, String> splitCookieToken(String tokenStr) {
    Map<String, String> map = new HashMap<String, String>();
    StringTokenizer st = new StringTokenizer(tokenStr, COOKIE_ATTR_SEPARATOR);

    while (st.hasMoreTokens()) {
      String part = st.nextToken();
      int separator = part.indexOf(COOKIE_KEY_VALUE_SEPARATOR);
      if (separator == -1) {
        LOG.error("Invalid token string " + tokenStr);
        return null;
      }
      String key = part.substring(0, separator);
      String value = part.substring(separator + 1);
      map.put(key, value);
    }
    return map;
  }
14703
public static MutableMap<String, String> tokensToMap(
            String string,
            String pairSeparator,
            String keyValueSeparator)
    {
        MutableMap<String, String> map = UnifiedMap.newMap();
        for (StringTokenizer tokenizer = new StringTokenizer(string, pairSeparator); tokenizer.hasMoreTokens(); )
        {
            String token = tokenizer.nextToken();
            String key = token.substring(0, token.indexOf(keyValueSeparator));
            String value = token.substring(token.indexOf(keyValueSeparator) + 1, token.length());
            map.put(key, value);
        }
        return map;
    }
1167802
private T loadLiteralValue(final String str)
	{
		// Literal in-memory value
		final String cachedStr = (inMemoryString != null) ? inMemoryString.get() : null;

		if (StringUtils.equals(str, cachedStr))
		{
			// Cached value is still valid!
		}
		else
		{
			cached = null; // Prevent the old value from being used

			// Cached value is not valid anymore, re-parse
			setCached(clazz.cast(factory.getInstance(clazz).deserialise(str)));

			inMemoryString = new SoftReference<>(str);
		}

		return cached;
	}
1292539
public static String decode(String str) {
    if (str != null) {
      try {
        return URLDecoder.decode(str, UTF_8.name());
      } catch (UnsupportedEncodingException e) {
        throw new RuntimeException("JVM must support UTF-8", e);
      }
    }
    return null;
  }
240268
@Override
	public List<Token> tokenize(String s) {
		List<Token> result = new ArrayList<Token>();
		result.add(new UndefinedToken(s));

		for (PredefinedTokenDefinition predefinedTokenDefinition : _predefinedTokenDefitions) {
			Set<Pattern> patterns = predefinedTokenDefinition.getTokenRegexPatterns();
			for (Pattern pattern : patterns) {
				for (ListIterator<Token> it = result.listIterator(); it.hasNext();) {
					Token token = it.next();
					if (token instanceof UndefinedToken) {
						List<Token> replacementTokens = tokenizeInternal(token.getString(), predefinedTokenDefinition,
								pattern);
						if (replacementTokens.size() > 1) {
							it.remove();
							for (Token newToken : replacementTokens) {
								it.add(newToken);
							}
						}
					}
				}
			}
		}

		return result;
	}
128624
public void setAttributes(String str)
    {
        str = str.trim();
        String delimiter = ":";    // default is colon delimiter,
        if(str.indexOf(";") != -1) // but use semi-colon with date format parameters (eg. HH:mm)
            delimiter = ";";
        StringTokenizer st = new StringTokenizer(str, delimiter);
        while(st.hasMoreTokens())
        {
            String token = st.nextToken().trim();
            int pos = token.indexOf("=");
            if(pos != -1)
            {
                String name = token.substring(0, pos).trim();
                String value = token.substring(pos+1).trim();

                if(name.equals(TYPE_ATTR))
                {
                    type = getCellType(value);
                }
                else if(name.equals(FORMAT_ATTR))
                {
                    format = value;
                }
                else if(name.equals(INPUT_TYPE_ATTR))
                {
                    inputType = getDataType(value);
                    if(outputType == NO_TYPE)
                        outputType = inputType;
                }
                else if(name.equals(INPUT_FORMAT_ATTR))
                {
                    inputFormat = value;
                }
                else if(name.equals(OUTPUT_TYPE_ATTR))
                {
                    outputType = getDataType(value);
                    if(inputType == NO_TYPE)
                        inputType = outputType;
                }
                else if(name.equals(OUTPUT_FORMAT_ATTR))
                {
                    outputFormat = value;
                }
                else if(name.equals(REGEX_ATTR))
                {
                    regex = value;
                }
                else if(name.equals(NULL_VALUE_ATTR))
                {
                    nullValue = value;
                }
                else if(name.equals(ALIGN_ATTR))
                {
                    align = getAlignment(value);
                }
                else if(name.equals(WRAP_ATTR))
                {
                    wrap = Boolean.parseBoolean(value);
                }
                else if(name.equals(DISPLAY_ATTR))
                {
                    display = value;
                }
            }
        }
    }
67177
function(str) {
	var tokens = [] // size = str.length + 2
	var i = 0;
	var maxlen = str.length;
	TOKEN:
	while (i < maxlen) {
		var c = str.charAt(i);
		var mlo = m_tokens_start.get(c);
		// if there are multi-char tokens starting with this char, try them
		if (mlo != null) {
			for (var len = mlo; len > 1; len--) {
				if (i <= maxlen - len) {
					var tr = str.substring(i, i + len);
					if (m_tokens.contains(tr)) {
						tokens.push(tr);
						i += len;
						continue TOKEN;
					}
				}
			}
		}
		// things starting with backslash are special
		if (c == '\\' && i <= maxlen - 2) {
			if (str.charAt(i + 1) == 'u' && i <= maxlen - 6) {
				tokens.push(str.substring(i, i + 6));		// \\uxxxx
				i += 6;
			} else if (str.charAt(i + 1) == 'U' && i <= maxlen - 10) {
				tokens.push(str.substring(i, i + 10));		// \\Uxxxxxxxx
				i += 10;
			} else {
				tokens.push(str.substring(i, i + 2));		// \\x
				i += 2;
			}
			continue TOKEN;
		}
		// otherwise just take one char
		tokens.push(c.toString());
		i += 1;
	}
	return tokens;
}
1189777
public static String[] split(String str, String separator, boolean trim) {
        if (str == null) {
            return null;
        }

        char sep = separator.charAt(0);

        ArrayList<String> strList = new ArrayList<String>();
        StringBuilder split = new StringBuilder();
        int index = 0;
        while ((index = StringUtils.findNext(str, sep, StringUtils.ESCAPE_CHAR, index, split)) >= 0) {
            ++index; // move over the separator for next search
            strList.add(split.toString());
            split.setLength(0); // reset the buffer
        }

        strList.add(split.toString());
        // remove trailing empty split(s)
        if (trim) {
            int last = strList.size(); // last split
            while (--last>=0 && "".equals(strList.get(last))) {
                strList.remove(last);
            }
        }

        return strList.toArray(new String[strList.size()]);
    }
927879
public static boolean isToken(String str) {
		// token := 1*<any (US-ASCII) CHAR except SPACE, CTLs, or tspecials>
		// tspecials := "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" /
		// <"> / "/" / "[" / "]" / "?" / "="
		// CTL := 0.- 31., 127.

		final int length = str.length();
		if (length == 0)
			return false;

		for (int idx = 0; idx < length; idx++) {
			char ch = str.charAt(idx);
			if (!TOKEN_CHARS.get(ch))
				return false;
		}

		return true;
	}
639091
function(tokenStr) {
            if (typeof tokenStr !== 'string') {
                return null;
            }
            var token = tokenCache[tokenStr];
            if (token !== undefined) {
                return token;
            } else {
                try {
                    token = tokens.validate(tokenStr, trustedPubKey);
                    tokenCache[tokenStr] = token;
                    return token;
                } catch (err) {
                    // did not validate, cache negative result.
                    tokenCache[tokenStr] = null;
                    return null;
                }
            }
        }
1049504
public static UTF8String fromString(String str) {
    return str == null ? null : fromBytes(str.getBytes(StandardCharsets.UTF_8));
  }
1178013
public static PrivateKey stringToRSAPrivateKey (String str)
    {
        try {
            BigInteger mod = new BigInteger(str.substring(0, str.indexOf(SPLIT)), 16);
            BigInteger exp = new BigInteger(str.substring(str.indexOf(SPLIT) + 1), 16);
            RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec(mod, exp);
            KeyFactory kf = KeyFactory.getInstance("RSA");
            return kf.generatePrivate(keySpec);
        } catch (NumberFormatException nfe) {
            log.warning("Failed to read key from string.", "str", str, nfe);
        } catch (GeneralSecurityException gse) {
            log.warning("Failed to read key from string.", "str", str, gse);
        }
        return null;
    }
628450
public List<T> list(String str)
    {
        Map<String,T> map = new LinkedHashMap<String,T>();

        if(str == null || str.length() == 0) // Select all resources by default
            str = "%";
        String[] tokens = str.split(",");
        for(String token : tokens)
        {
            token = token.trim();
            if(token.length() > 0)
            {
                Pattern pattern = Pattern.compile(token.replace("?", ".?").replace("%", ".*?"));
                for(NamedResource resource : names.values())
                {
                   if(pattern.matcher(resource.getName()).matches())
                        map.put(resource.getName(), (T)resource);
                }
            }
        }

        List<T> ret = new ArrayList<T>();
        ret.addAll(map.values());
        return ret;
    }
609641
function decodeToken(tokenStr) {
  if (!tokenStr || tokenStr === '') return null;
  try {
    return (0, _jwtDecode2.default)(tokenStr);
  } catch (error) {
    _logger2.default.error({
      description: 'Error decoding token.',
      error: error, func: 'decodeToken', file: 'token'
    });
    return null;
  }
}
69758
public static void split(String input, char delimiter, Consumer<String> callbackPerSubstring) {
        if(input == null) throw new NullPointerException("input cannot be null");
        
        final int len = input.length();
        
        int lastMark = 0;
        for (int i = 0; i < len; i++) {
            if (input.charAt(i) == delimiter) {
                callbackPerSubstring.accept(input.substring(lastMark, i));
                lastMark = i + 1;// 1 == delimiter length
            }
        }
        callbackPerSubstring.accept(input.substring(lastMark, len));
    }
225982
function parseCookies(str) {
  var cookies = {};

  var ary = (str || '').split(/;\s+/);
  _.map(ary, function(ck) {
    var parsed = ck.trim().split('=');
    cookies[parsed[0]] = parsed[1];
  });

  return cookies;
}
334656
public static List<Token> tokenize(CharSequence input, boolean textTrim) {
        if (input == null) {
            throw new IllegalArgumentException("input must not be null");
        }

        int inputLen = input.length();
        if (inputLen == 0) {
            List<Token> tokens = new ArrayList<>(1);
            tokens.add(new Token(""));
            return tokens;
        }

        int status = AT_TEXT;
        int tokenStartOffset = 0; // start position of token in the stringBuffer
        char symbol = Token.PARAMETER_SYMBOL; // PARAMETER_SYMBOL or ATTRIBUTE_SYMBOL
        char c;

        StringBuilder nameBuf = new StringBuilder();
        StringBuilder valueBuf = new StringBuilder();
        StringBuilder textBuf = new StringBuilder();

        List<Token> tokens = new ArrayList<>();

        for (int i = 0; i < inputLen; i++) {
            c = input.charAt(i);

            switch (status) {
            case AT_TEXT:
                textBuf.append(c);
                if (Token.isTokenSymbol(c)) {
                    symbol = c;
                    status = AT_TOKEN_SYMBOL;
                    // abc$ --> tokenStartOffset: 3
                    tokenStartOffset = textBuf.length() - 1;
                }
                break;
            case AT_TOKEN_SYMBOL:
                textBuf.append(c);
                if (c == Token.START_BRACKET) {
                    status = AT_TOKEN_NAME;
                } else {
                    if (Token.isTokenSymbol(c)) {
                        symbol = c;
                        status = AT_TOKEN_SYMBOL;
                        // abc$ --> tokenStartOffset: 3
                        tokenStartOffset = textBuf.length() - 1;
                    } else {
                        status = AT_TEXT;
                    }
                }
                break;
            case AT_TOKEN_NAME:
            case AT_TOKEN_VALUE:
                textBuf.append(c);
                if (status == AT_TOKEN_NAME) {
                    if (c == Token.VALUE_SEPARATOR) {
                        status = AT_TOKEN_VALUE;
                        break;
                    }
                }
                if (c == Token.END_BRACKET) {
                    if (nameBuf.length() > 0 || valueBuf.length() > 0) {
                        // save previous non-token string
                        if (tokenStartOffset > 0) {
                            String text = trimBuffer(textBuf, tokenStartOffset, textTrim);
                            Token token = new Token(text);
                            tokens.add(token);
                        }

                        // save token name and default value
                        Token token = createToken(symbol, nameBuf, valueBuf);
                        tokens.add(token);

                        status = AT_TEXT;
                        textBuf.setLength(0);
                        break;
                    }

                    status = AT_TEXT;
                    break;
                }
                if (status == AT_TOKEN_NAME) {
                    if (nameBuf.length() > MAX_TOKEN_NAME_LENGTH) {
                        status = AT_TEXT;
                        nameBuf.setLength(0);
                    }
                    nameBuf.append(c);
                } else {
                    valueBuf.append(c);
                }
                break;
            }
        }

        if (textBuf.length() > 0) {
            String text = trimBuffer(textBuf, textBuf.length(), textTrim);
            Token token = new Token(text);
            tokens.add(token);
        }

        return tokens;
    }