1 /*
2 * Jour - java profiler and monitoring library
3 *
4 * Copyright (C) 2004 Jour team
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21 package net.sf.jour.log4j;
22
23 import java.lang.reflect.Method;
24
25 import org.apache.log4j.spi.LocationInfo;
26
27 /*
28 * Created on 21.11.2004
29 *
30 * Contributing Author(s):
31 *
32 * Misha Lifschitz <mishalifschitz at users.sourceforge.net> (Inital implementation)
33 * Vlad Skarzhevskyy <vlads at users.sourceforge.net> (Inital implementation)
34 */
35 /***
36 * TODO Add docs
37 * @author vlads
38 * @version $Revision: 1.1 $ ($Author: vlads $)
39 */
40 public class WrapedLocationInfo extends LocationInfo {
41
42 private LocationInfo wrapedLocationInfo;
43
44 public final boolean isJava14 = detectJava14();
45
46 private static boolean detectJava14() {
47 try {
48 Method method = (new Throwable()).getClass().getMethod("getStackTrace", null);
49 return true;
50 } catch (NoSuchMethodException e) {
51 return false;
52 }
53 }
54
55 public WrapedLocationInfo(Throwable t, String fqnOfCallingClass) {
56 super(null, null);
57 if (isJava14) {
58 wrapedLocationInfo = new Java14LocationInfo(t, fqnOfCallingClass);
59 } else {
60 wrapedLocationInfo = new LocationInfo(t, fqnOfCallingClass);
61 }
62 }
63
64 /***
65 * @return Returns the className.
66 */
67 public String getClassName() {
68 return wrapedLocationInfo.getClassName();
69 }
70 /***
71 * @return Returns the fileName.
72 */
73 public String getFileName() {
74 return wrapedLocationInfo.getFileName();
75 }
76 /***
77 * @return Returns the lineNumber.
78 */
79 public String getLineNumber() {
80 return wrapedLocationInfo.getLineNumber();
81 }
82 /***
83 * @return Returns the methodName.
84 */
85 public String getMethodName() {
86 return wrapedLocationInfo.getMethodName();
87 }
88 }