what-the-bank/sources/com/google/common/escape/ArrayBasedUnicodeEscaper.java

81 lines
2.8 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.escape;
import com.google.common.base.Preconditions;
import java.util.Map;
/* loaded from: classes2.dex */
public abstract class ArrayBasedUnicodeEscaper extends UnicodeEscaper {
private final char[][] replacements;
private final int replacementsLength;
private final int safeMax;
private final char safeMaxChar;
private final int safeMin;
private final char safeMinChar;
protected abstract char[] escapeUnsafe(int i);
protected ArrayBasedUnicodeEscaper(Map<Character, String> map, int i, int i2, String str) {
this(ArrayBasedEscaperMap.create(map), i, i2, str);
}
protected ArrayBasedUnicodeEscaper(ArrayBasedEscaperMap arrayBasedEscaperMap, int i, int i2, String str) {
int i3;
Preconditions.checkNotNull(arrayBasedEscaperMap);
char[][] replacementArray = arrayBasedEscaperMap.getReplacementArray();
this.replacements = replacementArray;
this.replacementsLength = replacementArray.length;
if (i2 < i) {
i2 = -1;
i3 = Integer.MAX_VALUE;
} else {
i3 = i;
}
this.safeMin = i3;
this.safeMax = i2;
if (i3 >= 55296) {
this.safeMinChar = (char) 65535;
this.safeMaxChar = (char) 0;
} else {
this.safeMinChar = (char) i;
this.safeMaxChar = (char) Math.min(i2, 55295);
}
}
@Override // com.google.common.escape.UnicodeEscaper, com.google.common.escape.Escaper
public final String escape(String str) {
Preconditions.checkNotNull(str);
for (int i = 0; i < str.length(); i++) {
char charAt = str.charAt(i);
if ((charAt < this.replacementsLength && this.replacements[charAt] != null) || charAt > this.safeMaxChar || charAt < this.safeMinChar) {
return escapeSlow(str, i);
}
}
return str;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.google.common.escape.UnicodeEscaper
public final char[] escape(int i) {
char[] cArr;
if (i < this.replacementsLength && (cArr = this.replacements[i]) != null) {
return cArr;
}
if (i < this.safeMin || i > this.safeMax) {
return escapeUnsafe(i);
}
return null;
}
@Override // com.google.common.escape.UnicodeEscaper
protected final int nextEscapeIndex(CharSequence charSequence, int i, int i2) {
while (i < i2) {
char charAt = charSequence.charAt(i);
if ((charAt < this.replacementsLength && this.replacements[charAt] != null) || charAt > this.safeMaxChar || charAt < this.safeMinChar) {
break;
}
i++;
}
return i;
}
}