protected boolean shouldKeep(String parentField, String name) { name = StringUtils.hasText(parentField) ? parentField + "." + name : name; return FieldFilter.filter(name, includes, excludes).matched; } }
Matcher(String path) { this.path = path; tokens = StringUtils.tokenize(path, "."); }
public static String concatenate(Collection<?> list) { return concatenate(list, DEFAULT_DELIMITER); }
StringBuilder sb = new StringBuilder(); sb.append(indices); if (StringUtils.hasLength(types)) { sb.append("/"); sb.append(types); if (StringUtils.hasText(shard)) { pref.append("_shards:"); pref.append(shard); if (local || StringUtils.hasText(preference)) { if (pref.length() > 0) { if (version.onOrAfter(EsMajorVersion.V_5_X)) { if (StringUtils.hasText(preference)) { pref.append(preference); } else { Entry<String, String> entry = it.next(); sb.append(entry.getKey()); if (StringUtils.hasText(entry.getValue())) { sb.append("="); sb.append(entry.getValue());
if (StringUtils.hasText(userFilter)){ if (fields.isEmpty()) { fields = StringUtils.tokenize(userFilter, ","); } else { throw new EsHadoopIllegalStateException("User specified source filters were found [" + userFilter + "], " + "but the connector is executing in a state where it has provided its own source filtering " + "[" + StringUtils.concatenate(fields, ",") + "]. Please clear the user specified source fields under the " + "[" + ConfigurationOptions.ES_READ_SOURCE_FILTER + "] property to continue."); .readMetadata(settings.getReadMetadata()) .filters(QueryUtils.parseFilters(settings)) .fields(StringUtils.concatenate(fields, ",")); input = queryBuilder.build(client, new ScrollReader(ScrollReaderConfigBuilder.builder(new JdkValueReader(), mapping, settings)));
Map<String, Object> metadata = (Map<String, Object>) value.get("_metadata"); String routing = (String) metadata.get("_routing"); String encodedId = StringUtils.jsonEncoding((String) kv[0]); if (StringUtils.hasText(routing)) { String encodedRouting = StringUtils.jsonEncoding(routing); entry.add(StringUtils.toUTF(String.format(routedFormat, encodedId, encodedRouting))); } else { entry.add(StringUtils.toUTF(String.format(baseFormat, encodedId)));
public static String asUTFString(byte[] content) { return asUTFString(content, 0, content.length); }
public String[] getHostNames() { String[] newLocations = new String[locations.length]; for (int i = 0; i < locations.length; i++) { newLocations[i] = StringUtils.parseIpAddress(locations[i]).ip; } return newLocations; }
public static String toJsonString(Object value) { if (value == null) { return "null"; } else if (value.getClass().equals(String.class)) { return "\"" + StringUtils.jsonEncoding(value.toString()) + "\""; } // else it's a RawJson, Boolean or Number so no escaping or quotes else { return value.toString(); } }
@SuppressWarnings({ "rawtypes", "unchecked" }) public List<String> discoverNodes() { String endpoint = "_nodes/transport"; Map<String, Map> nodes = (Map<String, Map>) get(endpoint, "nodes"); List<String> hosts = new ArrayList<String>(nodes.size()); for (Map value : nodes.values()) { String inet = (String) value.get("http_address"); if (StringUtils.hasText(inet)) { hosts.add(StringUtils.parseIpAddress(inet).toString()); } } return hosts; }
public static ByteSizeValue parseBytesSizeValue(String sValue) throws EsHadoopIllegalArgumentException { long bytes; sValue = org.elasticsearch.hadoop.util.StringUtils.deleteWhitespace(sValue);
if (QueryUtils.isExplicitlyRequested(alias.getName(), indicesOrAliases)) { if (StringUtils.hasLength(alias.getSearchRouting())) { for (String value : alias.getSearchRouting().split(",")) { routing.add(value.trim()); searchRequestBuilder.routing(StringUtils.concatenate(routing, ","));
public static boolean hasText(CharSequence sequence) { if (!hasLength(sequence)) { return false; } int length = sequence.length(); for (int i = 0; i < length; i++) { if (!Character.isWhitespace(sequence.charAt(i))) { return true; } } return false; }
public static List<String> findSimiliar(CharSequence match, Collection<String> potential) { List<String> list = new ArrayList<String>(3); // 1 switches or 1 extra char int maxDistance = 2; for (String string : potential) { int dist = levenshteinDistance(match, string, maxDistance); if (dist >= 0) { if (dist < maxDistance) { maxDistance = dist; list.clear(); list.add(string); } else if (dist == maxDistance) { list.add(string); } } } return list; }
List<String> matches = StringUtils.findSimiliar(string, similar); for (String match : matches) {
public static List<String> discoveredOrDeclaredNodes(Settings settings) { // returned the discovered nodes or, if not defined, the set nodes String discoveredNodes = settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_DISCOVERED_NODES); return (StringUtils.hasText(discoveredNodes) ? StringUtils.tokenize(discoveredNodes) : declaredNodes(settings)); }
@Override public String toString() { return StringUtils.asUTFString(bytes, offset, size); }
/** * Returns the first address in {@code locations} that is equals to a public IP of the system * @param locations The list of address (hostname:port or ip:port) to check * @return The first address in {@code locations} that is equals to a public IP of the system or null if none */ static String checkLocality(String[] locations, Log log) { try { InetAddress[] candidates = NetworkUtils.getGlobalInterfaces(); for (String address : locations) { StringUtils.IpAndPort ipAndPort = StringUtils.parseIpAddress(address); InetAddress addr = InetAddress.getByName(ipAndPort.ip); for (InetAddress candidate : candidates) { if (addr.equals(candidate)) { return address; } } } } catch (SocketException e) { if (log.isDebugEnabled()) { log.debug("Unable to retrieve the global interfaces of the system", e); } } catch (UnknownHostException e) { if (log.isDebugEnabled()) { log.debug("Unable to retrieve IP address", e); } } return null; }
private void append(StringBuilder sb, List<Object> list, Object target) { for (Object object : list) { if (object instanceof FieldExtractor) { Object field = ((FieldExtractor) object).field(target); if (field == null) { throw new EsHadoopIllegalArgumentException(String.format("Found null value for pattern element in %s", pattern)); } else if (field == NOT_FOUND) { throw new EsHadoopIllegalArgumentException(String.format("Cannot find match for %s", pattern)); } else { sb.append(StringUtils.jsonEncoding(field.toString())); } } else { sb.append(StringUtils.jsonEncoding(object.toString())); } } }