Rabbit-R1/android (non root)/java/sources/com/google/common/escape/ArrayBasedUnicodeEscaper.java
2024-05-21 17:08:36 -04:00

82 lines
2.9 KiB
Java

package com.google.common.escape;
import com.google.common.base.Preconditions;
import java.util.Map;
import javax.annotation.CheckForNull;
import kotlin.jvm.internal.CharCompanionObject;
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.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;
@CheckForNull
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) {
Preconditions.checkNotNull(arrayBasedEscaperMap);
char[][] replacementArray = arrayBasedEscaperMap.getReplacementArray();
this.replacements = replacementArray;
this.replacementsLength = replacementArray.length;
if (i2 < i) {
i2 = -1;
i = Integer.MAX_VALUE;
}
this.safeMin = i;
this.safeMax = i2;
if (i >= 55296) {
this.safeMinChar = CharCompanionObject.MAX_VALUE;
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
@CheckForNull
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;
}
}