Java Code Examples for org.elasticsearch.common.Strings#delimitedListToStringArray()

The following examples show how to use org.elasticsearch.common.Strings#delimitedListToStringArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsFilter.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public static Settings filterSettings(String patterns, Settings settings) {
    String[] patternArray = Strings.delimitedListToStringArray(patterns, ",");
    Settings.Builder builder = Settings.settingsBuilder().put(settings);
    List<String> simpleMatchPatternList = new ArrayList<>();
    for (String pattern : patternArray) {
        if (Regex.isSimpleMatchPattern(pattern)) {
            simpleMatchPatternList.add(pattern);
        } else {
            builder.remove(pattern);
        }
    }
    if (!simpleMatchPatternList.isEmpty()) {
        String[] simpleMatchPatterns = simpleMatchPatternList.toArray(new String[simpleMatchPatternList.size()]);
        Iterator<Entry<String, String>> iterator = builder.internalMap().entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, String> current = iterator.next();
            if (Regex.simpleMatch(simpleMatchPatterns, current.getKey())) {
                iterator.remove();
            }
        }
    }
    return builder.build();
}
 
Example 2
Source File: MappingMetaData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public Id(String path) {
    this.path = path;
    if (path == null) {
        pathElements = Strings.EMPTY_ARRAY;
    } else {
        pathElements = Strings.delimitedListToStringArray(path, ".");
    }
}
 
Example 3
Source File: MappingMetaData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public Routing(boolean required, String path) {
    this.required = required;
    this.path = path;
    if (path == null) {
        pathElements = Strings.EMPTY_ARRAY;
    } else {
        pathElements = Strings.delimitedListToStringArray(path, ".");
    }
}
 
Example 4
Source File: MappingMetaData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public Timestamp(boolean enabled, String path, String format, String defaultTimestamp, Boolean ignoreMissing) {
    this.enabled = enabled;
    this.path = path;
    if (path == null) {
        pathElements = Strings.EMPTY_ARRAY;
    } else {
        pathElements = Strings.delimitedListToStringArray(path, ".");
    }
    this.format = format;
    this.dateTimeFormatter = Joda.forPattern(format);
    this.defaultTimestamp = defaultTimestamp;
    this.ignoreMissing = ignoreMissing;
}
 
Example 5
Source File: MappingMetaData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public ParsedVersion(String path, String versionType) {
    this.path = path;
    if (path == null) {
        this.pathElements = Strings.EMPTY_ARRAY;
        this.versionType = VersionType.INTERNAL;
    } else {
        this.versionType = VersionType.fromString(versionType);
        this.pathElements = Strings.delimitedListToStringArray(path, ".");
    }
}
 
Example 6
Source File: MappingMetaData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public ParsedVersion(String path, VersionType versionType) {
    this.path = path;
    if (path == null) {
        this.pathElements = Strings.EMPTY_ARRAY;
        this.versionType = VersionType.INTERNAL;
    } else {
        this.versionType = versionType;
        this.pathElements = Strings.delimitedListToStringArray(path, ".");
    }
}
 
Example 7
Source File: Regex.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static int flagsFromString(String flags) {
    int pFlags = 0;
    for (String s : Strings.delimitedListToStringArray(flags, "|")) {
        if (s.isEmpty()) {
            continue;
        }
        s = s.toUpperCase(Locale.ROOT);
        if ("CASE_INSENSITIVE".equals(s)) {
            pFlags |= Pattern.CASE_INSENSITIVE;
        } else if ("MULTILINE".equals(s)) {
            pFlags |= Pattern.MULTILINE;
        } else if ("DOTALL".equals(s)) {
            pFlags |= Pattern.DOTALL;
        } else if ("UNICODE_CASE".equals(s)) {
            pFlags |= Pattern.UNICODE_CASE;
        } else if ("CANON_EQ".equals(s)) {
            pFlags |= Pattern.CANON_EQ;
        } else if ("UNIX_LINES".equals(s)) {
            pFlags |= Pattern.UNIX_LINES;
        } else if ("LITERAL".equals(s)) {
            pFlags |= Pattern.LITERAL;
        } else if ("COMMENTS".equals(s)) {
            pFlags |= Pattern.COMMENTS;
        } else if ("UNICODE_CHAR_CLASS".equals(s)) {
            pFlags |= UNICODE_CHARACTER_CLASS;
        } else {
            throw new IllegalArgumentException("Unknown regex flag [" + s + "]");
        }
    }
    return pFlags;
}
 
Example 8
Source File: Regex.java    From crate with Apache License 2.0 5 votes vote down vote up
public static int flagsFromString(String flags) {
    int pFlags = 0;
    for (String s : Strings.delimitedListToStringArray(flags, "|")) {
        if (s.isEmpty()) {
            continue;
        }
        s = s.toUpperCase(Locale.ROOT);
        if ("CASE_INSENSITIVE".equals(s)) {
            pFlags |= Pattern.CASE_INSENSITIVE;
        } else if ("MULTILINE".equals(s)) {
            pFlags |= Pattern.MULTILINE;
        } else if ("DOTALL".equals(s)) {
            pFlags |= Pattern.DOTALL;
        } else if ("UNICODE_CASE".equals(s)) {
            pFlags |= Pattern.UNICODE_CASE;
        } else if ("CANON_EQ".equals(s)) {
            pFlags |= Pattern.CANON_EQ;
        } else if ("UNIX_LINES".equals(s)) {
            pFlags |= Pattern.UNIX_LINES;
        } else if ("LITERAL".equals(s)) {
            pFlags |= Pattern.LITERAL;
        } else if ("COMMENTS".equals(s)) {
            pFlags |= Pattern.COMMENTS;
        } else if (("UNICODE_CHAR_CLASS".equals(s)) || ("UNICODE_CHARACTER_CLASS".equals(s))) {
            pFlags |= UNICODE_CHARACTER_CLASS;
        } else {
            throw new IllegalArgumentException("Unknown regex flag [" + s + "]");
        }
    }
    return pFlags;
}