mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-14 18:07:16 +01:00
132 lines
3.8 KiB
Java
132 lines
3.8 KiB
Java
package com.amazonaws.util;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigInteger;
|
|
import java.nio.ByteBuffer;
|
|
import java.nio.charset.Charset;
|
|
import java.util.Date;
|
|
import java.util.Locale;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes6.dex */
|
|
public class StringUtils {
|
|
private static final String DEFAULT_ENCODING = "UTF-8";
|
|
public static final Charset UTF8 = Charset.forName("UTF-8");
|
|
|
|
public static String fromBigDecimal(BigDecimal bigDecimal) {
|
|
return bigDecimal.toString();
|
|
}
|
|
|
|
public static String fromBigInteger(BigInteger bigInteger) {
|
|
return bigInteger.toString();
|
|
}
|
|
|
|
public static String fromBoolean(Boolean bool) {
|
|
return Boolean.toString(bool.booleanValue());
|
|
}
|
|
|
|
public static String fromByte(Byte b) {
|
|
return Byte.toString(b.byteValue());
|
|
}
|
|
|
|
public static String fromByteBuffer(ByteBuffer byteBuffer) {
|
|
if (byteBuffer.hasArray()) {
|
|
return Base64.encodeAsString(byteBuffer.array());
|
|
}
|
|
byte[] bArr = new byte[byteBuffer.limit()];
|
|
byteBuffer.get(bArr);
|
|
return Base64.encodeAsString(bArr);
|
|
}
|
|
|
|
public static String fromDate(Date date) {
|
|
return DateUtils.formatISO8601Date(date);
|
|
}
|
|
|
|
public static String fromDouble(Double d) {
|
|
return Double.toString(d.doubleValue());
|
|
}
|
|
|
|
public static String fromFloat(Float f) {
|
|
return Float.toString(f.floatValue());
|
|
}
|
|
|
|
public static String fromInteger(Integer num) {
|
|
return Integer.toString(num.intValue());
|
|
}
|
|
|
|
public static String fromLong(Long l) {
|
|
return Long.toString(l.longValue());
|
|
}
|
|
|
|
public static boolean isBlank(CharSequence charSequence) {
|
|
int length;
|
|
if (charSequence != null && (length = charSequence.length()) != 0) {
|
|
for (int i = 0; i < length; i++) {
|
|
if (!Character.isWhitespace(charSequence.charAt(i))) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static String join(String str, String... strArr) {
|
|
StringBuilder sb = new StringBuilder();
|
|
for (int i = 0; i < strArr.length; i++) {
|
|
sb.append(strArr[i]);
|
|
if (i < strArr.length - 1) {
|
|
sb.append(str);
|
|
}
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public static String lowerCase(String str) {
|
|
if (str == null) {
|
|
return null;
|
|
}
|
|
return str.isEmpty() ? "" : str.toLowerCase(Locale.ENGLISH);
|
|
}
|
|
|
|
public static String replace(String str, String str2, String str3) {
|
|
StringBuffer stringBuffer = new StringBuffer(str.length());
|
|
stringBuffer.append(str);
|
|
int indexOf = stringBuffer.indexOf(str2);
|
|
while (indexOf != -1) {
|
|
stringBuffer = stringBuffer.replace(indexOf, str2.length() + indexOf, str3);
|
|
indexOf = stringBuffer.indexOf(str2);
|
|
}
|
|
return stringBuffer.toString();
|
|
}
|
|
|
|
public static BigDecimal toBigDecimal(String str) {
|
|
return new BigDecimal(str);
|
|
}
|
|
|
|
public static BigInteger toBigInteger(String str) {
|
|
return new BigInteger(str);
|
|
}
|
|
|
|
public static Boolean toBoolean(StringBuilder sb) {
|
|
return Boolean.valueOf(Boolean.getBoolean(sb.toString()));
|
|
}
|
|
|
|
public static Integer toInteger(StringBuilder sb) {
|
|
return Integer.valueOf(Integer.parseInt(sb.toString()));
|
|
}
|
|
|
|
public static String toString(StringBuilder sb) {
|
|
return sb.toString();
|
|
}
|
|
|
|
public static String upperCase(String str) {
|
|
if (str == null) {
|
|
return null;
|
|
}
|
|
return str.isEmpty() ? "" : str.toUpperCase(Locale.ENGLISH);
|
|
}
|
|
|
|
public static String fromString(String str) {
|
|
return str;
|
|
}
|
|
}
|