本文整理了Java中com.amazonaws.util.StringUtils.isNullOrEmpty()
方法的一些代码示例,展示了StringUtils.isNullOrEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.isNullOrEmpty()
方法的具体详情如下:
包路径:com.amazonaws.util.StringUtils
类名称:StringUtils
方法名:isNullOrEmpty
暂无
代码示例来源:origin: aws/aws-sdk-java
/**
* @return true if the given value is non-null and non-empty
*/
public static boolean hasValue(String str) {
return !isNullOrEmpty(str);
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Converts a given String to lower case with Locale.ENGLISH
*
* @param str the string to be converted to lower case
* @return the lower case of string, or itself if string is null/empty
*/
public static String lowerCase(String str) {
if(isNullOrEmpty(str)) {
return str;
}
return str.toLowerCase(LOCALE_ENGLISH);
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Converts a given String to upper case with Locale.ENGLISH
*
* @param str the string to be converted to upper case
* @return the upper case of string, or itself if string is null/empty
*/
public static String upperCase(String str) {
if(isNullOrEmpty(str)) {
return str;
}
return str.toUpperCase(LOCALE_ENGLISH);
}
代码示例来源:origin: aws/aws-sdk-java
/**
* <p> Asserts that the specified parameter value is neither <code>empty</code> nor null, and if
* it is, throws a <code>SdkClientException</code> with the specified error message. </p>
*
* @param parameterValue The parameter value being checked.
* @param errorMessage The error message to include in the SdkClientException if the
* specified parameter value is empty.
*/
private void assertParameterNotEmpty(String parameterValue, String errorMessage) {
if (StringUtils.isNullOrEmpty(parameterValue)) {
throw new SdkClientException(errorMessage);
}
}
代码示例来源:origin: aws/aws-sdk-java
private void parseNonProxyHosts(String nonProxyHosts) {
if (!StringUtils.isNullOrEmpty(nonProxyHosts)) {
String[] hosts = nonProxyHosts.split("\\|");
hostPatterns = new String[hosts.length];
for (int i = 0; i < hosts.length; ++i) {
hostPatterns[i] = hosts[i].toLowerCase().replace("*", ".*?");
}
}
}
代码示例来源:origin: apache/nifi
public static void notEmpty(String in, String fieldName) {
if (StringUtils.isNullOrEmpty(in)) {
throw new IllegalArgumentException(String.format("%s cannot be empty", fieldName));
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Replace all the labels in host with %s symbols and collect the input shape member names into a list
*/
private void replaceHostLabelsWithStringSpecifier(String hostExpression) {
if (StringUtils.isNullOrEmpty(hostExpression)) {
throw new IllegalArgumentException("Given host prefix is either null or empty");
}
Matcher matcher = PATTERN.matcher(hostExpression);
while (matcher.find()) {
String matched = matcher.group(1);
c2jNames.add(matched);
hostWithStringSpecifier = hostWithStringSpecifier.replaceFirst("\\{" + matched + "}", "%s");
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Throw exception if timestamp is provided for non-json protocol
*/
private void validateTimestampProtocol(String protocolString, String timestampFormat, String shape2) {
if (!StringUtils.isNullOrEmpty(timestampFormat) && isNonJsonProtocol(protocolString)) {
throw new IllegalArgumentException(String.format(
"Shape %s has timestamp format provided. Timestamp format for requests is not supported for xml, query or ec2 "
+ "protocol",
shape2));
}
}
代码示例来源:origin: aws/aws-sdk-java
public static Date parseRfc822Date(String dateString) {
if (StringUtils.isNullOrEmpty(dateString)) {
return null;
}
return DateUtils.parseRFC822Date(dateString);
}
代码示例来源:origin: aws/aws-sdk-java
private static boolean hasServingRegionHeader(HttpResponse response) {
return !StringUtils.isNullOrEmpty(getServingRegionHeader(response));
}
代码示例来源:origin: aws/aws-sdk-java
/**
* TODO The order would make more sense as System Property, Environment Variable, Default
* Profile name but we have to keep the current order for backwards compatiblity. Consider
* changing this in a future major version.
*/
public final String loadProfileName() {
final String profileEnvVarOverride = getEnvProfileName();
if (!StringUtils.isNullOrEmpty(profileEnvVarOverride)) {
return profileEnvVarOverride;
} else {
final String profileSysPropOverride = getSysPropertyProfileName();
if (!StringUtils.isNullOrEmpty(profileSysPropOverride)) {
return profileSysPropOverride;
} else {
return DEFAULT_PROFILE_NAME;
}
}
}
代码示例来源:origin: aws/aws-sdk-java
@Override
public AWSCredentials getCredentials() {
String accessKey = StringUtils.trim(System.getProperty(ACCESS_KEY_SYSTEM_PROPERTY));
String secretKey = StringUtils.trim(System.getProperty(SECRET_KEY_SYSTEM_PROPERTY));
String sessionToken = StringUtils.trim(System.getProperty(SESSION_TOKEN_SYSTEM_PROPERTY));
if (StringUtils.isNullOrEmpty(accessKey) || StringUtils.isNullOrEmpty(secretKey)) {
throw new SdkClientException(
"Unable to load AWS credentials from Java system "
+ "properties (" + ACCESS_KEY_SYSTEM_PROPERTY + " and "
+ SECRET_KEY_SYSTEM_PROPERTY + ")");
}
if (StringUtils.isNullOrEmpty(sessionToken)) {
return new BasicAWSCredentials(accessKey, secretKey);
} else {
return new BasicSessionCredentials(accessKey, secretKey, sessionToken);
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Asserts the string is not null and not empty, reporting to {@link ProblemReporter} with this context if it is.
*
* @param propertyValue Value to assert on.
* @param propertyName Name of property.
*/
public void assertStringNotEmpty(String propertyValue, String propertyName) {
if (StringUtils.isNullOrEmpty(propertyValue)) {
problemReporter.report(new Problem(this, String.format("%s is a required property.", propertyName)));
}
}
代码示例来源:origin: aws/aws-sdk-java
public static JavaVersion parseJavaVersion(final String fullVersionString) {
if (!StringUtils.isNullOrEmpty(fullVersionString)) {
final Matcher matcher = VERSION_REGEX.matcher(fullVersionString);
if (matcher.matches()) {
final Integer majorVersionFamily = NumberUtils.tryParseInt(matcher.group(1));
final Integer majorVersion = NumberUtils.tryParseInt(matcher.group(2));
final Integer maintenanceNumber = NumberUtils.tryParseInt(matcher.group(3));
final Integer updateNumber = NumberUtils.tryParseInt(matcher.group(4));
return new JavaVersion(majorVersionFamily, majorVersion, maintenanceNumber, updateNumber);
}
}
return JavaVersion.UNKNOWN;
}
代码示例来源:origin: aws/aws-sdk-java
private static String uriFrom(Request<?> sdkRequest) {
StringBuilder uriBuilder = new StringBuilder(sdkRequest.getEndpoint().toString());
if (!StringUtils.isNullOrEmpty(sdkRequest.getResourcePath())) {
uriBuilder.append(sdkRequest.getResourcePath());
}
QueryStringEncoder encoder = new QueryStringEncoder(uriBuilder.toString());
for (Map.Entry<String, List<String>> param : sdkRequest.getParameters().entrySet()) {
for (String value : param.getValue()) {
encoder.addParam(param.getKey(), value);
}
}
return encoder.toString();
}
代码示例来源:origin: aws/aws-sdk-java
/**
* @param value Raw string representing value of enum
* @return HttpMethodName enum or null if value is not present.
* @throws IllegalArgumentException If value does not represent a known enum value.
*/
public static HttpMethodName fromValue(String value) {
if (StringUtils.isNullOrEmpty(value)) {
return null;
}
final String upperCaseValue = StringUtils.upperCase(value);
for (HttpMethodName httpMethodName : values()) {
if (httpMethodName.name().equals(upperCaseValue)) {
return httpMethodName;
}
}
throw new IllegalArgumentException("Unsupported HTTP method name " + value);
}
代码示例来源:origin: aws/aws-sdk-java
@Override
public Boolean endpointDiscoveryEnabled() {
Boolean endpointDiscoveryEnabled = null;
File configFile = locationProvider.getLocation();
if (configFile != null && configFile.exists()) {
BasicProfile profile = loadProfile(configFile);
if (profile != null && !StringUtils.isNullOrEmpty(profile.getEndpointDiscovery())) {
try {
endpointDiscoveryEnabled = Boolean.parseBoolean(profile.getEndpointDiscovery());
} catch (Exception e) {
throw new RuntimeException("Unable to parse value for " + ProfileKeyConstants.ENDPOINT_DISCOVERY);
}
}
}
return endpointDiscoveryEnabled;
}
代码示例来源:origin: aws/aws-sdk-java
@Override
public String getRegion() throws SdkClientException {
File configFile = locationProvider.getLocation();
if (configFile != null && configFile.exists()) {
BasicProfile profile = loadProfile(configFile);
if (profile != null && !StringUtils.isNullOrEmpty(profile.getRegion())) {
return profile.getRegion();
}
}
return null;
}
代码示例来源:origin: aws/aws-sdk-java
@Override
public AmazonServiceException handle(HttpResponse errorResponse) throws Exception {
AmazonServiceException ase = createAse(errorResponse);
if (ase == null) {
throw new SdkClientException("Unable to unmarshall error response from service");
}
ase.setHttpHeaders(errorResponse.getHeaders());
if (StringUtils.isNullOrEmpty(ase.getErrorCode())) {
ase.setErrorCode(errorResponse.getStatusCode() + " " + errorResponse.getStatusText());
}
return ase;
}
代码示例来源:origin: apache/ignite
/**
* Initializing the IP finder.
*/
private void initClients() {
if (credsProvider == null || isNullOrEmpty(loadBalancerName) || isNullOrEmpty(region))
throw new IgniteSpiException("One or more configuration parameters are invalid [setCredentialsProvider=" +
credsProvider + ", setRegion=" + region + ", setLoadBalancerName=" +
loadBalancerName + "]");
if (amazonEC2Client == null)
amazonEC2Client = AmazonEC2ClientBuilder.standard().withRegion(region).withCredentials(credsProvider)
.build();
if (amazonELBClient == null)
amazonELBClient = AmazonElasticLoadBalancingClientBuilder.standard().withRegion(region)
.withCredentials(credsProvider).build();
}
内容来源于网络,如有侵权,请联系作者删除!