package com.kofax.mobile.sdk.capture.extraction; import android.text.TextUtils; import com.kofax.kmc.ken.engines.data.Image; import com.kofax.kmc.kut.utilities.CertificateValidatorListener; import com.kofax.mobile.sdk._internal.extraction.DataUnit; import com.kofax.mobile.sdk._internal.extraction.IDataUnitProcessedListener; import com.kofax.mobile.sdk._internal.extraction.IDeserializer; import com.kofax.mobile.sdk._internal.extraction.IExceptionResponseDeserializer; import com.kofax.mobile.sdk._internal.extraction.IExtractionServer; import com.kofax.mobile.sdk._internal.k; import com.kofax.mobile.sdk.capture.parameter.ExtractionParameters; import java.io.Serializable; import java.lang.ref.WeakReference; /* loaded from: classes3.dex */ public abstract class Extractor implements IDataUnitProcessedListener { private ExtractionParameters _parameters; private IDeserializer ach; private IExceptionResponseDeserializer aci; private WeakReference acj; private IExtractionServer ack; protected abstract ExtractorResponse createResponse(T t, ExceptionResponse exceptionResponse); protected abstract String getDefaultServerUrl(ExtractionParameters.ExtractionType extractionType); public void setExtractionServer(IExtractionServer iExtractionServer) { if (iExtractionServer == null) { throw new IllegalArgumentException("extractionServer cannot be null"); } this.ack = iExtractionServer; } public void setResultDeserializer(IDeserializer iDeserializer) { if (iDeserializer == null) { throw new IllegalArgumentException("checkDeserializer cannot be null"); } this.ach = iDeserializer; } public void setExceptionResponseDeserializer(IExceptionResponseDeserializer iExceptionResponseDeserializer) { if (iExceptionResponseDeserializer == null) { throw new IllegalArgumentException("exceptionResponseDeserializer cannot be null"); } this.aci = iExceptionResponseDeserializer; } public void setParameters(ExtractionParameters extractionParameters) { if (extractionParameters == null) { throw new IllegalArgumentException("parameters cannot be null"); } this._parameters = extractionParameters; if (TextUtils.isEmpty(extractionParameters.serverUrl)) { ExtractionParameters extractionParameters2 = this._parameters; extractionParameters2.serverUrl = getDefaultServerUrl(extractionParameters2.getExtractionType()); } } public void setExtractorListener(IExtractorListener iExtractorListener) { if (iExtractorListener == null) { throw new IllegalArgumentException("listener cannot be null"); } this.acj = new WeakReference<>(iExtractorListener); } public void setCertificateValidatorListener(CertificateValidatorListener certificateValidatorListener) { this.ack.setCertificateValidatorListener(certificateValidatorListener); } public void extract(Image... imageArr) { this.ack.extract(new DataUnit(imageArr), this); } @Override // com.kofax.mobile.sdk._internal.extraction.IDataUnitProcessedListener public void onExtractionComplete(DataUnit dataUnit) { ExceptionResponse exceptionResponseImpl; IExtractorListener iExtractorListener = this.acj.get(); if (iExtractorListener != null) { StringBuilder sb = new StringBuilder("Extraction results success: "); sb.append(dataUnit.success); k.C(sb.toString()); StringBuilder sb2 = new StringBuilder("Extraction response: "); sb2.append(dataUnit.returnData.response); k.C(sb2.toString()); T t = null; if (dataUnit.success) { t = this.ach.deserialize(dataUnit.returnData.response); exceptionResponseImpl = null; } else { try { exceptionResponseImpl = this.aci.deserialize(dataUnit.returnData.response); } catch (RuntimeException e) { exceptionResponseImpl = new ExceptionResponseImpl(e); } } iExtractorListener.onExtractionComplete(createResponse(t, exceptionResponseImpl)); } } }