[LOGBack-dev] svn commit: r263 - logback/core/trunk/src/main/java/ch/qos/logback/core/spi
noreply.seb at qos.ch
noreply.seb at qos.ch
Mon Jul 24 19:50:14 CEST 2006
Author: seb
Date: Mon Jul 24 19:50:13 2006
New Revision: 263
Modified:
logback/core/trunk/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java
Log:
removed unnecessary tests on appenderList
Modified: logback/core/trunk/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java
==============================================================================
--- logback/core/trunk/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java (original)
+++ logback/core/trunk/src/main/java/ch/qos/logback/core/spi/AppenderAttachableImpl.java Mon Jul 24 19:50:13 2006
@@ -16,150 +16,145 @@
import ch.qos.logback.core.Appender;
/**
- * A straightforward implementation of the {@link AppenderAttachable}
- * interface.
+ * A straightforward implementation of the {@link AppenderAttachable} interface.
*
* @author Ceki Gülcü
*/
public class AppenderAttachableImpl implements AppenderAttachable {
- final private List appenderList = new ArrayList();
+ final private List appenderList = new ArrayList();
- /**
- * Attach an appender. If the appender is already in the list in won't be
- * added again.
- */
- public void addAppender(Appender newAppender) {
- // Null values for newAppender parameter are strictly forbidden.
- if (newAppender == null) {
- throw new IllegalArgumentException("Cannot null as an appener");
- }
- if (!appenderList.contains(newAppender)) {
- appenderList.add(newAppender);
- }
- }
-
- /**
- * Call the <code>doAppend</code> method on all attached appenders.
- */
- public int appendLoopOnAppenders(Object o) {
- int size = 0;
- Appender appender;
-
- if (appenderList != null) {
- size = appenderList.size();
- for (int i = 0; i < size; i++) {
- appender = (Appender) appenderList.get(i);
- appender.doAppend(o);
- }
- }
- return size;
- }
-
- /**
- * Get all attached appenders as an Enumeration. If there are no attached
- * appenders <code>null</code> is returned.
- *
- * @return Enumeration An enumeration of attached appenders.
- */
- public Iterator iteratorForAppenders() {
- return appenderList.iterator();
- }
-
- /**
- * Look for an attached appender named as <code>name</code>.
- *
- * <p>
- * Return the appender with that name if in the list. Return null otherwise.
- *
- */
- public Appender getAppender(String name) {
- if ((appenderList == null) || (name == null)) {
- return null;
- }
-
- int size = appenderList.size();
- Appender appender;
-
- for (int i = 0; i < size; i++) {
- appender = (Appender) appenderList.get(i);
-
- if (name.equals(appender.getName())) {
- return appender;
- }
- }
-
- return null;
- }
-
- /**
- * Returns <code>true</code> if the specified appender is in the list of
- * attached appenders, <code>false</code> otherwise.
- *
- * @since 1.2
- */
- public boolean isAttached(Appender appender) {
- if ((appenderList == null) || (appender == null)) {
- return false;
- }
-
- int size = appenderList.size();
- Appender a;
-
- for (int i = 0; i < size; i++) {
- a = (Appender) appenderList.get(i);
-
- if (a == appender) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Remove and stop all previously attached appenders.
- */
- public void detachAndStopAllAppenders() {
- if (appenderList != null) {
- int len = appenderList.size();
-
- for (int i = 0; i < len; i++) {
- Appender a = (Appender) appenderList.get(i);
- a.stop();
- }
-
- appenderList.clear();
- }
- }
-
- /**
- * Remove the appender passed as parameter form the list of attached
- * appenders.
- */
- public boolean detachAppender(Appender appender) {
- if ((appender == null) || (appenderList == null)) {
- return false;
- }
- return appenderList.remove(appender);
- }
-
- /**
- * Remove the appender with the name passed as parameter form the list of
- * appenders.
- */
- public Appender detachAppender(String name) {
- if ((name == null) || (appenderList == null)) {
- return null;
- }
-
- int size = appenderList.size();
-
- for (int i = 0; i < size; i++) {
- if (name.equals(((Appender) appenderList.get(i)).getName())) {
- return (Appender) appenderList.remove(i);
- }
- }
- return null;
- }
+ /**
+ * Attach an appender. If the appender is already in the list in won't be
+ * added again.
+ */
+ public void addAppender(Appender newAppender) {
+ // Null values for newAppender parameter are strictly forbidden.
+ if (newAppender == null) {
+ throw new IllegalArgumentException("Cannot null as an appener");
+ }
+ if (!appenderList.contains(newAppender)) {
+ appenderList.add(newAppender);
+ }
+ }
+
+ /**
+ * Call the <code>doAppend</code> method on all attached appenders.
+ */
+ public int appendLoopOnAppenders(Object o) {
+ int size = 0;
+ Appender appender;
+
+ size = appenderList.size();
+ for (int i = 0; i < size; i++) {
+ appender = (Appender) appenderList.get(i);
+ appender.doAppend(o);
+ }
+ return size;
+ }
+
+ /**
+ * Get all attached appenders as an Enumeration. If there are no attached
+ * appenders <code>null</code> is returned.
+ *
+ * @return Enumeration An enumeration of attached appenders.
+ */
+ public Iterator iteratorForAppenders() {
+ return appenderList.iterator();
+ }
+
+ /**
+ * Look for an attached appender named as <code>name</code>.
+ *
+ * <p>
+ * Return the appender with that name if in the list. Return null otherwise.
+ *
+ */
+ public Appender getAppender(String name) {
+ if (name == null) {
+ return null;
+ }
+
+ int size = appenderList.size();
+ Appender appender;
+
+ for (int i = 0; i < size; i++) {
+ appender = (Appender) appenderList.get(i);
+
+ if (name.equals(appender.getName())) {
+ return appender;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns <code>true</code> if the specified appender is in the list of
+ * attached appenders, <code>false</code> otherwise.
+ *
+ * @since 1.2
+ */
+ public boolean isAttached(Appender appender) {
+ if (appender == null) {
+ return false;
+ }
+
+ int size = appenderList.size();
+ Appender a;
+
+ for (int i = 0; i < size; i++) {
+ a = (Appender) appenderList.get(i);
+
+ if (a == appender) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Remove and stop all previously attached appenders.
+ */
+ public void detachAndStopAllAppenders() {
+ int len = appenderList.size();
+
+ for (int i = 0; i < len; i++) {
+ Appender a = (Appender) appenderList.get(i);
+ a.stop();
+ }
+
+ appenderList.clear();
+ }
+
+ /**
+ * Remove the appender passed as parameter form the list of attached
+ * appenders.
+ */
+ public boolean detachAppender(Appender appender) {
+ if (appender == null) {
+ return false;
+ }
+ return appenderList.remove(appender);
+ }
+
+ /**
+ * Remove the appender with the name passed as parameter form the list of
+ * appenders.
+ */
+ public Appender detachAppender(String name) {
+ if (name == null) {
+ return null;
+ }
+
+ int size = appenderList.size();
+
+ for (int i = 0; i < size; i++) {
+ if (name.equals(((Appender) appenderList.get(i)).getName())) {
+ return (Appender) appenderList.remove(i);
+ }
+ }
+ return null;
+ }
}
More information about the logback-dev
mailing list