mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Replace Strings.startsWithIgnoreCase()
`Strings.startsWithIgnoreCase()` has been removed in elasticsearch 1.4 ans master. See https://github.com/elasticsearch/elasticsearch/pull/7428 Closes #35.
This commit is contained in:
parent
f5d35004a0
commit
29aae071c4
@ -21,7 +21,6 @@ package org.elasticsearch.repositories.azure;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.cloud.azure.AzureStorageService;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.blobstore.BlobMetaData;
|
||||
import org.elasticsearch.common.blobstore.support.PlainBlobMetaData;
|
||||
import org.elasticsearch.common.collect.ImmutableMap;
|
||||
@ -33,6 +32,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -85,7 +85,7 @@ public class AzureStorageServiceMock extends AbstractLifecycleComponent<AzureSto
|
||||
public ImmutableMap<String, BlobMetaData> listBlobsByPrefix(String container, String keyPath, String prefix) {
|
||||
ImmutableMap.Builder<String, BlobMetaData> blobsBuilder = ImmutableMap.builder();
|
||||
for (String blobName : blobs.keySet()) {
|
||||
if (Strings.startsWithIgnoreCase(blobName, prefix)) {
|
||||
if (startsWithIgnoreCase(blobName, prefix)) {
|
||||
blobsBuilder.put(blobName, new PlainBlobMetaData(blobName, blobs.get(blobName).length));
|
||||
}
|
||||
}
|
||||
@ -123,4 +123,27 @@ public class AzureStorageServiceMock extends AbstractLifecycleComponent<AzureSto
|
||||
@Override
|
||||
protected void doClose() throws ElasticsearchException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the given String starts with the specified prefix,
|
||||
* ignoring upper/lower case.
|
||||
*
|
||||
* @param str the String to check
|
||||
* @param prefix the prefix to look for
|
||||
* @see java.lang.String#startsWith
|
||||
*/
|
||||
public static boolean startsWithIgnoreCase(String str, String prefix) {
|
||||
if (str == null || prefix == null) {
|
||||
return false;
|
||||
}
|
||||
if (str.startsWith(prefix)) {
|
||||
return true;
|
||||
}
|
||||
if (str.length() < prefix.length()) {
|
||||
return false;
|
||||
}
|
||||
String lcStr = str.substring(0, prefix.length()).toLowerCase(Locale.ROOT);
|
||||
String lcPrefix = prefix.toLowerCase(Locale.ROOT);
|
||||
return lcStr.equals(lcPrefix);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user