EarProperties.java 2.91 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.pdfg.logging.PDFGLogger
 */
package com.adobe.pdfg.common;

import com.adobe.pdfg.logging.PDFGLogger;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;

public abstract class EarProperties {
    protected boolean tryCreationAgain = false;
    private static final PDFGLogger logger = PDFGLogger.getPDFGLogger(EarProperties.class);
    protected Properties properties = null;

    protected EarProperties() {
    }

    protected synchronized void init(String propertyFile, ClassLoader loader) {
        this.tryCreationAgain = false;
        Properties props = new Properties(System.getProperties());
        if (!this.addProperties("LFS_PDFGenerator.properties", loader, props)) {
            this.addProperties("LFS_PDFGenerator3D.properties", loader, props);
        }
        if (propertyFile != null) {
            this.addProperties(propertyFile, loader, props);
        }
        this.properties = props;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private boolean addProperties(String propertyFile, ClassLoader loader, Properties props) {
        boolean bSuccess;
        block13 : {
            bSuccess = true;
            InputStream in = null;
            try {
                in = loader.getResourceAsStream(propertyFile);
                if (in != null) {
                    Properties moreProperties = new Properties();
                    moreProperties.load(in);
                    props.putAll(moreProperties);
                    break block13;
                }
                logger.debug("Properties file '" + propertyFile + "' not found");
                bSuccess = false;
            }
            catch (IOException e) {
                logger.debug(e.getMessage(), null, (Throwable)e);
                props.clear();
                bSuccess = false;
            }
            finally {
                if (in != null) {
                    try {
                        in.close();
                    }
                    catch (IOException e1) {
                        logger.debug(e1.getMessage(), null, (Throwable)e1);
                    }
                }
            }
        }
        return bSuccess;
    }

    protected int virtualGetIntProperty(String key, int defaultValue) {
        int result = defaultValue;
        String propertyString = this.properties.getProperty(key);
        if (propertyString != null && propertyString.length() > 0) {
            try {
                int propertyInt;
                result = propertyInt = Integer.parseInt(propertyString);
            }
            catch (NumberFormatException e) {
                logger.debug("Non integer value '" + propertyString + "' for '" + key + "' , using default " + result, null, (Throwable)e);
            }
        }
        return result;
    }
}