本文整理匯總了Java中org.elasticsearch.common.Strings.hasText方法的典型用法代碼示例。如果您正苦於以下問題:Java Strings.hasText方法的具體用法?Java Strings.hasText怎麽用?Java Strings.hasText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.common.Strings
的用法示例。
在下文中一共展示了Strings.hasText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validHeaderValue
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
/**
* This does a very basic pass at validating that a header's value contains only expected characters according to RFC-5987, and those
* that it references.
* <p>
* https://tools.ietf.org/html/rfc5987
* <p>
* This is only expected to be used for assertions. The idea is that only readable US-ASCII characters are expected; the rest must be
* encoded with percent encoding, which makes checking for a valid character range very simple.
*
* @param value The header value to check
* @return {@code true} if the {@code value} is not obviously wrong.
*/
public static boolean validHeaderValue(String value) {
if (Strings.hasText(value) == false) {
return false;
}
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
// 32 = ' ' (31 = unit separator); 126 = '~' (127 = DEL)
if (c < 32 || c > 126) {
return false;
}
}
return true;
}
示例2: nodeSettings
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
@Override
protected Settings nodeSettings(int nodeOrdinal) {
Settings.Builder settings = Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir());
// if explicit, just load it and don't load from env
try {
if (Strings.hasText(System.getProperty("tests.config"))) {
try {
settings.loadFromPath(PathUtils.get(System.getProperty("tests.config")));
} catch (IOException e) {
throw new IllegalArgumentException("could not load aws tests config", e);
}
} else {
throw new IllegalStateException("to run integration tests, you need to set -Dtests.thirdparty=true and -Dtests.config=/path/to/elasticsearch.yml");
}
} catch (SettingsException exception) {
throw new IllegalStateException("your test configuration file is incorrect: " + System.getProperty("tests.config"), exception);
}
return settings.build();
}
示例3: readSettingsFromFile
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
/**
* Read settings from file when running integration tests with ThirdParty annotation.
* elasticsearch.yml file path has to be set with -Dtests.config=/path/to/elasticsearch.yml.
* @return Settings from elasticsearch.yml integration test file (for 3rd party tests)
*/
public static Settings readSettingsFromFile() {
Settings.Builder settings = Settings.builder();
// if explicit, just load it and don't load from env
try {
if (Strings.hasText(System.getProperty("tests.config"))) {
try {
settings.loadFromPath(PathUtils.get((System.getProperty("tests.config"))));
} catch (IOException e) {
throw new IllegalArgumentException("could not load azure tests config", e);
}
} else {
throw new IllegalStateException("to run integration tests, you need to set -Dtests.thirdparty=true and " +
"-Dtests.config=/path/to/elasticsearch.yml");
}
} catch (SettingsException exception) {
throw new IllegalStateException("your test configuration file is incorrect: " + System.getProperty("tests.config"), exception);
}
return settings.build();
}
示例4: nodeSettings
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
@Override
protected Settings nodeSettings(int nodeOrdinal) {
Settings.Builder settings = Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
.put("cloud.aws.test.random", randomInt())
.put("cloud.aws.test.write_failures", 0.1)
.put("cloud.aws.test.read_failures", 0.1);
// if explicit, just load it and don't load from env
try {
if (Strings.hasText(System.getProperty("tests.config"))) {
try {
settings.loadFromPath(PathUtils.get(System.getProperty("tests.config")));
} catch (IOException e) {
throw new IllegalArgumentException("could not load aws tests config", e);
}
} else {
throw new IllegalStateException("to run integration tests, you need to set -Dtests.thirdparty=true and -Dtests.config=/path/to/elasticsearch.yml");
}
} catch (SettingsException exception) {
throw new IllegalStateException("your test configuration file is incorrect: " + System.getProperty("tests.config"), exception);
}
return settings.build();
}
示例5: splitAndValidatePath
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
private static String[] splitAndValidatePath(String fullFieldPath) {
String[] parts = fullFieldPath.split("\\.");
for (String part : parts) {
if (Strings.hasText(part) == false) {
throw new IllegalArgumentException(
"object field starting or ending with a [.] makes object resolution ambiguous: [" + fullFieldPath + "]");
}
}
return parts;
}
示例6: validateAlias
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
/**
* Validate a proposed alias.
*/
public void validateAlias(String alias, String index, @Nullable String indexRouting, Function<String, IndexMetaData> indexLookup) {
validateAliasStandalone(alias, indexRouting);
if (!Strings.hasText(index)) {
throw new IllegalArgumentException("index name is required");
}
IndexMetaData indexNamedSameAsAlias = indexLookup.apply(alias);
if (indexNamedSameAsAlias != null) {
throw new InvalidAliasNameException(indexNamedSameAsAlias.getIndex(), alias, "an index exists with the same name as the alias");
}
}
示例7: validateAliasStandalone
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
void validateAliasStandalone(String alias, String indexRouting) {
if (!Strings.hasText(alias)) {
throw new IllegalArgumentException("alias name is required");
}
MetaDataCreateIndexService.validateIndexOrAliasName(alias, InvalidAliasNameException::new);
if (indexRouting != null && indexRouting.indexOf(',') != -1) {
throw new IllegalArgumentException("alias [" + alias + "] has several index routing values associated with it");
}
}
示例8: Add
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
/**
* Build the operation.
*/
public Add(String index, String alias, @Nullable String filter, @Nullable String indexRouting, @Nullable String searchRouting) {
super(index);
if (false == Strings.hasText(alias)) {
throw new IllegalArgumentException("[alias] is required");
}
this.alias = alias;
this.filter = filter;
this.indexRouting = indexRouting;
this.searchRouting = searchRouting;
}
示例9: Remove
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
/**
* Build the operation.
*/
public Remove(String index, String alias) {
super(index);
if (false == Strings.hasText(alias)) {
throw new IllegalArgumentException("[alias] is required");
}
this.alias = alias;
}
示例10: validate
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
@Override
public ActionRequestValidationException validate() {
ActionRequestValidationException validationException = null;
if (names == null) {
validationException = addValidationError("names is null or empty", validationException);
} else {
for (String name : names) {
if (name == null || !Strings.hasText(name)) {
validationException = addValidationError("name is missing", validationException);
}
}
}
return validationException;
}
示例11: hasIndexRequestsWithPipelines
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
/**
* @return Whether this bulk request contains index request with an ingest pipeline enabled.
*/
public boolean hasIndexRequestsWithPipelines() {
for (DocWriteRequest actionRequest : requests) {
if (actionRequest instanceof IndexRequest) {
IndexRequest indexRequest = (IndexRequest) actionRequest;
if (Strings.hasText(indexRequest.getPipeline())) {
return true;
}
}
}
return false;
}
示例12: getSetting
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
/**
* Get a given setting from the repository settings, throwing a {@link RepositoryException} if the setting does not exist or is empty.
*/
static <T> T getSetting(Setting<T> setting, RepositoryMetaData metadata) {
T value = setting.get(metadata.settings());
if (value == null) {
throw new RepositoryException(metadata.name(), "Setting [" + setting.getKey() + "] is not defined for repository");
}
if ((value instanceof String) && (Strings.hasText((String) value)) == false) {
throw new RepositoryException(metadata.name(), "Setting [" + setting.getKey() + "] is empty for repository");
}
return value;
}
示例13: doStart
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
@Override
protected void doStart() {
String uriSetting = getMetadata().settings().get("uri");
if (Strings.hasText(uriSetting) == false) {
throw new IllegalArgumentException("No 'uri' defined for hdfs snapshot/restore");
}
URI uri = URI.create(uriSetting);
if ("hdfs".equalsIgnoreCase(uri.getScheme()) == false) {
throw new IllegalArgumentException(
String.format(Locale.ROOT, "Invalid scheme [%s] specified in uri [%s]; only 'hdfs' uri allowed for hdfs snapshot/restore", uri.getScheme(), uriSetting));
}
if (Strings.hasLength(uri.getPath()) && uri.getPath().equals("/") == false) {
throw new IllegalArgumentException(String.format(Locale.ROOT,
"Use 'path' option to specify a path [%s], not the uri [%s] for hdfs snapshot/restore", uri.getPath(), uriSetting));
}
String pathSetting = getMetadata().settings().get("path");
// get configuration
if (pathSetting == null) {
throw new IllegalArgumentException("No 'path' defined for hdfs snapshot/restore");
}
int bufferSize = getMetadata().settings().getAsBytesSize("buffer_size", DEFAULT_BUFFER_SIZE).bytesAsInt();
try {
// initialize our filecontext
SpecialPermission.check();
FileContext fileContext = AccessController.doPrivileged((PrivilegedAction<FileContext>)
() -> createContext(uri, getMetadata().settings()));
blobStore = new HdfsBlobStore(fileContext, pathSetting, bufferSize);
logger.debug("Using file-system [{}] for URI [{}], path [{}]", fileContext.getDefaultFileSystem(), fileContext.getDefaultFileSystem().getUri(), pathSetting);
} catch (IOException e) {
throw new ElasticsearchGenerationException(String.format(Locale.ROOT, "Cannot create HDFS repository for uri [%s]", uri), e);
}
super.doStart();
}
示例14: validateAliasStandalone
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
private void validateAliasStandalone(String alias, String indexRouting) {
if (!Strings.hasText(alias)) {
throw new IllegalArgumentException("alias name is required");
}
if (indexRouting != null && indexRouting.indexOf(',') != -1) {
throw new IllegalArgumentException("alias [" + alias + "] has several index routing values associated with it");
}
}
示例15: validate
import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
@Override
public ActionRequestValidationException validate() {
ActionRequestValidationException validationException = null;
if (allAliasActions.isEmpty()) {
return addValidationError("Must specify at least one alias action", validationException);
}
for (AliasActions aliasAction : allAliasActions) {
if (CollectionUtils.isEmpty(aliasAction.aliases)) {
validationException = addValidationError("Alias action [" + aliasAction.actionType().name().toLowerCase(Locale.ENGLISH)
+ "]: Property [alias/aliases] is either missing or null", validationException);
} else {
for (String alias : aliasAction.aliases) {
if (!Strings.hasText(alias)) {
validationException = addValidationError("Alias action [" + aliasAction.actionType().name().toLowerCase(Locale.ENGLISH)
+ "]: [alias/aliases] may not be empty string", validationException);
}
}
}
if (CollectionUtils.isEmpty(aliasAction.indices)) {
validationException = addValidationError("Alias action [" + aliasAction.actionType().name().toLowerCase(Locale.ENGLISH)
+ "]: Property [index/indices] is either missing or null", validationException);
} else {
for (String index : aliasAction.indices) {
if (!Strings.hasText(index)) {
validationException = addValidationError("Alias action [" + aliasAction.actionType().name().toLowerCase(Locale.ENGLISH)
+ "]: [index/indices] may not be empty string", validationException);
}
}
}
}
return validationException;
}