001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017package org.apache.log4j.spi; 018 019/** 020 The internal representation of caller location information. 021 022 @since 0.8.3 023 */ 024public class LocationInfo implements java.io.Serializable { 025 026 private final StackTraceElement element; 027 028 public String fullInfo; 029 030 public LocationInfo(StackTraceElement element) { 031 this.element = element; 032 } 033 034 /** 035 When location information is not available the constant 036 <code>NA</code> is returned. Current value of this string 037 constant is <b>?</b>. */ 038 public final static String NA = "?"; 039 040 static final long serialVersionUID = -1325822038990805636L; 041 042 043 /** 044 Return the fully qualified class name of the caller making the 045 logging request. 046 */ 047 public 048 String getClassName() { 049 return element.getClassName(); 050 } 051 052 /** 053 Return the file name of the caller. 054 */ 055 public 056 String getFileName() { 057 return element.getFileName(); 058 } 059 060 /** 061 Returns the line number of the caller. 062 */ 063 public 064 String getLineNumber() { 065 return Integer.toString(element.getLineNumber()); 066 } 067 068 /** 069 Returns the method name of the caller. 070 */ 071 public 072 String getMethodName() { 073 return element.getMethodName(); 074 } 075}