package com.l7tech.server.log;

import com.l7tech.common.log.HybridDiagnosticContextMatcher.MatcherRules;
import com.l7tech.gateway.common.log.GatewayDiagnosticContextKeys;
import com.l7tech.gateway.common.log.SinkConfiguration;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.logging.Handler;
import java.util.logging.LogRecord;

abstract class MessageSinkSupport implements MessageSink {
   private final SinkConfiguration a;
   private final Set<MessageCategory> b;
   private final int c;
   private final MatcherRules d;

   @Override
   public void message(MessageCategory param1, LogRecord param2) {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 2
      // 01: ifnull 21
      // 04: aload 0
      // 05: aload 1
      // 06: aload 2
      // 07: invokevirtual com/l7tech/server/log/MessageSinkSupport.a (Lcom/l7tech/server/log/MessageCategory;Ljava/util/logging/LogRecord;)Z
      // 0a: ifeq 21
      // 0d: goto 14
      // 10: invokestatic com/l7tech/server/log/MessageSinkSupport.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 13: athrow
      // 14: aload 0
      // 15: aload 1
      // 16: aload 2
      // 17: invokevirtual com/l7tech/server/log/MessageSinkSupport.processMessage (Lcom/l7tech/server/log/MessageCategory;Ljava/util/logging/LogRecord;)V
      // 1a: goto 21
      // 1d: invokestatic com/l7tech/server/log/MessageSinkSupport.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 20: athrow
      // 21: return
      // try (0 -> 7): 8 java/lang/IllegalArgumentException
      // try (2 -> 14): 15 java/lang/IllegalArgumentException
   }

   @Override
   public List<Handler> getHandlers() {
      return Collections.emptyList();
   }

   MessageSinkSupport(SinkConfiguration var1) {
      this.a = var1;
      this.c = var1.getSeverity().toLoggingLevel().intValue();
      this.b = this.a(var1);
      this.d = new MatcherRules(var1.getFilters(), GatewayDiagnosticContextKeys.PREFIX_MATCH_PROPERTIES);
   }

   SinkConfiguration a() {
      return this.a;
   }

   int getThreshold() {
      return this.c;
   }

   boolean a(MessageCategory var1) {
      boolean var2 = false;

      try {
         if (var1 == null || !this.b.contains(var1)) {
            return var2;
         }
      } catch (IllegalArgumentException var3) {
         throw a(var3);
      }

      return true;
   }

   abstract void processMessage(MessageCategory var1, LogRecord var2);

   private boolean a(MessageCategory param1, LogRecord param2) {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 2
      // 01: invokevirtual java/util/logging/LogRecord.getLevel ()Ljava/util/logging/Level;
      // 04: invokevirtual java/util/logging/Level.intValue ()I
      // 07: aload 0
      // 08: invokevirtual com/l7tech/server/log/MessageSinkSupport.getThreshold ()I
      // 0b: if_icmplt 36
      // 0e: aload 0
      // 0f: aload 1
      // 10: invokevirtual com/l7tech/server/log/MessageSinkSupport.a (Lcom/l7tech/server/log/MessageCategory;)Z
      // 13: ifeq 36
      // 16: goto 1d
      // 19: invokestatic com/l7tech/server/log/MessageSinkSupport.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 1c: athrow
      // 1d: aload 0
      // 1e: getfield com/l7tech/server/log/MessageSinkSupport.d Lcom/l7tech/common/log/HybridDiagnosticContextMatcher$MatcherRules;
      // 21: invokestatic com/l7tech/common/log/HybridDiagnosticContextMatcher.matches (Lcom/l7tech/common/log/HybridDiagnosticContextMatcher$MatcherRules;)Z
      // 24: ifeq 36
      // 27: goto 2e
      // 2a: invokestatic com/l7tech/server/log/MessageSinkSupport.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 2d: athrow
      // 2e: bipush 1
      // 2f: goto 37
      // 32: invokestatic com/l7tech/server/log/MessageSinkSupport.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 35: athrow
      // 36: bipush 0
      // 37: ireturn
      // try (0 -> 10): 11 java/lang/IllegalArgumentException
      // try (6 -> 17): 18 java/lang/IllegalArgumentException
      // try (13 -> 22): 22 java/lang/IllegalArgumentException
   }

   private Set<MessageCategory> a(SinkConfiguration var1) {
      HashSet var2 = new HashSet();
      String var3 = var1.getCategories();
      if (var3 != null) {
         StringTokenizer var4 = new StringTokenizer(var3, ",");

         while (var4.hasMoreTokens()) {
            String var5 = var4.nextToken().trim();

            try {
               var2.add(MessageCategory.valueOf(var5));
            } catch (IllegalArgumentException var7) {
            }
         }
      }

      return Collections.unmodifiableSet(var2);
   }

   private static IllegalArgumentException a(IllegalArgumentException var0) {
      return var0;
   }

   static class ConfigurationException extends Exception {
      static final long serialVersionUID = -2488045756444917897L;

      ConfigurationException(String var1) {
         super(var1);
      }

      ConfigurationException(String var1, Throwable var2) {
         super(var1, var2);
      }
   }
}
