public KeyValuePairCollection getAll(KeyMatcher keyMatcher) { KeyValuePairCollection pairsPerKey = new OrderedKeyValuePairCollection(); for (KeyValuePair kvp : m_pairs) { if (keyMatcher.matches(kvp.getKey())) { pairsPerKey.add(kvp); } } return pairsPerKey; }
@Override public String getHeader(String name) { if (!m_headers.containsKey(KeyMatcher.ignoringCase(name))) { return null; } return m_headers.getUnique(KeyMatcher.ignoringCase(name)).getValue(); }
/** * constructs the string representation of the path. * * @return a string. */ public String asString() { if (size() == 1 && hasTrailingSlash()) { // special case if only one part, then join will not append the delimter. return PATH_DELIMITER; } return StringUtils.join(segments, PATH_DELIMITER); }
public static String encodeForURL(String value, String charset) { EncodingOptions encodingOptions = EncodingOptions.defaultOptions().charset(charset); return encodeForURL(value, encodingOptions); }
public static String buildQueryStringForUrl(Map<String, Iterable<String>> params, String charset) { return buildQueryStringForUrl(params, EncodingOptions.defaultOptions().charset(charset)); }
public boolean matches(String path) { for (PathWildcardMatcher matcher : m_pathMatchers) { if (matcher.matches(path)) { return true; } } return false; }
public static String encodeForURL(String value, EncodingOptions encodingOptions) { if (!encodingOptions.isSpaceAsPercent()){ return encodeForURLSpaceAsPlus(value, encodingOptions.getCharset()); } return encodeForURLSpaceAsPercent(value, encodingOptions.getCharset()); }
@Override public String getParameter(String name) { return m_formParameters.getUnique(KeyMatcher.ignoringCase(name)).getValue(); }
public static String encodeForURL(String value) { return encodeForURL(value, EncodingOptions.defaultOptions()); }
public KeyValuePair getUnique(KeyMatcher keyMatcher) throws NonUniqueException { KeyValuePairCollection possiblyNonUniquePairs = getAll(keyMatcher); if (possiblyNonUniquePairs.size() == 0) { return null; } if (possiblyNonUniquePairs.size() > 1) { throw new NonUniqueException("Multiple matching KeyValuePairs found for key <" + keyMatcher + ">."); } return possiblyNonUniquePairs.iterator().next(); }
/** * Sends a HTML form redirect. Builds an HTML fragment as content containing a form * which sends itself after loading. Usefull for URLs * with a long parameter list. All URL parameters are encoded as POST body * parameters. */ public static void sendFormPostRedirect(String redirectUrl, HttpServletResponse response) { sendFormPostRedirect(redirectUrl, response, URLUtils.parseQueryStringFromUrl(redirectUrl)); }
/** * gives an {@link URLPath}, which contains all elements starting from the * given index. * * @param start of the first element (including) {@link URLPath} * @return the {@link URLPath} with the sub elements */ public URLPath getSubPath(int start) { return getSubPath(start, size()); }
public static String replaceQueryInUrl(String url, Map<String, Iterable<String>> params) { String query = buildQueryStringForUrl(params); url = removeQueryStringFromUrl(url); return url + "?" + query; }
/** * gives a {@link URLPath} with a trailing slash * * @return a new created {@link URLPath}, which have all elements, with a * trailing slash */ public URLPath appendTrailingSlash() { if (hasTrailingSlash()) { return this; } return append(ROOT); }
public StringInputStream(String content, Charset charset) { m_content = content; initEncoder(charset); initBuffers(); }
/** * @param uid * @param roles Collection of String. * @param userAttributes Collection of {@link Attribute}. * @param expiration * @param issuer */ public Token(String uid, Collection<String> roles, Collection<Attribute> userAttributes, Date expiration, String issuer) { this(uid, roles, userAttributes, DateUtil.tofullISOString(expiration), issuer); }
private EncodingOptions copy() { EncodingOptions clone = new EncodingOptions(); clone.charset = charset; clone.spaceAsPercent = spaceAsPercent; return clone; }
/** * checks, if this {@link URLPath} have no elements * * @return {@code true} if this {@link URLPath} have no elements, otherwise * {@code false} */ public boolean isEmpty() { return EMPTY.equals(this); }
public EncodingOptions spaceAsPercent() { EncodingOptions copy = this.copy(); copy.spaceAsPercent = true; return copy; }