[jboss-svn-commits] JBoss Common SVN: r3231 - jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/filters.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Jun 5 14:16:34 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-06-05 14:16:34 -0400 (Fri, 05 Jun 2009)
New Revision: 3231

Added:
   jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/filters/InvertFilter.java
Log:
An inverting filter

Added: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/filters/InvertFilter.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/filters/InvertFilter.java	                        (rev 0)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/filters/InvertFilter.java	2009-06-05 18:16:34 UTC (rev 3231)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.logmanager.filters;
+
+import java.util.logging.Filter;
+import java.util.logging.LogRecord;
+
+/**
+ * An inverting filter.
+ */
+public final class InvertFilter implements Filter {
+    private final Filter target;
+
+    /**
+     * Construct a new instance.
+     *
+     * @param target the target filter
+     */
+    public InvertFilter(final Filter target) {
+        this.target = target;
+    }
+
+    /**
+     * Determine whether a log record passes this filter.
+     *
+     * @param record the log record
+     * @return {@code true} if the target filter returns {@code false}, {@code false} otherwise
+     */
+    public boolean isLoggable(final LogRecord record) {
+        return ! target.isLoggable(record);
+    }
+}




More information about the jboss-svn-commits mailing list