View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17
    18  package org.apache.log4j.chainsaw;
    19
    20  import java.awt.Cursor;
    21  import java.awt.Point;
    22  import java.awt.Toolkit;
    23  import java.util.ArrayList;
    24  import java.util.List;
    25
    26  import javax.swing.ImageIcon;
    27
    28  import org.apache.log4j.chainsaw.icons.ChainsawIcons;
    29
    30
    31  /**
    32   * @author Paul Smith &lt;psmith@apache.org&gt;
    33   *
    34   */
    35  public class ChainsawColumns {
    36    private static final List columnNames = new ArrayList();
    37
    38    static {
    39      columnNames.add(ChainsawConstants.LOGGER_COL_NAME);
    40      columnNames.add(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE.toUpperCase()); //add uppercase col name
    41      columnNames.add(ChainsawConstants.TIMESTAMP_COL_NAME);
    42      columnNames.add(ChainsawConstants.LEVEL_COL_NAME);
    43      columnNames.add(ChainsawConstants.THREAD_COL_NAME);
    44      columnNames.add(ChainsawConstants.MESSAGE_COL_NAME);
    45      columnNames.add(ChainsawConstants.NDC_COL_NAME);
    46      columnNames.add(ChainsawConstants.THROWABLE_COL_NAME);
    47      columnNames.add(ChainsawConstants.CLASS_COL_NAME);
    48      columnNames.add(ChainsawConstants.METHOD_COL_NAME);
    49      columnNames.add(ChainsawConstants.FILE_COL_NAME);
    50      columnNames.add(ChainsawConstants.MILLIS_DELTA_COL_NAME_LOWERCASE.toUpperCase()); //add uppercase col name
    51      columnNames.add(ChainsawConstants.LINE_COL_NAME);
    52
    53      //NOTE:  ID must ALWAYS be last field because the model adds this value itself as an identifier to the end of the consructed vector
    54      columnNames.add(ChainsawConstants.ID_COL_NAME);
    55    }
    56
    57    public static final int INDEX_LOGGER_COL_NAME = 1;
    58    public static final int INDEX_LOG4J_MARKER_COL_NAME = 2;
    59    public static final int INDEX_TIMESTAMP_COL_NAME = 3;
    60    public static final int INDEX_LEVEL_COL_NAME = 4;
    61    public static final int INDEX_THREAD_COL_NAME = 5;
    62    public static final int INDEX_MESSAGE_COL_NAME = 6;
    63    public static final int INDEX_NDC_COL_NAME = 7;
    64    public static final int INDEX_THROWABLE_COL_NAME = 8;
    65    public static final int INDEX_CLASS_COL_NAME = 9;
    66    public static final int INDEX_METHOD_COL_NAME = 10;
    67    public static final int INDEX_FILE_COL_NAME = 11;
    68    public static final int INDEX_LINE_COL_NAME = 12;
    69    public static final int INDEX_MILLIS_DELTA_COL_NAME = 13;
    70    public static final int INDEX_ID_COL_NAME = 14;
    71
    72   public static final Cursor CURSOR_FOCUS_ON;
    73   static{
    74   	CURSOR_FOCUS_ON = Toolkit.getDefaultToolkit().createCustomCursor(new ImageIcon(ChainsawIcons.WINDOW_ICON).getImage(), new Point(3,3), "FocusOn");
    75   }
    76
    77    private ChainsawColumns() {
    78    }
    79
    80    public static List getColumnsNames() {
    81      return columnNames;
    82    }
    83
    84    /**
    85     * Given the index which matches one of the static constants in this class, returns the resolved
    86     * Column name as a string label.
    87     * @param columnIndex (note this is a 1 based collection)
    88     * @return column name
    89     */
    90    public static String getColumnName(int columnIndex) {
    91      return getColumnsNames().get(columnIndex - 1).toString();
    92    }
    93  }