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 ArrayBasedCharEscaper extends CharEscaper { private final char[][] replacements; private final int replacementsLength; private final char safeMax; private final char safeMin; @CheckForNull protected abstract char[] escapeUnsafe(char c); /* JADX INFO: Access modifiers changed from: protected */ public ArrayBasedCharEscaper(Map 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 = CharCompanionObject.MAX_VALUE; } 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 @CheckForNull 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; } }