193 lines
7.1 KiB
Java
193 lines
7.1 KiB
Java
|
package com.kofax.kmc.klo.logistics.data;
|
||
|
|
||
|
import com.kofax.kmc.ken.engines.data.Image;
|
||
|
import com.kofax.kmc.klo.logistics.version.KloVersion;
|
||
|
import com.kofax.kmc.kut.utilities.AppContextProvider;
|
||
|
import com.kofax.kmc.kut.utilities.SdkVersion;
|
||
|
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
|
||
|
import com.kofax.kmc.kut.utilities.error.InternalError;
|
||
|
import com.kofax.kmc.kut.utilities.error.KmcException;
|
||
|
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
|
||
|
import com.kofax.mobile.sdk._internal.IBus;
|
||
|
import com.kofax.mobile.sdk._internal.dagger.Injector;
|
||
|
import com.kofax.mobile.sdk.q.a;
|
||
|
import java.io.IOException;
|
||
|
import java.io.ObjectInputStream;
|
||
|
import java.io.ObjectOutputStream;
|
||
|
import java.io.Serializable;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Collections;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.UUID;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class Document implements Serializable, Cloneable {
|
||
|
private static final long serialVersionUID = -5740834983974316354L;
|
||
|
private transient IBus _bus;
|
||
|
private transient DocumentType iF;
|
||
|
private transient List<FieldType> iG;
|
||
|
private transient List<Field> iH;
|
||
|
private transient List<Field> iI;
|
||
|
private transient List<Page> iJ;
|
||
|
private transient List<Page> iK;
|
||
|
private transient String iL;
|
||
|
private transient String iM;
|
||
|
private transient List<ClassificationResult> iN;
|
||
|
|
||
|
/* renamed from: clone, reason: merged with bridge method [inline-methods] */
|
||
|
public Document m273clone() {
|
||
|
try {
|
||
|
return (Document) super.clone();
|
||
|
} catch (CloneNotSupportedException unused) {
|
||
|
throw new InternalError("Document: unexpected 'clone not supported exception'");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Document(DocumentType documentType) {
|
||
|
this.iF = documentType.m274clone();
|
||
|
this.iL = UUID.randomUUID().toString();
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
public Document(DocumentTypeR documentTypeR) {
|
||
|
this.iF = (DocumentType) documentTypeR;
|
||
|
this.iL = UUID.randomUUID().toString();
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
public Document(DocumentType documentType, String str) {
|
||
|
if (str == null) {
|
||
|
throw new NullPointerException("Document constructor: documentID parameter cannot be null");
|
||
|
}
|
||
|
str = str.isEmpty() ? UUID.randomUUID().toString() : str;
|
||
|
this.iF = documentType.m274clone();
|
||
|
this.iL = str;
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
public Document(DocumentTypeR documentTypeR, String str) {
|
||
|
if (str == null) {
|
||
|
throw new NullPointerException("Document constructor: documentID parameter cannot be null");
|
||
|
}
|
||
|
str = str.isEmpty() ? UUID.randomUUID().toString() : str;
|
||
|
this.iF = (DocumentType) documentTypeR;
|
||
|
this.iL = str;
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
private void init() {
|
||
|
this.iG = this.iF.getFieldTypes();
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
this.iH = arrayList;
|
||
|
this.iI = Collections.unmodifiableList(arrayList);
|
||
|
if (this.iG != null) {
|
||
|
for (int i = 0; i < this.iG.size(); i++) {
|
||
|
this.iH.add(new Field(this.iG.get(i), this.iL));
|
||
|
List<Field> list = this.iH;
|
||
|
list.get(list.size() - 1).updateFieldProperties(this.iG.get(i).getDefault(), true, "");
|
||
|
}
|
||
|
}
|
||
|
ArrayList arrayList2 = new ArrayList();
|
||
|
this.iJ = arrayList2;
|
||
|
this.iK = Collections.unmodifiableList(arrayList2);
|
||
|
this.iM = "";
|
||
|
this.iN = new ArrayList();
|
||
|
IBus iBus = Injector.getInjector(AppContextProvider.getContext()).getIBus();
|
||
|
this._bus = iBus;
|
||
|
iBus.post(new a(this));
|
||
|
}
|
||
|
|
||
|
public void addPage(Page page) throws KmcException {
|
||
|
Image image;
|
||
|
page.setDocumentID(this.iL);
|
||
|
this.iJ.add(page);
|
||
|
if (this.iL == null || page.getImages().size() <= 0 || (image = page.getImages().get(0)) == null) {
|
||
|
return;
|
||
|
}
|
||
|
this._bus.post(new com.kofax.mobile.sdk.r.a(this.iL, image));
|
||
|
}
|
||
|
|
||
|
public ErrorInfo removePage(String str) {
|
||
|
ErrorInfo errorInfo = ErrorInfo.KMC_SUCCESS;
|
||
|
Iterator<Page> it = this.iJ.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
if (str.equalsIgnoreCase(it.next().getPageID())) {
|
||
|
it.remove();
|
||
|
return errorInfo;
|
||
|
}
|
||
|
}
|
||
|
return ErrorInfo.KMC_LO_PAGE_NOT_FOUND;
|
||
|
}
|
||
|
|
||
|
public List<ClassificationResult> getClassificationAlternatives() {
|
||
|
return new ArrayList(this.iN);
|
||
|
}
|
||
|
|
||
|
public void setClassificationAlternatives(List<ClassificationResult> list) {
|
||
|
new ArrayList(list);
|
||
|
}
|
||
|
|
||
|
public void setDocumentLevelError(String str) {
|
||
|
if (str == null) {
|
||
|
throw new NullPointerException("setDocumentLevelError: documentLevelError parameter cannot be null");
|
||
|
}
|
||
|
this.iM = str;
|
||
|
}
|
||
|
|
||
|
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
|
||
|
objectOutputStream.defaultWriteObject();
|
||
|
objectOutputStream.writeObject(Document.class.getName());
|
||
|
objectOutputStream.writeObject(KloVersion.getPackageVersion());
|
||
|
objectOutputStream.writeObject(this.iF);
|
||
|
objectOutputStream.writeObject(this.iH);
|
||
|
objectOutputStream.writeObject(this.iJ);
|
||
|
objectOutputStream.writeObject(this.iL);
|
||
|
objectOutputStream.writeObject(this.iM);
|
||
|
objectOutputStream.writeObject(this.iN);
|
||
|
}
|
||
|
|
||
|
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException, KmcRuntimeException {
|
||
|
objectInputStream.defaultReadObject();
|
||
|
if (Document.class.getName().compareToIgnoreCase((String) objectInputStream.readObject()) == 0) {
|
||
|
if (SdkVersion.versionCompatible(KloVersion.getPackageVersion(), (String) objectInputStream.readObject()).booleanValue()) {
|
||
|
DocumentType documentType = (DocumentType) objectInputStream.readObject();
|
||
|
this.iF = documentType;
|
||
|
this.iG = documentType.getFieldTypes();
|
||
|
ArrayList arrayList = (ArrayList) objectInputStream.readObject();
|
||
|
this.iH = arrayList;
|
||
|
this.iI = Collections.unmodifiableList(arrayList);
|
||
|
ArrayList arrayList2 = (ArrayList) objectInputStream.readObject();
|
||
|
this.iJ = arrayList2;
|
||
|
this.iK = Collections.unmodifiableList(arrayList2);
|
||
|
this.iL = (String) objectInputStream.readObject();
|
||
|
this.iM = (String) objectInputStream.readObject();
|
||
|
this.iN = (ArrayList) objectInputStream.readObject();
|
||
|
return;
|
||
|
}
|
||
|
throw new KmcRuntimeException(ErrorInfo.KMC_GN_DESERIALIZE_VERSION_ERROR);
|
||
|
}
|
||
|
throw new KmcRuntimeException(ErrorInfo.KMC_GN_DESERIALIZE_OBJECT_ERROR);
|
||
|
}
|
||
|
|
||
|
public List<Page> getPages() {
|
||
|
return this.iK;
|
||
|
}
|
||
|
|
||
|
public List<Field> getFields() {
|
||
|
return this.iI;
|
||
|
}
|
||
|
|
||
|
public DocumentType getDocumentType() {
|
||
|
return this.iF;
|
||
|
}
|
||
|
|
||
|
public String getDocumentLevelError() {
|
||
|
return this.iM;
|
||
|
}
|
||
|
|
||
|
public String getDocumentId() {
|
||
|
return this.iL;
|
||
|
}
|
||
|
}
|