Merge branch 'develop' into feature/JAL-3390hideUnmappedStructure
[jalview.git] / src / jalview / javascript / log4j / Layout.java
diff --git a/src/jalview/javascript/log4j/Layout.java b/src/jalview/javascript/log4j/Layout.java
new file mode 100644 (file)
index 0000000..ea79e1b
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview 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 General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.javascript.log4j;
+
+import jalview.javascript.log4j.spi.LoggingEvent;
+import jalview.javascript.log4j.spi.OptionHandler;
+
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.TTCCLayout;
+
+public abstract class Layout implements OptionHandler
+{
+
+  // Note that the line.separator property can be looked up even by
+  // applets.
+  public final static String LINE_SEP = System
+          .getProperty("line.separator");
+
+  public final static int LINE_SEP_LEN = LINE_SEP.length();
+
+  /**
+   * Implement this method to create your own layout format.
+   */
+  abstract public String format(LoggingEvent event);
+
+  /**
+   * Returns the content type output by this layout. The base class returns
+   * "text/plain".
+   */
+  public String getContentType()
+  {
+    return "text/plain";
+  }
+
+  /**
+   * Returns the header for the layout format. The base class returns
+   * <code>null</code>.
+   */
+  public String getHeader()
+  {
+    return null;
+  }
+
+  /**
+   * Returns the footer for the layout format. The base class returns
+   * <code>null</code>.
+   */
+  public String getFooter()
+  {
+    return null;
+  }
+
+  /**
+   * If the layout handles the throwable object contained within
+   * {@link LoggingEvent}, then the layout should return <code>false</code>.
+   * Otherwise, if the layout ignores throwable object, then the layout should
+   * return <code>true</code>. If ignoresThrowable is true, the appender is
+   * responsible for rendering the throwable.
+   * <p>
+   * The {@link SimpleLayout}, {@link TTCCLayout}, {@link PatternLayout} all
+   * return <code>true</code>. The {@link org.apache.log4j.xml.XMLLayout}
+   * returns <code>false</code>.
+   * 
+   * @since 0.8.4
+   */
+  abstract public boolean ignoresThrowable();
+
+}