com.crashlytics.tools.android_2.1.0

ons.logging.impl.Jdk13LumberjackLogger");
  }
  
  /**
   * @deprecated
   */
  protected boolean isJdk14Available()
  {
    return isLogLibraryAvailable("Jdk14", "org.apache.commons.logging.impl.Jdk14Logger");
  }
  
  /**
   * @deprecated
   */
  protected boolean isLog4JAvailable()
  {
    return isLogLibraryAvailable("Log4J", "org.apache.commons.logging.impl.Log4JLogger");
  }
  
  protected Log newInstance(String name)
    throws LogConfigurationException
  {
    try
    {
      Log instance;
      Log instance;
      if (logConstructor == null)
      {
        instance = discoverLogImplementation(name);
      }
      else
      {
        Object[] params = { name };
        instance = (Log)logConstructor.newInstance(params);
      }
      if (logMethod != null)
      {
        Object[] params = { this };
        logMethod.invoke(instance, params);
      }
      return instance;
    }
    catch (LogConfigurationException lce)
    {
      throw lce;
    }
    catch (InvocationTargetException e)
    {
      Throwable c = e.getTargetException();
      throw new LogConfigurationException(c == null ? e : c);
    }
    catch (Throwable t)
    {
      LogFactory.handleThrowable(t);
      
      throw new LogConfigurationException(t);
    }
  }
  
  private static ClassLoader getContextClassLoaderInternal()
    throws LogConfigurationException
  {
    (ClassLoader)AccessController.doPrivileged(new PrivilegedAction()
    {
      public Object run()
      {
        return LogFactoryImpl.access$000();
      }
    });
  }
  
  private static String getSystemProperty(String key, String def)
    throws SecurityException
  {
    (String)AccessController.doPrivileged(new PrivilegedAction()
    {
      private final String val$key;
      private final String val$def;
      
      public Object run()
      {
        return System.getProperty(val$key, val$def);
      }
    });
  }
  
  private ClassLoader getParentClassLoader(ClassLoader cl)
  {
    try
    {
      (ClassLoader)AccessController.doPrivileged(new PrivilegedAction()
      {
        private final ClassLoader val$cl;
        
        public Object run()
        {
          return val$cl.getParent();
        }
      });
    }
    catch (SecurityException ex)
    {
      logDiagnostic("[SECURITY] Unable to obtain parent classloader");
    }
    return null;
  }
  
  private boolean isLogLibraryAvailable(String name, String classname)
  {
    if (isDiagnosticsEnabled()) {
      logDiagnostic("Checking for '" + name + "'.");
    }
    try
    {
      Log log = createLogFromClass(classname, getClass().getName(), false);
      if (log == null)
      {
        if (isDiagnosticsEnabled()) {
          logDiagnostic("Did not find '" + name + "'.");
        }
        return false;
      }
      if (isDiagnosticsEnabled()) {
        logDiagnostic("Found '" + name + "'.");
      }
      return true;
    }
    catch (LogConfigurationException e)
    {
      if (isDiagnosticsEnabled()) {
        logDiagnostic("Logging system '" + name + "' is available but not useable.");
      }
    }
    return false;
  }
  
  private String getConfigurationValue(String property)
  {
    if (isDiagnosticsEnabled()) {
      logDiagnostic("[ENV] Trying to get configuration for item " + property);
    }
    Object valueObj = getAttribute(property);
    if (valueObj != null)
    {
      if (isDiagnosticsEnabled()) {
        logDiagnostic("[ENV] Found LogFactory attribute [" + valueObj + "] for " + property);
      }
      return valueObj.toString();
    }
    if (isDiagnosticsEnabled()) {
      logDiagnostic("[ENV] No LogFactory attribute found for " + property);
    }
    try
    {
      String value = getSystemProperty(property, null);
      if (value != null)
      {
        if (isDiagnosticsEnabled()) {
          logDiagnostic("[ENV] Found system property [" + value + "] for " + property);
        }
        return value;
      }
      if (isDiagnosticsEnabled()) {
        logDiagnostic("[ENV] No system property found for property " + property);
      }
    }
    catch (SecurityException e)
    {
      if (isDiagnosticsEnabled()) {
        logDiagnostic("[ENV] Security prevented reading system property " + property);
      }
    }
    if (isDiagnosticsEnabled()) {
      logDiagnostic("[ENV] No configuration defined for item " + property);
    }
    return null;
  }
  
  private boolean getBooleanConfiguration(String key, boolean dflt)
  {
    String val = getConfigurationValue(key);
    if (val == null) {
      return dflt;
    }
    return Boolean.valueOf(val).booleanValue();
  }
  
  private void initConfiguration()
  {
    allowFlawedContext = getBooleanConfiguration("org.apache.commons.logging.Log.allowFlawedContext", true);
    allowFlawedDiscovery = getBooleanConfiguration("org.apache.commons.logging.Log.allowFlawedDiscovery", true);
    allowFlawedHierarchy = getBooleanConfiguration("org.apache.commons.logging.Log.allowFlawedHierarchy", true);
  }
  
  private Log discoverLogImplementation(String logCategory)
    throws LogConfigurationException
  {
    if (isDiagnosticsEnabled()) {
      logDiagnostic("Discovering a Log implementation...");
    }
    initConfiguration();
    
    Log result = null;
    
    String specifiedLogClassName = findUserSpecifiedLogClassName();
    if (specifiedLogClassName != null)
    {
      if (isDiagnosticsEnabled()) {
        logDiagnostic("Attempting to load user-specified log class '" + specifiedLogClassName + "'...");
      }
      result = createLogFromClass(specifiedLogClassName, logCategory, true);
      if (result == null)
      {
        StringBuffer messageBuffer = new StringBuffer("User-specified log class '");
        messageBuffer.append(specifiedLogClassName);
        messageBuffer.append("' cannot be found or is not useable.");
        
        informUponSimilarName(messageBuffer, specifiedLogClassName, "org.apache.commons.logging.impl.Log4JLogger");
        informUponSimilarName(messageBuffer, specifiedLogClassName, "org.apache.commons.logging.impl.Jdk14Logger");
        informUponSimilarName(messageBuffer, specifiedLogClassName, "org.apache.commons.logging.impl.Jdk13LumberjackLogger");
        informUponSimilarName(messageBuffer, specifiedLogClassName, "org.apache.commons.logging.impl.SimpleLog");
        throw new LogConfigurationException(messageBuffer.toString());
      }
      return result;
    }
    if (isDiagnosticsEnabled()) {
      logDiagnostic("No user-specified Log implementation; performing discovery using the standard supported logging implementations...");
    }
    for (int i = 0; (i < classesToDiscover.length) && (result == null); i++) {
      result = createLogFromClass(classesToDiscover[i], logCategory, true);
    }
    if (result == null) {
      throw new LogConfigurationException("No suitable Log implementation");
    }
    return result;
  }
  
  private void informUponSimilarName(StringBuffer messageBuffer, String name, String candidate)
  {
    if (name.equals(candidate)) {
      return;
    }
    if (name.regionMatches(true, 0, candidate, 0, PKG_LEN + 5))
    {
      messageBuffer.append(" Did you mean '");
      messageBuffer.append(candidate);
      messageBuffer.append("'?");
    }
  }
  
  private String findUserSpecifiedLogClassName()
  {
    if (isDiagnosticsEnabled()) {
      logDiagnostic("Trying to get log class from attribute 'org.apache.commons.logging.Log'");
    }
    String specifiedClass = (String)getAttribute("org.apache.commons.logging.Log");
    if (specifiedClass == null)
    {
      if (isDiagnosticsEnabled()) {
        logDiagnostic("Trying to get log class from attribute 'org.apache.commons.logging.log'");
      }
      specifiedClass = (String)getAttribute("org.apache.commons.logging.log");
    }
    if (specifiedClass == null)
    {
      if (isDiagnosticsEnabled()) {
        logDiagnostic("Trying to get log class from system property 'org.apache.commons.logging.Log'");
      }
      try
      {
        specifiedClass = getSystemProperty("org.apache.commons.logging.Log", null);
      }
      catch (SecurityException e)
      {
        if (isDiagnosticsEnabled()) {
          logDiagnostic("No access allowed to system property 'org.apache.commons.logging.Log' - " + e.getMessage());
        }
      }
    }
    if (specifiedClass == null)
    {
      if (isDiagnosticsEnabled()) {
        logDiagnostic("Trying to get log class from system property 'org.apache.commons.logging.log'");
      }
      try
      {
        specifiedClass = getSystemProperty("org.apache.commons.logging.log", null);
      }
      catch (SecurityException e)
      {
        if (isDiagnosticsEnabled()) {
          logDiagnostic("No access allowed to system property 'org.apache.commons.logging.log' - " + e.getMessage());
        }
      }
    }
    if (specifiedClass != null) {
      specifiedClass = specifiedClass.trim();
    }
    return specifiedClass;
  }
  
  private Log createLogFromClass(String logAdapterClassName, String logCategory, boolean affectState)
    throws LogConfigurationException
  {
    if (isDiagnosticsEnabled()) {
      logDiagnostic("Attempting to instantiate '" + logAdapterClassName + "'");
    }
    Object[] params = { logCategory };
    Log logAdapter = null;
    Constructor constructor = null;
    
    Class logAdapterClass = null;
    ClassLoader currentCL = getBaseClassLoader();
    for (;;)
    {
      logDiagnostic("Trying to load '" + logAdapterClassName + "' from classloader " + LogFactory.objectId(currentCL));
      try
      {
        if (isDiagnosticsEnabled())
        {
          String resourceName = logAdapterClassName.replace('.', '/') + ".class";
          URL url;
          URL url;
          if (currentCL != null) {
            url = currentCL.getResource(resourceName);
          } else {
            url = ClassLoader.getSystemResource(resourceName + ".class");
          }
          if (url == null) {
            logDiagnostic("Class '" + logAdapterClassName + "' [" + resourceName + "] cannot be found.");
          } else {
            logDiagnostic("Class '" + logAdapterClassName + "' was found at '" + url + "'");
          }
        }
        Class c;
        try
        {
          c = Class.forName(logAdapterClassName, true, currentCL);
        }
        catch (ClassNotFoundException originalClassNotFoundException)
        {
          String msg = originalClassNotFoundException.getMessage();
          logDiagnostic("The log adapter '" + logAdapterClassName + "' is not available via classloader " + LogFactory.objectId(currentCL) + ": " + msg.trim());
          try
          {
            c = Class.forName(logAdapterClassName);
          }
          catch (ClassNotFoundException secondaryClassNotFoundException)
          {
            msg = secondaryClassNotFoundException.getMessage();
            logDiagnostic("The log adapter '" + logAdapterClassName + "' is not available via the LogFactoryImpl class classloader: " + msg.trim());
            
            break;
          }
        }
        constructor = c.getConstructor(logConstructorSignature);
        Object o = constructor.newInstance(params);
        if ((o instanceof Log))
        {
          logAdapterClass = c;
          logAdapter = (Log)o;
          break;
        }
        handleFlawedHierarchy(currentCL, c);
      }
      catch (NoClassDefFoundError e)
      {
        String msg = e.getMessage();
        logDiagnostic("The log adapter '" + logAdapterClassName + "' is missing dependencies when loaded via classloader " + LogFactory.objectId(currentCL) + ": " + msg.trim());
        
        break;
      }
      catch (ExceptionInInitializerError e)
      {
        String msg = e.getMessage();
        logDiagnostic("The log adapter '" + logAdapterClassName + "' is unable to initialize itself when loaded via classloader " + LogFactory.objectId(currentCL) + ": " + msg.trim());
        
        break;
      }
      catch (LogConfigurationException e)
      {
        throw e;
      }
      catch (Throwable t)
      {
        LogFactory.handleThrowable(t);
        
        handleFlawedDiscovery(logAdapterClassName, currentCL, t);
      }
      if (currentCL == null) {
        break;
      }
      currentCL = getParentClassLoader(currentCL);
    }
    if ((logAdapterClass != null) && (affectState))
    {
      logClassName = logAdapterClassName;
      logConstructor = constructor;
      try
      {
        logMethod = logAdapterClass.getMethod("setLogFactory", logMethodSignature);
        logDiagnostic("Found method setLogFactory(LogFactory) in '" + logAdapterClassName + "'");
      }
      catch (Throwable t)
      {
        LogFactory.handleThrowable(t);
        logMethod = null;
        logDiagnostic("[INFO] '" + logAdapterClassName + "' from classloader " + LogFactory.objectId(currentCL) + " does not declare optional method " + "setLogFactory(LogFactory)");
      }
      logDiagnostic("Log adapter '" + logAdapterClassName + "' from classloader " + LogFactory.objectId(logAdapterClass.getClassLoader()) + " has been selected for use.");
    }
    return logAdapter;
  }
  
  private ClassLoader getBaseClassLoader()
    throws LogConfigurationException
  {
    ClassLoader thisClassLoader = getClassLoader(LogFactoryImpl.class);
    if (!useTCCL) {
      return thisClassLoader;
    }
    ClassLoader contextClassLoader = getContextClassLoaderInternal();
    
    ClassLoader baseClassLoader = getLowestClassLoader(contextClassLoader, thisClassLoader);
    if (baseClassLoader == null)
    {
      if (allowFlawedContext)
      {
        if (isDiagnosticsEnabled()) {
          logDiagnostic("[WARNING] the context classloader is not part of a parent-child relationship with the classloader that loaded LogFactoryImpl.");
        }
        return contextClassLoader;
      }
      throw new LogConfigurationException("Bad classloader hierarchy; LogFactoryImpl was loaded via a classloader that is not related to the current context classloader.");
    }
    if (baseClassLoader != contextClassLoader) {
      if (allowFlawedContext)
      {
        if (isDiagnosticsEnabled()) {
          logDiagnostic("Warning: the context classloader is an ancestor of the classloader that loaded LogFactoryImpl; it should be the same or a descendant. The application using commons-logging should ensure the context classloader is used correctly.");
        }
      }
      else {
        throw new LogConfigurationException("Bad classloader hierarchy; LogFactoryImpl was loaded via a classloader that is not related to the current context classloader.");
      }
    }
    return baseClassLoader;
  }
  
  private ClassLoader getLowestClassLoader(ClassLoader c1, ClassLoader c2)
  {
    if (c1 == null) {
      return c2;
    }
    if (c2 == null) {
      return c1;
    }
    ClassLoader current = c1;
    while (current != null)
    {
      if (current == c2) {
        return c1;
      }
      current = getParentClassLoader(current);
    }
    current = c2;
    while (current != null)
    {
      if (current == c1) {
        return c2;
      }
      current = getParentClassLoader(current);
    }
    return null;
  }
  
  private void handleFlawedDiscovery(String logAdapterClassName, ClassLoader classLoader, Throwable discoveryFlaw)
  {
    if (isDiagnosticsEnabled())
    {
      logDiagnostic("Could not instantiate Log '" + logAdapterClassName + "' -- " + discoveryFlaw.getClass().getName() + ": " + discoveryFlaw.getLocalizedMessage());
      if ((discoveryFlaw instanceof InvocationTargetException))
      {
        InvocationTargetException ite = (InvocationTargetException)discoveryFlaw;
        Throwable cause = ite.getTargetException();
        if (cause != null)
        {
          logDiagnostic("... InvocationTargetException: " + cause.getClass().getName() + ": " + cause.getLocalizedMessage());
          if ((cause instanceof ExceptionInInitializerError))
          {
            ExceptionInInitializerError eiie = (ExceptionInInitializerError)cause;
            Throwable cause2 = eiie.getException();
            if (cause2 != null)
            {
              StringWriter sw = new StringWriter();
              cause2.printStackTrace(new PrintWriter(sw, true));
              logDiagnostic("... ExceptionInInitializerError: " + sw.toString());
            }
          }
        }
      }
    }
    if (!allowFlawedDiscovery) {
      throw new LogConfigurationException(discoveryFlaw);
    }
  }
  
  private void handleFlawedHierarchy(ClassLoader badClassLoader, Class badClass)
    throws LogConfigurationException
  {
    boolean implementsLog = false;
    String logInterfaceName = Log.class.getName();
    Class[] interfaces = badClass.getInterfaces();
    for (int i = 0; i < interfaces.length; i++) {
      if (logInterfaceName.equals(interfaces[i].getName()))
      {
        implementsLog = true;
        break;
      }
    }
    if (implementsLog)
    {
      if (isDiagnosticsEnabled()) {
        try
        {
          ClassLoader logInterfaceClassLoader = getClassLoader(Log.class);
          logDiagnostic("Class '" + badClass.getName() + "' was found in classloader " + LogFactory.objectId(badClassLoader) + ". It is bound to a Log interface which is not" + " the one loaded from classloader " + LogFactory.objectId(logInterfaceClassLoader));
        }
        catch (Throwable t)
        {
          LogFactory.handleThrowable(t);
          logDiagnostic("Error while trying to output diagnostics about bad class '" + badClass + "'");
        }
      }
      if (!allowFlawedHierarchy)
      {
        StringBuffer msg = new StringBuffer();
        msg.append("Terminating logging for this context ");
        msg.append("due to bad log hierarchy. ");
        msg.append("You have more than one version of '");
        msg.append(Log.class.getName());
        msg.append("' visible.");
        if (isDiagnosticsEnabled()) {
          logDiagnostic(msg.toString());
        }
        throw new LogConfigurationException(msg.toString());
      }
      if (isDiagnosticsEnabled())
      {
        StringBuffer msg = new StringBuffer();
        msg.append("Warning: bad log hierarchy. ");
        msg.append("You have more than one version of '");
        msg.append(Log.class.getName());
        msg.append("' visible.");
        logDiagnostic(msg.toString());
      }
    }
    else
    {
      if (!allowFlawedDiscovery)
      {
        StringBuffer msg = new StringBuffer();
        msg.append("Terminating logging for this context. ");
        msg.append("Log class '");
        msg.append(badClass.getName());
        msg.append("' does not implement the Log interface.");
        if (isDiagnosticsEnabled()) {
          logDiagnostic(msg.toString());
        }
        throw new LogConfigurationException(msg.toString());
      }
      if (isDiagnosticsEnabled())
      {
        StringBuffer msg = new StringBuffer();
        msg.append("[WARNING] Log class '");
        msg.append(badClass.getName());
        msg.append("' does not implement the Log interface.");
        logDiagnostic(msg.toString());
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.LogFactoryImpl
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.Serializable;
import org.apache.commons.logging.Log;
import org.apache.log.Hierarchy;
import org.apache.log.Logger;

public class LogKitLogger
  implements Log, Serializable
{
  private static final long serialVersionUID = 3768538055836059519L;
  protected volatile transient Logger logger = null;
  protected String name = null;
  
  public LogKitLogger(String name)
  {
    this.name = name;
    logger = getLogger();
  }
  
  public Logger getLogger()
  {
    Logger result = logger;
    if (result == null) {
      synchronized (this)
      {
        result = logger;
        if (result == null) {
          logger = (result = Hierarchy.getDefaultHierarchy().getLoggerFor(name));
        }
      }
    }
    return result;
  }
  
  public void trace(Object message)
  {
    debug(message);
  }
  
  public void trace(Object message, Throwable t)
  {
    debug(message, t);
  }
  
  public void debug(Object message)
  {
    if (message != null) {
      getLogger().debug(String.valueOf(message));
    }
  }
  
  public void debug(Object message, Throwable t)
  {
    if (message != null) {
      getLogger().debug(String.valueOf(message), t);
    }
  }
  
  public void info(Object message)
  {
    if (message != null) {
      getLogger().info(String.valueOf(message));
    }
  }
  
  public void info(Object message, Throwable t)
  {
    if (message != null) {
      getLogger().info(String.valueOf(message), t);
    }
  }
  
  public void warn(Object message)
  {
    if (message != null) {
      getLogger().warn(String.valueOf(message));
    }
  }
  
  public void warn(Object message, Throwable t)
  {
    if (message != null) {
      getLogger().warn(String.valueOf(message), t);
    }
  }
  
  public void error(Object message)
  {
    if (message != null) {
      getLogger().error(String.valueOf(message));
    }
  }
  
  public void error(Object message, Throwable t)
  {
    if (message != null) {
      getLogger().error(String.valueOf(message), t);
    }
  }
  
  public void fatal(Object message)
  {
    if (message != null) {
      getLogger().fatalError(String.valueOf(message));
    }
  }
  
  public void fatal(Object message, Throwable t)
  {
    if (message != null) {
      getLogger().fatalError(String.valueOf(message), t);
    }
  }
  
  public boolean isDebugEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isErrorEnabled()
  {
    return getLogger().isErrorEnabled();
  }
  
  public boolean isFatalEnabled()
  {
    return getLogger().isFatalErrorEnabled();
  }
  
  public boolean isInfoEnabled()
  {
    return getLogger().isInfoEnabled();
  }
  
  public boolean isTraceEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isWarnEnabled()
  {
    return getLogger().isWarnEnabled();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.LogKitLogger
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.Serializable;
import org.apache.commons.logging.Log;

public class NoOpLog
  implements Log, Serializable
{
  private static final long serialVersionUID = 561423906191706148L;
  
  public NoOpLog() {}
  
  public NoOpLog(String name) {}
  
  public void trace(Object message) {}
  
  public void trace(Object message, Throwable t) {}
  
  public void debug(Object message) {}
  
  public void debug(Object message, Throwable t) {}
  
  public void info(Object message) {}
  
  public void info(Object message, Throwable t) {}
  
  public void warn(Object message) {}
  
  public void warn(Object message, Throwable t) {}
  
  public void error(Object message) {}
  
  public void error(Object message, Throwable t) {}
  
  public void fatal(Object message) {}
  
  public void fatal(Object message, Throwable t) {}
  
  public final boolean isDebugEnabled()
  {
    return false;
  }
  
  public final boolean isErrorEnabled()
  {
    return false;
  }
  
  public final boolean isFatalEnabled()
  {
    return false;
  }
  
  public final boolean isInfoEnabled()
  {
    return false;
  }
  
  public final boolean isTraceEnabled()
  {
    return false;
  }
  
  public final boolean isWarnEnabled()
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.NoOpLog
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.LogFactory;

public class ServletContextCleaner
  implements ServletContextListener
{
  private static final Class[] RELEASE_SIGNATURE = { ClassLoader.class };
  
  public void contextDestroyed(ServletContextEvent sce)
  {
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    
    Object[] params = new Object[1];
    params[0] = tccl;
    
    ClassLoader loader = tccl;
    while (loader != null) {
      try
      {
        Class logFactoryClass = loader.loadClass("org.apache.commons.logging.LogFactory");
        Method releaseMethod = logFactoryClass.getMethod("release", RELEASE_SIGNATURE);
        releaseMethod.invoke(null, params);
        loader = logFactoryClass.getClassLoader().getParent();
      }
      catch (ClassNotFoundException ex)
      {
        loader = null;
      }
      catch (NoSuchMethodException ex)
      {
        System.err.println("LogFactory instance found which does not support release method!");
        loader = null;
      }
      catch (IllegalAccessException ex)
      {
        System.err.println("LogFactory instance found which is not accessable!");
        loader = null;
      }
      catch (InvocationTargetException ex)
      {
        System.err.println("LogFactory instance release method failed!");
        loader = null;
      }
    }
    LogFactory.release(tccl);
  }
  
  public void contextInitialized(ServletContextEvent sce) {}
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.ServletContextCleaner
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.security.PrivilegedAction;

final class SimpleLog$1
  implements PrivilegedAction
{
  private final String val$name;
  
  SimpleLog$1(String paramString)
  {
    val$name = paramString;
  }
  
  public Object run()
  {
    ClassLoader threadCL = SimpleLog.access$000();
    if (threadCL != null) {
      return threadCL.getResourceAsStream(val$name);
    }
    return ClassLoader.getSystemResourceAsStream(val$name);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.SimpleLog.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogConfigurationException;

public class SimpleLog
  implements Log, Serializable
{
  private static final long serialVersionUID = 136942970684951178L;
  protected static final String systemPrefix = "org.apache.commons.logging.simplelog.";
  protected static final Properties simpleLogProps = new Properties();
  protected static final String DEFAULT_DATE_TIME_FORMAT = "yyyy/MM/dd HH:mm:ss:SSS zzz";
  protected static volatile boolean showLogName = false;
  protected static volatile boolean showShortName = true;
  protected static volatile boolean showDateTime = false;
  protected static volatile String dateTimeFormat = "yyyy/MM/dd HH:mm:ss:SSS zzz";
  protected static DateFormat dateFormatter = null;
  public static final int LOG_LEVEL_TRACE = 1;
  public static final int LOG_LEVEL_DEBUG = 2;
  public static final int LOG_LEVEL_INFO = 3;
  public static final int LOG_LEVEL_WARN = 4;
  public static final int LOG_LEVEL_ERROR = 5;
  public static final int LOG_LEVEL_FATAL = 6;
  public static final int LOG_LEVEL_ALL = 0;
  public static final int LOG_LEVEL_OFF = 7;
  
  private static String getStringProperty(String name)
  {
    String prop = null;
    try
    {
      prop = System.getProperty(name);
    }
    catch (SecurityException e) {}
    return prop == null ? simpleLogProps.getProperty(name) : prop;
  }
  
  private static String getStringProperty(String name, String dephault)
  {
    String prop = getStringProperty(name);
    return prop == null ? dephault : prop;
  }
  
  private static boolean getBooleanProperty(String name, boolean dephault)
  {
    String prop = getStringProperty(name);
    return prop == null ? dephault : "true".equalsIgnoreCase(prop);
  }
  
  static
  {
    InputStream in = getResourceAsStream("simplelog.properties");
    if (null != in) {
      try
      {
        simpleLogProps.load(in);
        in.close();
      }
      catch (IOException e) {}
    }
    showLogName = getBooleanProperty("org.apache.commons.logging.simplelog.showlogname", showLogName);
    showShortName = getBooleanProperty("org.apache.commons.logging.simplelog.showShortLogname", showShortName);
    showDateTime = getBooleanProperty("org.apache.commons.logging.simplelog.showdatetime", showDateTime);
    if (showDateTime)
    {
      dateTimeFormat = getStringProperty("org.apache.commons.logging.simplelog.dateTimeFormat", dateTimeFormat);
      try
      {
        dateFormatter = new SimpleDateFormat(dateTimeFormat);
      }
      catch (IllegalArgumentException e)
      {
        dateTimeFormat = "yyyy/MM/dd HH:mm:ss:SSS zzz";
        dateFormatter = new SimpleDateFormat(dateTimeFormat);
      }
    }
  }
  
  protected volatile String logName = null;
  protected volatile int currentLogLevel;
  private volatile String shortLogName = null;
  
  public SimpleLog(String name)
  {
    logName = name;
    
    setLevel(3);
    
    String lvl = getStringProperty("org.apache.commons.logging.simplelog.log." + logName);
    int i = String.valueOf(name).lastIndexOf(".");
    while ((null == lvl) && (i > -1))
    {
      name = name.substring(0, i);
      lvl = getStringProperty("org.apache.commons.logging.simplelog.log." + name);
      i = String.valueOf(name).lastIndexOf(".");
    }
    if (null == lvl) {
      lvl = getStringProperty("org.apache.commons.logging.simplelog.defaultlog");
    }
    if ("all".equalsIgnoreCase(lvl)) {
      setLevel(0);
    } else if ("trace".equalsIgnoreCase(lvl)) {
      setLevel(1);
    } else if ("debug".equalsIgnoreCase(lvl)) {
      setLevel(2);
    } else if ("info".equalsIgnoreCase(lvl)) {
      setLevel(3);
    } else if ("warn".equalsIgnoreCase(lvl)) {
      setLevel(4);
    } else if ("error".equalsIgnoreCase(lvl)) {
      setLevel(5);
    } else if ("fatal".equalsIgnoreCase(lvl)) {
      setLevel(6);
    } else if ("off".equalsIgnoreCase(lvl)) {
      setLevel(7);
    }
  }
  
  public void setLevel(int currentLogLevel)
  {
    this.currentLogLevel = currentLogLevel;
  }
  
  public int getLevel()
  {
    return currentLogLevel;
  }
  
  protected void log(int type, Object message, Throwable t)
  {
    StringBuffer buf = new StringBuffer();
    if (showDateTime)
    {
      Date now = new Date();
      String dateText;
      synchronized (dateFormatter)
      {
        dateText = dateFormatter.format(now);
      }
      buf.append(dateText);
      buf.append(" ");
    }
    switch (type)
    {
    case 1: 
      buf.append("[TRACE] "); break;
    case 2: 
      buf.append("[DEBUG] "); break;
    case 3: 
      buf.append("[INFO] "); break;
    case 4: 
      buf.append("[WARN] "); break;
    case 5: 
      buf.append("[ERROR] "); break;
    case 6: 
      buf.append("[FATAL] ");
    }
    if (showShortName)
    {
      if (shortLogName == null)
      {
        String slName = logName.substring(logName.lastIndexOf(".") + 1);
        shortLogName = slName.substring(slName.lastIndexOf("/") + 1);
      }
      buf.append(String.valueOf(shortLogName)).append(" - ");
    }
    else if (showLogName)
    {
      buf.append(String.valueOf(logName)).append(" - ");
    }
    buf.append(String.valueOf(message));
    if (t != null)
    {
      buf.append(" <");
      buf.append(t.toString());
      buf.append(">");
      
      StringWriter sw = new StringWriter(1024);
      PrintWriter pw = new PrintWriter(sw);
      t.printStackTrace(pw);
      pw.close();
      buf.append(sw.toString());
    }
    write(buf);
  }
  
  protected void write(StringBuffer buffer)
  {
    System.err.println(buffer.toString());
  }
  
  protected boolean isLevelEnabled(int logLevel)
  {
    return logLevel >= currentLogLevel;
  }
  
  public final void debug(Object message)
  {
    if (isLevelEnabled(2)) {
      log(2, message, null);
    }
  }
  
  public final void debug(Object message, Throwable t)
  {
    if (isLevelEnabled(2)) {
      log(2, message, t);
    }
  }
  
  public final void trace(Object message)
  {
    if (isLevelEnabled(1)) {
      log(1, message, null);
    }
  }
  
  public final void trace(Object message, Throwable t)
  {
    if (isLevelEnabled(1)) {
      log(1, message, t);
    }
  }
  
  public final void info(Object message)
  {
    if (isLevelEnabled(3)) {
      log(3, message, null);
    }
  }
  
  public final void info(Object message, Throwable t)
  {
    if (isLevelEnabled(3)) {
      log(3, message, t);
    }
  }
  
  public final void warn(Object message)
  {
    if (isLevelEnabled(4)) {
      log(4, message, null);
    }
  }
  
  public final void warn(Object message, Throwable t)
  {
    if (isLevelEnabled(4)) {
      log(4, message, t);
    }
  }
  
  public final void error(Object message)
  {
    if (isLevelEnabled(5)) {
      log(5, message, null);
    }
  }
  
  public final void error(Object message, Throwable t)
  {
    if (isLevelEnabled(5)) {
      log(5, message, t);
    }
  }
  
  public final void fatal(Object message)
  {
    if (isLevelEnabled(6)) {
      log(6, message, null);
    }
  }
  
  public final void fatal(Object message, Throwable t)
  {
    if (isLevelEnabled(6)) {
      log(6, message, t);
    }
  }
  
  public final boolean isDebugEnabled()
  {
    return isLevelEnabled(2);
  }
  
  public final boolean isErrorEnabled()
  {
    return isLevelEnabled(5);
  }
  
  public final boolean isFatalEnabled()
  {
    return isLevelEnabled(6);
  }
  
  public final boolean isInfoEnabled()
  {
    return isLevelEnabled(3);
  }
  
  public final boolean isTraceEnabled()
  {
    return isLevelEnabled(1);
  }
  
  public final boolean isWarnEnabled()
  {
    return isLevelEnabled(4);
  }
  
  private static ClassLoader getContextClassLoader()
  {
    ClassLoader classLoader = null;
    try
    {
      Method method = Thread.class.getMethod("getContextClassLoader", (Class[])null);
      try
      {
        classLoader = (ClassLoader)method.invoke(Thread.currentThread(), (Class[])null);
      }
      catch (IllegalAccessException e) {}catch (InvocationTargetException e)
      {
        if (!(e.getTargetException() instanceof SecurityException)) {
          throw new LogConfigurationException("Unexpected InvocationTargetException", e.getTargetException());
        }
      }
    }
    catch (NoSuchMethodException e) {}
    if (classLoader == null) {
      classLoader = SimpleLog.class.getClassLoader();
    }
    return classLoader;
  }
  
  private static InputStream getResourceAsStream(String name)
  {
    (InputStream)AccessController.doPrivileged(new PrivilegedAction()
    {
      private final String val$name;
      
      public Object run()
      {
        ClassLoader threadCL = SimpleLog.access$000();
        if (threadCL != null) {
          return threadCL.getResourceAsStream(val$name);
        }
        return ClassLoader.getSystemResourceAsStream(val$name);
      }
    });
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.SimpleLog
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.util.Enumeration;

class WeakHashtable$1
  implements Enumeration
{
  private final Enumeration val$enumer;
  private final WeakHashtable this$0;
  
  WeakHashtable$1(WeakHashtable paramWeakHashtable, Enumeration paramEnumeration)
  {
    this$0 = paramWeakHashtable;val$enumer = paramEnumeration;
  }
  
  public boolean hasMoreElements()
  {
    return val$enumer.hasMoreElements();
  }
  
  public Object nextElement()
  {
    WeakHashtable.Referenced nextReference = (WeakHashtable.Referenced)val$enumer.nextElement();
    return WeakHashtable.Referenced.access$100(nextReference);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.WeakHashtable.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.util.Map.Entry;

final class WeakHashtable$Entry
  implements Map.Entry
{
  private final Object key;
  private final Object value;
  
  WeakHashtable$Entry(Object x0, Object x1, WeakHashtable.1 x2)
  {
    this(x0, x1);
  }
  
  private WeakHashtable$Entry(Object key, Object value)
  {
    this.key = key;
    this.value = value;
  }
  
  public boolean equals(Object o)
  {
    boolean result = false;
    if ((o != null) && ((o instanceof Map.Entry)))
    {
      Map.Entry entry = (Map.Entry)o;
      result = (getKey() == null ? entry.getKey() == null : getKey().equals(entry.getKey())) && (getValue() == null ? entry.getValue() == null : getValue().equals(entry.getValue()));
    }
    return result;
  }
  
  public int hashCode()
  {
    return (getKey() == null ? 0 : getKey().hashCode()) ^ (getValue() == null ? 0 : getValue().hashCode());
  }
  
  public Object setValue(Object value)
  {
    throw new UnsupportedOperationException("Entry.setValue is not supported.");
  }
  
  public Object getValue()
  {
    return value;
  }
  
  public Object getKey()
  {
    return key;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.WeakHashtable.Entry
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;

final class WeakHashtable$Referenced
{
  private final WeakReference reference;
  private final int hashCode;
  
  WeakHashtable$Referenced(Object x0, WeakHashtable.1 x1)
  {
    this(x0);
  }
  
  WeakHashtable$Referenced(Object x0, ReferenceQueue x1, WeakHashtable.1 x2)
  {
    this(x0, x1);
  }
  
  private WeakHashtable$Referenced(Object referant)
  {
    reference = new WeakReference(referant);
    
    hashCode = referant.hashCode();
  }
  
  private WeakHashtable$Referenced(Object key, ReferenceQueue queue)
  {
    reference = new WeakHashtable.WeakKey(key, queue, this, null);
    
    hashCode = key.hashCode();
  }
  
  public int hashCode()
  {
    return hashCode;
  }
  
  private Object getValue()
  {
    return reference.get();
  }
  
  public boolean equals(Object o)
  {
    boolean result = false;
    if ((o instanceof Referenced))
    {
      Referenced otherKey = (Referenced)o;
      Object thisKeyValue = getValue();
      Object otherKeyValue = otherKey.getValue();
      if (thisKeyValue == null)
      {
        result = otherKeyValue == null;
        
        result = (result) && (hashCode() == otherKey.hashCode());
      }
      else
      {
        result = thisKeyValue.equals(otherKeyValue);
      }
    }
    return result;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.WeakHashtable.Referenced
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;

final class WeakHashtable$WeakKey
  extends WeakReference
{
  private final WeakHashtable.Referenced referenced;
  
  WeakHashtable$WeakKey(Object x0, ReferenceQueue x1, WeakHashtable.Referenced x2, WeakHashtable.1 x3)
  {
    this(x0, x1, x2);
  }
  
  private WeakHashtable$WeakKey(Object key, ReferenceQueue queue, WeakHashtable.Referenced referenced)
  {
    super(key, queue);
    this.referenced = referenced;
  }
  
  private WeakHashtable.Referenced getReferenced()
  {
    return referenced;
  }
}

/* Location:
 * Qualified Name:    
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd