You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2018/03/13 07:04:44 UTC

[16/27] logging-chainsaw git commit: Reformat code for consistency

http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/chainsaw/LoggerNameListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/log4j/chainsaw/LoggerNameListener.java b/src/main/java/org/apache/log4j/chainsaw/LoggerNameListener.java
index 6a27ffe..a182b4e 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LoggerNameListener.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LoggerNameListener.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,19 +23,20 @@ import java.util.EventListener;
 /**
  * Implementations are notified when new Logger names
  * are added to the related LoggerNameModel instance.
- * 
+ *
  * @author Paul Smith <psmith@apache.org>
  */
 public interface LoggerNameListener extends EventListener {
-  /**
-   * Called by LoggerNameModel instances when a new unique
-   * Logger name string has been introduced into the model
-   * @param loggerName the new, unique loggerName
-   */
-  void loggerNameAdded(String loggerName);
+    /**
+     * Called by LoggerNameModel instances when a new unique
+     * Logger name string has been introduced into the model
+     *
+     * @param loggerName the new, unique loggerName
+     */
+    void loggerNameAdded(String loggerName);
 
-  /**
-   * Logger names were reset (used to clear the tree model)
-   */
-  void reset();
+    /**
+     * Logger names were reset (used to clear the tree model)
+     */
+    void reset();
 }

http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/chainsaw/LoggerNameModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/log4j/chainsaw/LoggerNameModel.java b/src/main/java/org/apache/log4j/chainsaw/LoggerNameModel.java
index 59301d7..df53d75 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LoggerNameModel.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LoggerNameModel.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,36 +25,37 @@ import java.util.Collection;
 /**
  * Implementations of this model contain all the known Logger
  * names within it's model space.
- * 
+ *
  * @author Paul Smith psmith@apache.org
  */
 public interface LoggerNameModel {
-  
-  /**
-   * Returns an unmodifiable Collection of the uniquely
-   * known LoggerNames within this model.
-   * 
-   * @return unmodifiable Collection of Logger name Strings
-   */
-  Collection getLoggerNames();
-  
-  /**
-   * Attempts to add the loggerName to the model, and returns
-   * true if it does, i.e that the loggerName is new, otherwise
-   * it is ignored.
-   * 
-   * If the loggerName is new for this model, all the LoggerNameListeners
-   * are notified using this thread.
-   * 
-   * @param loggerName
-   */
-  boolean addLoggerName(String loggerName);
-
-  /**
-   * The logger names have been cleared
-   */
-  void reset();
-  
-  void addLoggerNameListener(LoggerNameListener l);
-  void removeLoggerNameListener(LoggerNameListener l);
+
+    /**
+     * Returns an unmodifiable Collection of the uniquely
+     * known LoggerNames within this model.
+     *
+     * @return unmodifiable Collection of Logger name Strings
+     */
+    Collection getLoggerNames();
+
+    /**
+     * Attempts to add the loggerName to the model, and returns
+     * true if it does, i.e that the loggerName is new, otherwise
+     * it is ignored.
+     * <p>
+     * If the loggerName is new for this model, all the LoggerNameListeners
+     * are notified using this thread.
+     *
+     * @param loggerName
+     */
+    boolean addLoggerName(String loggerName);
+
+    /**
+     * The logger names have been cleared
+     */
+    void reset();
+
+    void addLoggerNameListener(LoggerNameListener l);
+
+    void removeLoggerNameListener(LoggerNameListener l);
 }

http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/chainsaw/LoggerNameModelSupport.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/log4j/chainsaw/LoggerNameModelSupport.java b/src/main/java/org/apache/log4j/chainsaw/LoggerNameModelSupport.java
index 2a835a6..8e795e2 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LoggerNameModelSupport.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LoggerNameModelSupport.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,80 +19,78 @@
  */
 package org.apache.log4j.chainsaw;
 
+import javax.swing.event.EventListenerList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.swing.event.EventListenerList;
-
 
 /**
  * An implementation of LoggerNameModel which can be used as a delegate
- * 
+ *
  * @author Paul Smith &lt;psmith@apache.org&gt;
  */
 public class LoggerNameModelSupport implements LoggerNameModel {
-  
-  private Set<String> loggerNameSet = new HashSet<>();
-  private EventListenerList listenerList = new EventListenerList();
-  
-
-  /* (non-Javadoc)
-   * @see org.apache.log4j.chainsaw.LoggerNameModel#getLoggerNames()
-   */
-  public Collection getLoggerNames() {
-    return Collections.unmodifiableSet(loggerNameSet);
-  }
-
-  /* (non-Javadoc)
-   * @see org.apache.log4j.chainsaw.LoggerNameModel#addLoggerName(java.lang.String)
-   */
-  public boolean addLoggerName(String loggerName) {
-    boolean isNew = loggerNameSet.add(loggerName);
-    
-    if(isNew)
-    {
-      notifyListeners(loggerName);
+
+    private Set<String> loggerNameSet = new HashSet<>();
+    private EventListenerList listenerList = new EventListenerList();
+
+
+    /* (non-Javadoc)
+     * @see org.apache.log4j.chainsaw.LoggerNameModel#getLoggerNames()
+     */
+    public Collection getLoggerNames() {
+        return Collections.unmodifiableSet(loggerNameSet);
     }
-    
-    return isNew;
-  }
 
-  public void reset() {
-      loggerNameSet.clear();
-      LoggerNameListener[] eventListeners = listenerList.getListeners(LoggerNameListener.class);
+    /* (non-Javadoc)
+     * @see org.apache.log4j.chainsaw.LoggerNameModel#addLoggerName(java.lang.String)
+     */
+    public boolean addLoggerName(String loggerName) {
+        boolean isNew = loggerNameSet.add(loggerName);
+
+        if (isNew) {
+            notifyListeners(loggerName);
+        }
+
+        return isNew;
+    }
+
+    public void reset() {
+        loggerNameSet.clear();
+        LoggerNameListener[] eventListeners = listenerList.getListeners(LoggerNameListener.class);
+
+        for (LoggerNameListener listener : eventListeners) {
+            listener.reset();
+        }
+    }
+
+    /**
+     * Notifies all the registered listeners that a new unique
+     * logger name has been added to this model
+     *
+     * @param loggerName
+     */
+    private void notifyListeners(String loggerName) {
+        LoggerNameListener[] eventListeners = listenerList.getListeners(LoggerNameListener.class);
+
+        for (LoggerNameListener listener : eventListeners) {
+            listener.loggerNameAdded(loggerName);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.log4j.chainsaw.LoggerNameModel#addLoggerNameListener(org.apache.log4j.chainsaw.LoggerNameListener)
+     */
+    public void addLoggerNameListener(LoggerNameListener l) {
+        listenerList.add(LoggerNameListener.class, l);
+    }
 
-    for (LoggerNameListener listener : eventListeners) {
-      listener.reset();
+    /* (non-Javadoc)
+     * @see org.apache.log4j.chainsaw.LoggerNameModel#removeLoggerNameListener(org.apache.log4j.chainsaw.LoggerNameListener)
+     */
+    public void removeLoggerNameListener(LoggerNameListener l) {
+        listenerList.remove(LoggerNameListener.class, l);
     }
-  }
-
-  /**
-   * Notifies all the registered listeners that a new unique
-   * logger name has been added to this model
-   * @param loggerName
-   */
-  private void notifyListeners(String loggerName)
-  {
-    LoggerNameListener[] eventListeners = listenerList.getListeners(LoggerNameListener.class);
-
-    for (LoggerNameListener listener : eventListeners) {
-      listener.loggerNameAdded(loggerName);
-    }    
-  }
-
-  /* (non-Javadoc)
-   * @see org.apache.log4j.chainsaw.LoggerNameModel#addLoggerNameListener(org.apache.log4j.chainsaw.LoggerNameListener)
-   */
-  public void addLoggerNameListener(LoggerNameListener l) {
-    listenerList.add(LoggerNameListener.class, l);
-  }
-
-  /* (non-Javadoc)
-   * @see org.apache.log4j.chainsaw.LoggerNameModel#removeLoggerNameListener(org.apache.log4j.chainsaw.LoggerNameListener)
-   */
-  public void removeLoggerNameListener(LoggerNameListener l) {
-    listenerList.remove(LoggerNameListener.class, l);
-  }
 }

http://git-wip-us.apache.org/repos/asf/logging-chainsaw/blob/96ebd9ad/src/main/java/org/apache/log4j/chainsaw/LoggerNameTree.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/log4j/chainsaw/LoggerNameTree.java b/src/main/java/org/apache/log4j/chainsaw/LoggerNameTree.java
index 67d1412..c252b84 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LoggerNameTree.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LoggerNameTree.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,7 +19,7 @@
  */
 package org.apache.log4j.chainsaw;
 
-import javax.swing.JTree;
+import javax.swing.*;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.TreeModel;
 
@@ -30,24 +30,22 @@ import javax.swing.tree.TreeModel;
  * @author Paul Smith &lt;psmith@apache.org&gt;
  */
 public class LoggerNameTree extends JTree {
-  LoggerNameTree(TreeModel model) {
-    super(model);
-    
-    
+    LoggerNameTree(TreeModel model) {
+        super(model);
+
+
+        //    ============================================
+        //    TODO remove this WIP node once we're statisfied
+        DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
 
-    //    ============================================
-    //    TODO remove this WIP node once we're statisfied
-    DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
+        DefaultMutableTreeNode node =
+            new DefaultMutableTreeNode("Work in Progress...");
+        node.setAllowsChildren(false);
 
-    DefaultMutableTreeNode node =
-      new DefaultMutableTreeNode("Work in Progress...");
-    node.setAllowsChildren(false);
+        root.add(node);
 
-    root.add(node);
 
-    
+    }
 
-  }
 
- 
 }