/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  android.util.Log
 *  java.io.IOException
 *  java.lang.Class
 *  java.lang.Enum
 *  java.lang.Object
 *  java.lang.String
 *  java.lang.System
 *  java.util.Enumeration
 *  java.util.Hashtable
 */
package com.google.code.microlog4android.repository;

import android.util.Log;
import com.google.code.microlog4android.Level;
import com.google.code.microlog4android.Logger;
import com.google.code.microlog4android.repository.CommonLoggerRepository;
import com.google.code.microlog4android.repository.LoggerNamesUtil;
import com.google.code.microlog4android.repository.LoggerRepository;
import com.google.code.microlog4android.repository.MicrologRepositoryNode;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;

public final class DefaultLoggerRepository
extends Enum<DefaultLoggerRepository>
implements LoggerRepository,
CommonLoggerRepository {
    private static final /* synthetic */ DefaultLoggerRepository[] ENUM$VALUES;
    public static final /* enum */ DefaultLoggerRepository INSTANCE = new DefaultLoggerRepository("INSTANCE", 0);
    private static final String TAG = "Microlog.DefaultLoggerRepository";
    private Hashtable<String, MicrologRepositoryNode> leafNodeHashtable = new Hashtable(43);
    private MicrologRepositoryNode rootNode;

    static {
        DefaultLoggerRepository[] arrdefaultLoggerRepository = new DefaultLoggerRepository[]{INSTANCE};
        ENUM$VALUES = arrdefaultLoggerRepository;
    }

    private DefaultLoggerRepository(String object, int n2) {
        super(string2, n);
        object = new Logger("", (CommonLoggerRepository)this);
        object.setLevel(Level.DEBUG);
        this.rootNode = new MicrologRepositoryNode("", (Logger)object);
    }

    private MicrologRepositoryNode createNewChildNode(String string2, MicrologRepositoryNode micrologRepositoryNode) {
        MicrologRepositoryNode micrologRepositoryNode2 = new MicrologRepositoryNode(string2, micrologRepositoryNode);
        micrologRepositoryNode.addChild(micrologRepositoryNode2);
        return micrologRepositoryNode2;
    }

    public static DefaultLoggerRepository valueOf(String string2) {
        return (DefaultLoggerRepository)Enum.valueOf((Class)DefaultLoggerRepository.class, (String)string2);
    }

    public static DefaultLoggerRepository[] values() {
        DefaultLoggerRepository[] arrdefaultLoggerRepository = ENUM$VALUES;
        int n = arrdefaultLoggerRepository.length;
        DefaultLoggerRepository[] arrdefaultLoggerRepository2 = new DefaultLoggerRepository[n];
        System.arraycopy((Object)arrdefaultLoggerRepository, (int)0, (Object)arrdefaultLoggerRepository2, (int)0, (int)n);
        return arrdefaultLoggerRepository2;
    }

    void addLogger(Logger logger) {
        String string2 = logger.getName();
        MicrologRepositoryNode micrologRepositoryNode = this.rootNode;
        String[] arrstring = LoggerNamesUtil.getLoggerNameComponents(string2);
        int n = arrstring.length;
        int n2 = 0;
        do {
            if (n2 >= n) {
                if (arrstring.length > 0) {
                    MicrologRepositoryNode micrologRepositoryNode2 = new MicrologRepositoryNode(LoggerNamesUtil.getClassName(arrstring), logger, micrologRepositoryNode);
                    micrologRepositoryNode.addChild(micrologRepositoryNode2);
                    this.leafNodeHashtable.put((Object)string2, (Object)micrologRepositoryNode2);
                }
                return;
            }
            String string3 = arrstring[n2];
            if (micrologRepositoryNode.getChildNode(string3) == null) {
                micrologRepositoryNode = super.createNewChildNode(string3, micrologRepositoryNode);
            }
            ++n2;
        } while (true);
    }

    @Override
    public boolean contains(String string2) {
        return this.leafNodeHashtable.containsKey((Object)string2);
    }

    @Override
    public Level getEffectiveLevel(String string2) {
        Level level = null;
        MicrologRepositoryNode micrologRepositoryNode = (MicrologRepositoryNode)this.leafNodeHashtable.get((Object)string2);
        while (level == null && micrologRepositoryNode != null) {
            level = micrologRepositoryNode.getLogger().getLevel();
            micrologRepositoryNode = micrologRepositoryNode.getParent();
        }
        return level;
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    @Override
    public Logger getLogger(String string2) {
        void var6_2 = this;
        synchronized (var6_2) {
            MicrologRepositoryNode micrologRepositoryNode = (MicrologRepositoryNode)this.leafNodeHashtable.get((Object)string2);
            Logger logger = micrologRepositoryNode.getLogger();
            if (micrologRepositoryNode != null) return logger;
            Logger logger2 = new Logger(string2, (CommonLoggerRepository)this);
            this.addLogger(logger2);
            return logger2;
        }
    }

    @Override
    public Logger getRootLogger() {
        return this.rootNode.getLogger();
    }

    @Override
    public int numberOfLeafNodes() {
        return this.leafNodeHashtable.size();
    }

    @Override
    public void reset() {
        this.rootNode.resetLogger();
        this.leafNodeHashtable.clear();
    }

    /*
     * Enabled aggressive block sorting
     * Lifted jumps to return sites
     */
    @Override
    public void setLevel(String string2, Level level) {
        MicrologRepositoryNode micrologRepositoryNode = (MicrologRepositoryNode)this.leafNodeHashtable.get((Object)string2);
        if (micrologRepositoryNode != null) {
            micrologRepositoryNode.getLogger().setLevel(level);
            return;
        }
        MicrologRepositoryNode micrologRepositoryNode2 = this.rootNode;
        String[] arrstring = LoggerNamesUtil.getLoggerNameComponents(string2);
        int n = arrstring.length;
        int n2 = 0;
        do {
            if (n2 >= n) {
                if (micrologRepositoryNode2 == null) return;
                micrologRepositoryNode2.getLogger().setLevel(level);
                return;
            }
            String string3 = arrstring[n2];
            if (micrologRepositoryNode2.getChildNode(string3) == null) {
                micrologRepositoryNode2 = super.createNewChildNode(string3, micrologRepositoryNode2);
            }
            ++n2;
        } while (true);
    }

    @Override
    public void shutdown() {
        Enumeration enumeration = this.leafNodeHashtable.elements();
        while (enumeration.hasMoreElements()) {
            Logger logger = ((MicrologRepositoryNode)enumeration.nextElement()).getLogger();
            if (logger == null) continue;
            try {
                logger.close();
                continue;
            }
            catch (IOException var3_2) {
                Log.e((String)"Microlog.DefaultLoggerRepository", (String)("Failed to close logger " + logger.getName()));
                continue;
            }
            break;
        }
        return;
    }
}

