All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ui.auto.core.utils.InvocationInfo Maven / Gradle / Ivy

There is a newer version: 1.7.1
Show newest version
/*
Copyright 2010-2012 Michael Braiman

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package ui.auto.core.utils;

public class InvocationInfo {
	private final String className;
	private final String methodName;
	private final int lineNumber;
	private final String fileName;
	static private final String myClassName="ui.auto.core.utils.InvocationInfo";
	
	private InvocationInfo(StackTraceElement stackElement){
		className=stackElement.getClassName();
		methodName=stackElement.getMethodName();
		lineNumber=stackElement.getLineNumber();
		fileName=stackElement.getFileName();
	}
	
	public static InvocationInfo whoAmI(){
		StackTraceElement stackElement=getTraceElement("whoAmI",1);
		if (stackElement!=null){
			return new InvocationInfo(stackElement);
		}
		return null;
	}
	
	public static InvocationInfo whoInvokedMe(){
		StackTraceElement stackElement=getTraceElement("whoInvokedMe",2);
		if (stackElement!=null){
			return new InvocationInfo(stackElement);
		}
		return null;
	}
	
	private static StackTraceElement getTraceElement(String myMethod,int offset){
		StackTraceElement[] els=Thread.currentThread().getStackTrace();
		for (int i=0;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy