/** * Convenience method to return a Collection as a CSV String. * E.g. useful for <code>toString()</code> implementations. * * @param coll the Collection to display * @return the delimited String */ public static String collectionToCommaDelimitedString(Iterable<?> coll) { return collectionToDelimitedString(coll, ","); }
/** * Convenience method to return a Collection as a delimited (e.g. CSV) * String. E.g. useful for <code>toString()</code> implementations. * * @param coll the Collection to display * @param delim the delimiter to use (probably a ",") * @return the delimited String */ public static String collectionToDelimitedString(Iterable<?> coll, String delim) { return collectionToDelimitedString(coll, delim, "", ""); }
@Override public String getDescription() { return "requests[" + requests.size() + "], indices[" + Strings.collectionToDelimitedString(indices, ", ") + "]"; }
/** * Convenience method to return a Collection as a delimited (e.g. CSV) * String. E.g. useful for <code>toString()</code> implementations. * * @param coll the Collection to display * @param delim the delimiter to use (probably a ",") * @param prefix the String to start each element with * @param suffix the String to end each element with * @return the delimited String */ public static String collectionToDelimitedString(Iterable<?> coll, String delim, String prefix, String suffix) { StringBuilder sb = new StringBuilder(); collectionToDelimitedString(coll, delim, prefix, suffix, sb); return sb.toString(); }
protected static String mergeFieldValues(List<Object> fieldValues, char valuesSeparator) { //postings highlighter accepts all values in a single string, as offsets etc. need to match with content //loaded from stored fields, we merge all values using a proper separator String rawValue = Strings.collectionToDelimitedString(fieldValues, String.valueOf(valuesSeparator)); return rawValue.substring(0, Math.min(rawValue.length(), Integer.MAX_VALUE - 1)); }
public SettingsFilter(Collection<String> patterns) { for (String pattern : patterns) { if (isValidPattern(pattern) == false) { throw new IllegalArgumentException("invalid pattern: " + pattern); } } this.patterns = Collections.unmodifiableSet(new HashSet<>(patterns)); patternString = Strings.collectionToDelimitedString(patterns, ","); }
} else { sb.append("stats["); Strings.collectionToDelimitedString(context.groupStats(), ",", "", "", sb); sb.append("], ");
Locale.ROOT, "missing mandatory plugins [%s], found plugins [%s]", Strings.collectionToDelimitedString(missingPlugins, ", "), Strings.collectionToDelimitedString(pluginsNames, ", ")); throw new IllegalStateException(message);
/** * Handle HTTP OPTIONS requests to a valid REST endpoint. A 200 HTTP * response code is returned, and the response 'Allow' header includes a * list of valid HTTP methods for the endpoint (see * <a href="https://tools.ietf.org/html/rfc2616#section-9.2">HTTP/1.1 - 9.2 * - Options</a>). */ private void handleOptionsRequest(RestRequest request, RestChannel channel, Set<RestRequest.Method> validMethodSet) { if (request.method() == RestRequest.Method.OPTIONS && validMethodSet.size() > 0) { BytesRestResponse bytesRestResponse = new BytesRestResponse(OK, TEXT_CONTENT_TYPE, BytesArray.EMPTY); bytesRestResponse.addHeader("Allow", Strings.collectionToDelimitedString(validMethodSet, ",")); channel.sendResponse(bytesRestResponse); } else if (request.method() == RestRequest.Method.OPTIONS && validMethodSet.size() == 0) { /* * When we have an OPTIONS HTTP request and no valid handlers, * simply send OK by default (with the Access Control Origin header * which gets automatically added). */ channel.sendResponse(new BytesRestResponse(OK, TEXT_CONTENT_TYPE, BytesArray.EMPTY)); } }
/** * Handle requests to a valid REST endpoint using an unsupported HTTP * method. A 405 HTTP response code is returned, and the response 'Allow' * header includes a list of valid HTTP methods for the endpoint (see * <a href="https://tools.ietf.org/html/rfc2616#section-10.4.6">HTTP/1.1 - * 10.4.6 - 405 Method Not Allowed</a>). */ private void handleUnsupportedHttpMethod(RestRequest request, RestChannel channel, Set<RestRequest.Method> validMethodSet) { try { BytesRestResponse bytesRestResponse = BytesRestResponse.createSimpleErrorResponse(channel, METHOD_NOT_ALLOWED, "Incorrect HTTP method for uri [" + request.uri() + "] and method [" + request.method() + "], allowed: " + validMethodSet); bytesRestResponse.addHeader("Allow", Strings.collectionToDelimitedString(validMethodSet, ",")); channel.sendResponse(bytesRestResponse); } catch (final IOException e) { logger.warn("failed to send bad request response", e); channel.sendResponse(new BytesRestResponse(INTERNAL_SERVER_ERROR, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY)); } }
/** * Convenience method to return a Collection as a delimited (e.g. CSV) * String. E.g. useful for <code>toString()</code> implementations. * * @param coll the Collection to display * @param delim the delimiter to use (probably a ",") * @return the delimited String */ public static String collectionToDelimitedString(Iterable<?> coll, String delim) { return collectionToDelimitedString(coll, delim, "", ""); }
/** * Convenience method to return a Collection as a delimited (e.g. CSV) * String. E.g. useful for <code>toString()</code> implementations. * * @param coll the Collection to display * @param delim the delimiter to use (probably a ",") * @return the delimited String */ public static String collectionToDelimitedString(Iterable<?> coll, String delim) { return collectionToDelimitedString(coll, delim, "", ""); }
/** * Convenience method to return a Collection as a CSV String. * E.g. useful for <code>toString()</code> implementations. * * @param coll the Collection to display * @return the delimited String */ public static String collectionToCommaDelimitedString(Iterable<?> coll) { return collectionToDelimitedString(coll, ","); }
/** * Convenience method to return a Collection as a delimited (e.g. CSV) * String. E.g. useful for <code>toString()</code> implementations. * * @param coll the Collection to display * @param delim the delimiter to use (probably a ",") * @return the delimited String */ public static String collectionToDelimitedString(Iterable<?> coll, String delim) { return collectionToDelimitedString(coll, delim, "", ""); }
/** * Convenience method to return a Collection as a CSV String. * E.g. useful for <code>toString()</code> implementations. * * @param coll the Collection to display * @return the delimited String */ public static String collectionToCommaDelimitedString(Iterable<?> coll) { return collectionToDelimitedString(coll, ","); }
@Override public String getDescription() { return "requests[" + requests.size() + "], indices[" + Strings.collectionToDelimitedString(indices, ", ") + "]"; }
static String mergeFieldValues(List<Object> fieldValues, char valuesSeparator) { //postings highlighter accepts all values in a single string, as offsets etc. need to match with content //loaded from stored fields, we merge all values using a proper separator String rawValue = Strings.collectionToDelimitedString(fieldValues, String.valueOf(valuesSeparator)); return rawValue.substring(0, Math.min(rawValue.length(), Integer.MAX_VALUE - 1)); }
public SettingsFilter(Settings settings, Collection<String> patterns) { super(settings); for (String pattern : patterns) { if (isValidPattern(pattern) == false) { throw new IllegalArgumentException("invalid pattern: " + pattern); } } this.patterns = Collections.unmodifiableSet(new HashSet<>(patterns)); patternString = Strings.collectionToDelimitedString(patterns, ","); }
@Override public String toString() { List<String> components = new ArrayList<>(4); components.add("target shard [" + shardRouting +"]"); components.add("indexUUID [" + indexUUID + "]"); components.add("message [" + message +"]"); if (failure != null) { components.add("failure [" + ExceptionsHelper.detailedMessage(failure) + "]"); } return Strings.collectionToDelimitedString(components, ", "); } }
public SettingsFilter(Settings settings, Collection<String> patterns) { super(settings); for (String pattern : patterns) { if (isValidPattern(pattern) == false) { throw new IllegalArgumentException("invalid pattern: " + pattern); } } this.patterns = Collections.unmodifiableSet(new HashSet<>(patterns)); patternString = Strings.collectionToDelimitedString(patterns, ","); }