当前位置: 首页>>代码示例>>Java>>正文


Java Strings.splitStringToArray方法代码示例

本文整理汇总了Java中org.elasticsearch.common.Strings.splitStringToArray方法的典型用法代码示例。如果您正苦于以下问题:Java Strings.splitStringToArray方法的具体用法?Java Strings.splitStringToArray怎么用?Java Strings.splitStringToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.common.Strings的用法示例。


在下文中一共展示了Strings.splitStringToArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildFromString

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
/**
 * Supports just passing fpp, as in "0.01", and also ranges, like "50k=0.01,1m=0.05". If
 * its null, returns {@link #buildDefault()}.
 */
public static Factory buildFromString(@Nullable String config) {
    if (config == null) {
        return buildDefault();
    }
    String[] sEntries = Strings.splitStringToArray(config, ',');
    if (sEntries.length == 0) {
        if (config.length() > 0) {
            return new Factory(new Entry[]{new Entry(0, Double.parseDouble(config))});
        }
        return buildDefault();
    }
    Entry[] entries = new Entry[sEntries.length];
    for (int i = 0; i < sEntries.length; i++) {
        int index = sEntries[i].indexOf('=');
        entries[i] = new Entry(
                (int) SizeValue.parseSizeValue(sEntries[i].substring(0, index).trim()).singles(),
                Double.parseDouble(sEntries[i].substring(index + 1).trim())
        );
    }
    return new Factory(entries);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:BloomFilter.java

示例2: fetch

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
/**
 * Fetches the Shape with the given ID in the given type and index.
 *
 * @param getRequest GetRequest containing index, type and id
 * @param path      Name or path of the field in the Shape Document where the Shape itself is located
 * @return Shape with the given ID
 * @throws IOException Can be thrown while parsing the Shape Document and extracting the Shape
 */
public ShapeBuilder fetch(GetRequest getRequest,String path) throws IOException {
    getRequest.preference("_local");
    getRequest.operationThreaded(false);
    GetResponse response = client.get(getRequest).actionGet();
    if (!response.isExists()) {
        throw new IllegalArgumentException("Shape with ID [" + getRequest.id() + "] in type [" + getRequest.type() + "] not found");
    }

    String[] pathElements = Strings.splitStringToArray(path, '.');
    int currentPathSlot = 0;

    XContentParser parser = null;
    try {
        parser = XContentHelper.createParser(response.getSourceAsBytesRef());
        XContentParser.Token currentToken;
        while ((currentToken = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
            if (currentToken == XContentParser.Token.FIELD_NAME) {
                if (pathElements[currentPathSlot].equals(parser.currentName())) {
                    parser.nextToken();
                    if (++currentPathSlot == pathElements.length) {
                        return ShapeBuilder.parse(parser);
                    }
                } else {
                    parser.nextToken();
                    parser.skipChildren();
                }
            }
        }
        throw new IllegalStateException("Shape with name [" + getRequest.id() + "] found but missing " + path + " field");
    } finally {
        if (parser != null) {
            parser.close();
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:44,代码来源:ShapeFetchService.java

示例3: loadFromDelimitedString

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
public Builder loadFromDelimitedString(String value, char delimiter) {
    String[] values = Strings.splitStringToArray(value, delimiter);
    for (String s : values) {
        int index = s.indexOf('=');
        if (index == -1) {
            throw new IllegalArgumentException("value [" + s + "] for settings loaded with delimiter [" + delimiter + "] is malformed, missing =");
        }
        map.put(s.substring(0, index), s.substring(index + 1));
    }
    return this;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:Settings.java

示例4: extractRawValues

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
/**
 * Extracts raw values (string, int, and so on) based on the path provided returning all of them
 * as a single list.
 */
public static List<Object> extractRawValues(String path, Map<String, Object> map) {
    List<Object> values = new ArrayList<>();
    String[] pathElements = Strings.splitStringToArray(path, '.');
    if (pathElements.length == 0) {
        return values;
    }
    extractRawValues(values, map, pathElements, 0);
    return values;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:XContentMapValues.java

示例5: extractValue

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
public static Object extractValue(String path, Map<String, Object> map) {
    String[] pathElements = Strings.splitStringToArray(path, '.');
    if (pathElements.length == 0) {
        return null;
    }
    return extractValue(pathElements, 0, map);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:XContentMapValues.java

示例6: insert

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
public void insert(String path, T value) {
    String[] strings = Strings.splitStringToArray(path, separator);
    if (strings.length == 0) {
        rootValue = value;
        return;
    }
    int index = 0;
    // supports initial delimiter.
    if (strings.length > 0 && strings[0].isEmpty()) {
        index = 1;
    }
    root.insert(strings, index, value);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:PathTrie.java

示例7: retrieve

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
public T retrieve(String path, Map<String, String> params) {
    if (path.length() == 0) {
        return rootValue;
    }
    String[] strings = Strings.splitStringToArray(path, separator);
    if (strings.length == 0) {
        return rootValue;
    }
    int index = 0;
    // supports initial delimiter.
    if (strings.length > 0 && strings[0].isEmpty()) {
        index = 1;
    }
    return root.retrieve(strings, index, params);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:PathTrie.java


注:本文中的org.elasticsearch.common.Strings.splitStringToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。