當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。