CustomExternalEntityResolver.java 1.14 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.fd.forms.internal.utils;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class CustomExternalEntityResolver
implements EntityResolver {
    private boolean resolveExternalEntitiesFlag;
    private boolean isExternalEntityPresent;

    private CustomExternalEntityResolver(boolean resolveExternalEntitiesFlag) {
        this.resolveExternalEntitiesFlag = resolveExternalEntitiesFlag;
    }

    public static CustomExternalEntityResolver valueOf(boolean b) {
        return b ? new CustomExternalEntityResolver(true) : new CustomExternalEntityResolver(false);
    }

    public boolean isExternalEntityPresent() {
        return this.isExternalEntityPresent;
    }

    @Override
    public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
        this.isExternalEntityPresent = true;
        if (this.resolveExternalEntitiesFlag) {
            return null;
        }
        return new InputSource(new StringReader(""));
    }
}