58 lines
2.0 KiB
Java
58 lines
2.0 KiB
Java
|
package com.google.common.escape;
|
||
|
|
||
|
import com.google.common.base.Preconditions;
|
||
|
import java.util.Map;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public abstract class ArrayBasedCharEscaper extends CharEscaper {
|
||
|
private final char[][] replacements;
|
||
|
private final int replacementsLength;
|
||
|
private final char safeMax;
|
||
|
private final char safeMin;
|
||
|
|
||
|
protected abstract char[] escapeUnsafe(char c);
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public ArrayBasedCharEscaper(Map<Character, String> map, char c, char c2) {
|
||
|
this(ArrayBasedEscaperMap.create(map), c, c2);
|
||
|
}
|
||
|
|
||
|
protected ArrayBasedCharEscaper(ArrayBasedEscaperMap arrayBasedEscaperMap, char c, char c2) {
|
||
|
Preconditions.checkNotNull(arrayBasedEscaperMap);
|
||
|
char[][] replacementArray = arrayBasedEscaperMap.getReplacementArray();
|
||
|
this.replacements = replacementArray;
|
||
|
this.replacementsLength = replacementArray.length;
|
||
|
if (c2 < c) {
|
||
|
c2 = 0;
|
||
|
c = 65535;
|
||
|
}
|
||
|
this.safeMin = c;
|
||
|
this.safeMax = c2;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.escape.CharEscaper, 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.safeMax || charAt < this.safeMin) {
|
||
|
return escapeSlow(str, i);
|
||
|
}
|
||
|
}
|
||
|
return str;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
@Override // com.google.common.escape.CharEscaper
|
||
|
public final char[] escape(char c) {
|
||
|
char[] cArr;
|
||
|
if (c < this.replacementsLength && (cArr = this.replacements[c]) != null) {
|
||
|
return cArr;
|
||
|
}
|
||
|
if (c < this.safeMin || c > this.safeMax) {
|
||
|
return escapeUnsafe(c);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
}
|