Example usage for java.lang Throwable Throwable

List of usage examples for java.lang Throwable Throwable

Introduction

In this page you can find the example usage for java.lang Throwable Throwable.

Prototype

public Throwable() 

Source Link

Document

Constructs a new throwable with null as its detail message.

Usage

From source file:com.amossys.hooker.hookers.Hooker.java

protected void hookMethodsWithOutputs(final HookerListener listener, final String className,
        final Map<String, Integer> methods, final Map<String, Object> outputs)
        throws HookerInitializationException {

    final String hookerName = this.getHookerName();

    MS.hookClassLoad(className, new MS.ClassLoadHook() {

        @SuppressWarnings({ "unchecked", "rawtypes" })
        public void classLoaded(Class<?> resources) {

            /**/*from  ww w . jav a 2  s.  co m*/
             * Based on the name of the method, we retrieve all the possibilities
             */
            Map<GenericDeclaration, String> methodsToHook = new HashMap<GenericDeclaration, String>();
            boolean found;
            for (String methodName : methods.keySet()) {
                found = false;

                /**
                 * Checks if the requested method is a constructor or not
                 */
                if (className.substring(className.lastIndexOf('.') + 1).equals(methodName)) {
                    found = true;
                    for (int iConstructor = 0; iConstructor < resources
                            .getConstructors().length; iConstructor++) {
                        methodsToHook.put(resources.getConstructors()[iConstructor], methodName);
                    }
                } else {
                    for (Method m : resources.getMethods()) {
                        if (m.getName().equals(methodName)) {
                            found = true;
                            methodsToHook.put(m, methodName);
                        }
                    }
                }
                if (!found) {
                    SubstrateMain.log(new StringBuilder("No method found with name ").append(className)
                            .append(":").append(methodName).toString());
                }
            }

            for (final GenericDeclaration pMethod : methodsToHook.keySet()) {
                final String methodName = methodsToHook.get(pMethod);
                if (SubstrateMain.DEBUG_MODE) {
                    SubstrateMain.log(new StringBuilder("Hooking method ").append(className).append(":")
                            .append(methodName).toString());
                }

                // To debug Substrate if you have a stacktrace
                // for (Class param : ((Method) pMethod).getParameterTypes()) {
                // SubstrateMain.log("   Param: " + param.getSimpleName());
                // }

                final int intrusiveLevelFinal = methods.get(methodName);

                final MS.MethodPointer<Object, Object> old = new MethodPointer<Object, Object>();
                MS.hookMethod_(resources, (Member) pMethod, new MS.MethodHook() {
                    public Object invoked(final Object resources, final Object... args) throws Throwable {

                        if (ApplicationConfig.isFiltered() || ApplicationConfig.getPackageName() == null) {
                            return old.invoke(resources, args);
                        }

                        if (isSelfHooking((Member) pMethod)) {
                            SubstrateMain.log(
                                    "Self hooking detected on method '" + ((Member) pMethod).getName() + "'.");
                            return old.invoke(resources, args);
                        }

                        final String packName = ApplicationConfig.getPackageName();
                        final Context appContext = ApplicationConfig.getContext();

                        InterceptEvent event = null;

                        if (packName != null && appContext != null) {

                            // Open the connection to the service if not yet bound
                            if (!serviceConnection.isBoundToTheService()) {
                                serviceConnection.doBindService(appContext);
                            }

                            // Create the intercept event for this hook
                            event = new InterceptEvent(hookerName, intrusiveLevelFinal,
                                    System.identityHashCode(resources), packName, className, methodName);

                            //TODO: We should also save the parameters value before the call.
                            //      it requires to clone the parameters
                            //      and save them in the event if their value is different after the call

                            /**
                             * If specified, we execute the before method of the provided listener
                             */
                            if (listener != null) {
                                listener.before(className, pMethod, resources, event);
                            }

                        }

                        /**
                         * We invoke the original method and capture the result
                         */
                        Object result = old.invoke(resources, args);

                        // if requested we modify the output value of the invocation
                        if (outputs != null && outputs.containsKey(methodName)) {

                            if (result == null || outputs.get(methodName) == null
                                    || result.getClass().isAssignableFrom(outputs.get(methodName).getClass())) {
                                result = outputs.get(methodName);
                            } else {
                                SubstrateMain.log("Cannot replace method " + methodName + " output with "
                                        + outputs.get(methodName) + ": types are incompatible.", false);
                            }
                        }

                        // Store the result in the event (if available)
                        if (event != null && appContext != null) {

                            // Register the parameters of the method call in the event
                            if (args != null) {
                                for (Object arg : args) {
                                    if (arg != null) {
                                        String argValue = getStringRepresentationOfAttribute(arg);
                                        event.addParameter(arg.getClass().getName(), argValue);
                                    } else {
                                        event.addParameter(null, null);
                                    }
                                }
                            }

                            // if the invocation returned something we store it in the event
                            if (result != null) {
                                String strResult = getStringRepresentationOfAttribute(result);
                                event.setReturns(result.getClass().getName(), strResult);
                            } else {
                                event.setReturns(null, null);
                            }

                            /**
                             * if specified, we execute the after method of the provided listener
                             */
                            if (listener != null) {
                                listener.after(className, pMethod, resources, event);
                            }

                            insertEvent(event, appContext);
                        }

                        return result;
                    }

                    /**
                     * Computes if we are self hooking ourselves. To do so, we generate a stack trace to retrieve
                     * the caller list of the current invocation and check no Hooker appears after the second entry of the stack trace.
                     * @param pMethod 
                     * @param pMethod 
                     * @return true if we are self-hooking
                     */
                    private boolean isSelfHooking(Member pMethod) {
                        boolean selfHooking = false;
                        StackTraceElement[] stackTrace = new Throwable().getStackTrace();
                        if (stackTrace.length > 2) {
                            for (int i = 2; i < stackTrace.length; i++) {
                                if (stackTrace[i].getClassName().startsWith(Hooker.class.getName())) {
                                    selfHooking = true;
                                    break;
                                }
                            }
                        }
                        return selfHooking;
                    }

                }, old);
            }

        }
    });

}

From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java

/**
 * <p>Suitable for logging methods with <code>void</code> return type.</p>
 * @see java.util.logging.Level#FINER// w w w  .  j  ava  2  s  . c o  m
 */
public void exiting() {
    StackTraceElement[] elements = new Throwable().getStackTrace();
    exiting(elements[1].getClassName(), elements[1].getMethodName());
}

From source file:com.baidu.cafe.local.record.WebElementRecorder.java

public void setHookedWebChromeClient(final WebView webView) {
    webElementEventCreator.prepareForStart();
    if (webView != null) {
        webView.post(new Runnable() {
            public void run() {
                webView.getSettings().setJavaScriptEnabled(true);
                final WebChromeClient originalWebChromeClient = getOriginalWebChromeClient(webView);
                if (originalWebChromeClient != null) {
                    webView.setWebChromeClient(new WebChromeClient() {
                        HashMap<String, Boolean> invoke = new HashMap<String, Boolean>();

                        /**
                         * Overrides onJsPrompt in order to create
                         * {@code WebElement} objects based on the web
                         * elements attributes prompted by the injections of
                         * JavaScript/*from  w  ww  .  j a v a  2 s .  c om*/
                         */

                        @Override
                        public boolean onJsPrompt(WebView view, String url, String message, String defaultValue,
                                JsPromptResult r) {

                            if (message != null) {
                                if (message.endsWith("WebElementRecorder-finished")) {
                                    // Log.i("onJsPrompt : " + message);
                                    webElementEventCreator.setFinished(true);
                                } else {
                                    webElementEventCreator.createWebElementEvent(message, view);
                                }
                            }
                            r.confirm();
                            return true;
                        }

                        @Override
                        public Bitmap getDefaultVideoPoster() {
                            Bitmap ret = null;
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                ret = originalWebChromeClient.getDefaultVideoPoster();
                                invoke.put(funcName, false);
                            }
                            return ret;
                        }

                        @Override
                        public View getVideoLoadingProgressView() {
                            View ret = null;
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                ret = originalWebChromeClient.getVideoLoadingProgressView();
                                invoke.put(funcName, false);
                            }
                            return ret;
                        }

                        @Override
                        public void getVisitedHistory(ValueCallback<String[]> callback) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.getVisitedHistory(callback);
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public void onCloseWindow(WebView window) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onCloseWindow(window);
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
                            boolean ret = false;
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                ret = originalWebChromeClient.onConsoleMessage(consoleMessage);
                                invoke.put(funcName, false);
                            }
                            return ret;
                        }

                        @Override
                        public void onConsoleMessage(String message, int lineNumber, String sourceID) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onConsoleMessage(message, lineNumber, sourceID);
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture,
                                Message resultMsg) {
                            boolean ret = false;
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                ret = originalWebChromeClient.onCreateWindow(view, isDialog, isUserGesture,
                                        resultMsg);
                                invoke.put(funcName, false);
                            }
                            return ret;
                        }

                        @Override
                        public void onExceededDatabaseQuota(String url, String databaseIdentifier, long quota,
                                long estimatedDatabaseSize, long totalQuota, QuotaUpdater quotaUpdater) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onExceededDatabaseQuota(url, databaseIdentifier, quota,
                                        estimatedDatabaseSize, totalQuota, quotaUpdater);
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public void onGeolocationPermissionsHidePrompt() {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onGeolocationPermissionsHidePrompt();
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onGeolocationPermissionsShowPrompt(origin, callback);
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public void onHideCustomView() {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onHideCustomView();
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
                            boolean ret = false;
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                ret = originalWebChromeClient.onJsAlert(view, url, message, result);
                                invoke.put(funcName, false);
                            }
                            return ret;
                        }

                        @Override
                        public boolean onJsBeforeUnload(WebView view, String url, String message,
                                JsResult result) {
                            boolean ret = false;
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                ret = originalWebChromeClient.onJsBeforeUnload(view, url, message, result);
                                invoke.put(funcName, false);
                            }
                            return ret;
                        }

                        @Override
                        public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
                            boolean ret = false;
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                ret = originalWebChromeClient.onJsConfirm(view, url, message, result);
                                invoke.put(funcName, false);
                            }
                            return ret;
                        }

                        @Override
                        public boolean onJsTimeout() {
                            boolean ret = false;
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                ret = originalWebChromeClient.onJsTimeout();
                                invoke.put(funcName, false);
                            }
                            return ret;
                        }

                        @Override
                        public void onProgressChanged(WebView view, int newProgress) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onProgressChanged(view, newProgress);
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
                                QuotaUpdater quotaUpdater) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onReachedMaxAppCacheSize(requiredStorage, quota,
                                        quotaUpdater);
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public void onReceivedIcon(WebView view, Bitmap icon) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onReceivedIcon(view, icon);
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public void onReceivedTitle(WebView view, String title) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onReceivedTitle(view, title);
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onReceivedTouchIconUrl(view, url, precomposed);
                                invoke.put(funcName, false);
                            }

                        }

                        @Override
                        public void onRequestFocus(WebView view) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onRequestFocus(view);
                                invoke.put(funcName, false);
                            }
                        }

                        @Override
                        public void onShowCustomView(View view, CustomViewCallback callback) {
                            String funcName = new Throwable().getStackTrace()[1].getMethodName();
                            if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                invoke.put(funcName, true);
                                originalWebChromeClient.onShowCustomView(view, callback);
                                invoke.put(funcName, false);
                            }
                        }

                        public void onShowCustomView(View view, int requestedOrientation,
                                CustomViewCallback callback) {
                            if (Build.VERSION.SDK_INT >= 14) {
                                String funcName = new Throwable().getStackTrace()[1].getMethodName();
                                if (invoke.get(funcName) == null || !invoke.get(funcName)) {
                                    invoke.put(funcName, true);
                                    originalWebChromeClient.onShowCustomView(view, requestedOrientation,
                                            callback);
                                    invoke.put(funcName, false);
                                }
                            }
                        }
                    });
                } else {
                    webView.setWebChromeClient(new WebChromeClient() {

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#getDefaultVideoPoster()
                         */
                        @Override
                        public Bitmap getDefaultVideoPoster() {
                            // TODO Auto-generated method stub
                            return super.getDefaultVideoPoster();
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#getVideoLoadingProgressView()
                         */
                        @Override
                        public View getVideoLoadingProgressView() {
                            // TODO Auto-generated method stub
                            return super.getVideoLoadingProgressView();
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#getVisitedHistory(android.webkit.ValueCallback)
                         */
                        @Override
                        public void getVisitedHistory(ValueCallback<String[]> callback) {
                            // TODO Auto-generated method stub
                            super.getVisitedHistory(callback);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onCloseWindow(android.webkit.WebView)
                         */
                        @Override
                        public void onCloseWindow(WebView window) {
                            // TODO Auto-generated method stub
                            super.onCloseWindow(window);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)
                         */
                        @Override
                        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
                            // TODO Auto-generated method stub
                            return super.onConsoleMessage(consoleMessage);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onConsoleMessage(java.lang.String, int, java.lang.String)
                         */
                        @Override
                        public void onConsoleMessage(String message, int lineNumber, String sourceID) {
                            // TODO Auto-generated method stub
                            super.onConsoleMessage(message, lineNumber, sourceID);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onCreateWindow(android.webkit.WebView, boolean, boolean, android.os.Message)
                         */
                        @Override
                        public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture,
                                Message resultMsg) {
                            // TODO Auto-generated method stub
                            return super.onCreateWindow(view, isDialog, isUserGesture, resultMsg);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onExceededDatabaseQuota(java.lang.String, java.lang.String, long, long, long, android.webkit.WebStorage.QuotaUpdater)
                         */
                        @Override
                        public void onExceededDatabaseQuota(String url, String databaseIdentifier, long quota,
                                long estimatedDatabaseSize, long totalQuota, QuotaUpdater quotaUpdater) {
                            // TODO Auto-generated method stub
                            super.onExceededDatabaseQuota(url, databaseIdentifier, quota, estimatedDatabaseSize,
                                    totalQuota, quotaUpdater);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onGeolocationPermissionsHidePrompt()
                         */
                        @Override
                        public void onGeolocationPermissionsHidePrompt() {
                            // TODO Auto-generated method stub
                            super.onGeolocationPermissionsHidePrompt();
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String, android.webkit.GeolocationPermissions.Callback)
                         */
                        @Override
                        public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
                            // TODO Auto-generated method stub
                            super.onGeolocationPermissionsShowPrompt(origin, callback);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onHideCustomView()
                         */
                        @Override
                        public void onHideCustomView() {
                            // TODO Auto-generated method stub
                            super.onHideCustomView();
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onJsAlert(android.webkit.WebView, java.lang.String, java.lang.String, android.webkit.JsResult)
                         */
                        @Override
                        public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
                            // TODO Auto-generated method stub
                            return super.onJsAlert(view, url, message, result);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onJsBeforeUnload(android.webkit.WebView, java.lang.String, java.lang.String, android.webkit.JsResult)
                         */
                        @Override
                        public boolean onJsBeforeUnload(WebView view, String url, String message,
                                JsResult result) {
                            // TODO Auto-generated method stub
                            return super.onJsBeforeUnload(view, url, message, result);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onJsConfirm(android.webkit.WebView, java.lang.String, java.lang.String, android.webkit.JsResult)
                         */
                        @Override
                        public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
                            // TODO Auto-generated method stub
                            return super.onJsConfirm(view, url, message, result);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onJsPrompt(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String, android.webkit.JsPromptResult)
                         */
                        @Override
                        public boolean onJsPrompt(WebView view, String url, String message, String defaultValue,
                                JsPromptResult result) {
                            if (message != null) {
                                if (message.endsWith("WebElementRecorder-finished")) {
                                    // Log.i("onJsPrompt : " + message);
                                    webElementEventCreator.setFinished(true);
                                } else {
                                    webElementEventCreator.createWebElementEvent(message, view);
                                }
                            }
                            result.confirm();
                            return true;
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onJsTimeout()
                         */
                        @Override
                        public boolean onJsTimeout() {
                            // TODO Auto-generated method stub
                            return super.onJsTimeout();
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onProgressChanged(android.webkit.WebView, int)
                         */
                        @Override
                        public void onProgressChanged(WebView view, int newProgress) {
                            // TODO Auto-generated method stub
                            super.onProgressChanged(view, newProgress);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onReachedMaxAppCacheSize(long, long, android.webkit.WebStorage.QuotaUpdater)
                         */
                        @Override
                        public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
                                QuotaUpdater quotaUpdater) {
                            // TODO Auto-generated method stub
                            super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onReceivedIcon(android.webkit.WebView, android.graphics.Bitmap)
                         */
                        @Override
                        public void onReceivedIcon(WebView view, Bitmap icon) {
                            // TODO Auto-generated method stub
                            super.onReceivedIcon(view, icon);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onReceivedTitle(android.webkit.WebView, java.lang.String)
                         */
                        @Override
                        public void onReceivedTitle(WebView view, String title) {
                            // TODO Auto-generated method stub
                            super.onReceivedTitle(view, title);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView, java.lang.String, boolean)
                         */
                        @Override
                        public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed) {
                            // TODO Auto-generated method stub
                            super.onReceivedTouchIconUrl(view, url, precomposed);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onRequestFocus(android.webkit.WebView)
                         */
                        @Override
                        public void onRequestFocus(WebView view) {
                            // TODO Auto-generated method stub
                            super.onRequestFocus(view);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onShowCustomView(android.view.View, android.webkit.WebChromeClient.CustomViewCallback)
                         */
                        @Override
                        public void onShowCustomView(View view, CustomViewCallback callback) {
                            // TODO Auto-generated method stub
                            super.onShowCustomView(view, callback);
                        }

                        /* (non-Javadoc)
                         * @see android.webkit.WebChromeClient#onShowCustomView(android.view.View, int, android.webkit.WebChromeClient.CustomViewCallback)
                         */
                        @Override
                        public void onShowCustomView(View view, int requestedOrientation,
                                CustomViewCallback callback) {
                            // TODO Auto-generated method stub
                            super.onShowCustomView(view, requestedOrientation, callback);
                        }

                    });
                }
            }
        });
    }
}

From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java

/**
 * Exiting./*from  ww w.j  a  v  a 2 s . co  m*/
 *
 * @param result The result of the method call
 * @see java.util.logging.Level#FINER
 */
public void exiting(Object result) {
    StackTraceElement[] elements = new Throwable().getStackTrace();
    exiting(elements[1].getClassName(), elements[1].getMethodName(), result);
}

From source file:fungus.HyphaLink.java

public void transferNeighbor(MycoNode neighbor, MycoNode target) {
    if (neighbor != null && target != null) {
        if (neighbor == target) {
            log.log(Level.FINER, myNode + " TRIED TO TRANSFER " + neighbor + " TO ITSELF.",
                    new Object[] { myNode, neighbor });
            return;
        }/*from   ww  w . j ava 2  s . com*/
        neighbors.remove(neighbor);
        fireLinkRemoved(neighbor);
        HyphaLink neighborLink = ((HyphaLink) neighbor.getProtocol(hyphaLinkPid));
        neighborLink.pruneNeighbor(myNode);

        if (areNeighbors(neighbor, target)) {
            log.log(Level.FINER, myNode + " TRIED TO TRANSFER " + target + " TO " + neighbor
                    + " BUT ARE ALREADY " + "CONNECTED", new Object[] { myNode, neighbor, target });
            return;
        }
        log.log(Level.FINER, myNode + " TRANSFERS " + neighbor + " TO " + target,
                new Object[] { myNode, neighbor, target });
        HyphaLink targetLink = target.getHyphaLink();
        targetLink.addNeighbor(neighbor);
    } else {
        log.log(Level.WARNING, "BAD TRANSFER attempted from " + myNode + " TO " + target,
                new Object[] { myNode, neighbor, target });
        (new Throwable()).printStackTrace();
        //FIXME: Warning
    }
}

From source file:mobisocial.socialkit.musubi.Musubi.java

/**
 * Returns all DbIdentities owned by the current user
 *///from  www  . ja  va 2 s .  c om
public List<DbIdentity> users(Uri feedUri) {
    Uri uri;
    if (feedUri == null) {
        uri = uriForDir(DbThing.IDENTITY);
    } else {
        long feedId = ContentUris.parseId(feedUri);
        uri = uriForItem(DbThing.MEMBER, feedId);
    }
    String selection = DbIdentity.COL_OWNED + " = 1";
    String[] selectionArgs = null;
    String sortOrder = null;
    Cursor c = mContext.getContentResolver().query(uri, DbIdentity.COLUMNS, selection, selectionArgs,
            sortOrder);
    try {
        List<DbIdentity> identities = new LinkedList<DbIdentity>();
        if (c == null || c.getCount() == 0) {
            Log.w(TAG, "no local user for feed " + feedUri, new Throwable());
            return identities;
        }
        while (c.moveToNext()) {
            DbIdentity id = DbIdentity.fromStandardCursor(mContext, c);
            identities.add(id);
        }
        return identities;
    } finally {
        if (c != null) {
            c.close();
        }
    }
}

From source file:com.xhsoft.framework.common.utils.ClassUtil.java

/**
 * /*from w  w w . ja  v  a2  s.  c  o  m*/
 * @return - String
 * @author: lizj
 */
public static String getCallerName(int depth) {
    String JDK_VERSION = System.getProperty("java.version");

    double version = 1.3D;

    try {
        JDK_VERSION = JDK_VERSION.substring(0, 3);

        version = Double.parseDouble(JDK_VERSION);
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }

    if (DEBUG) {
        log.debug("java.version: " + version);
    }

    if (version >= 1.5D) {
        try {
            Thread currentThread = Thread.currentThread();

            StackTraceElement[] stack = (StackTraceElement[]) (Thread.class
                    .getMethod("getStackTrace", new Class[0]).invoke(currentThread, new Object[0]));

            if (stack != null && stack.length >= 3) {
                for (int i = 0; i < stack.length; i++) {
                    if (stack[i].getClassName().equals(ClassUtil.class.getName())
                            && "getCallerName".equals(stack[i].getMethodName())) {
                        if (i + 2 + depth < stack.length) {
                            return stack[i + 2 + depth].getClassName() + "."
                                    + stack[i + 2 + depth].getMethodName();
                        }
                    }
                }

                return null;
            }
        } catch (IllegalArgumentException e1) {
            e1.printStackTrace();
        } catch (SecurityException e1) {
            e1.printStackTrace();
        } catch (IllegalAccessException e1) {
            e1.printStackTrace();
        } catch (InvocationTargetException e1) {
            e1.printStackTrace();
        } catch (NoSuchMethodException e1) {
            e1.printStackTrace();
        }
    } else if (version >= 1.4D) {
        StackTraceElement[] stack = (new Throwable()).getStackTrace();

        if (stack != null && stack.length >= (3 + depth)) {
            return stack[2 + depth].getClassName() + "." + stack[2 + depth].getMethodName();
        }
    }

    java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(4096);

    new Throwable().printStackTrace(new java.io.PrintStream(bos));

    String x = bos.toString();

    java.io.BufferedReader br = new java.io.BufferedReader(new java.io.StringReader(x));

    String val = null;
    String str = null;

    try {
        int i = 0;

        while ((str = br.readLine()) != null) {
            if (i++ == (3 + depth)) {
                str = StringUtil.getA5(str, "at ");

                val = str = StringUtil.getB4(str, "(");
            }
        }
    } catch (IOException e) {
    }

    return val;
}

From source file:com.alipay.vbizplatform.web.controller.MyCarManageController.java

/**
 * ?(?)/* w  w  w.  j  a  v  a2s.co m*/
 * @param request
 * @param response
 * @return
 */
@RequestMapping(value = "/queryBrand")
public String queryBrand(HttpServletRequest request, HttpServletResponse response) {
    logger.info("uid={},class={},method=queryBrand,desc=?",
            super.getUserInfo(request).getUid(), this.getClass().getName());
    Map<String, String> pageParam = super.getParametersFromPage(request);

    long startTime = System.currentTimeMillis();
    String uId = "";
    try {

        // 1????
        Map<String, List<Map<String, Object>>> brandsMap = myCarManageService.getBrands();
        uId = super.getUserInfo(request).getUid();
        //1?session??
        //?
        Map<String, Object> vo = null;
        //            Object obj = request.getSession().getAttribute("newVehicleModel");

        String vehicleModelKey = uId + VEHICLE_MODEL_KEY_PREFIX;
        Object obj = spyMemcachedClient.get(vehicleModelKey);

        if (obj != null) {
            vo = (HashMap<String, Object>) obj;
            /*****???vo******/
            if (StringUtils.isNotEmpty(pageParam.get("viNumber"))) {
                vo.put("viNumber", URLDecoder.decode(pageParam.get("viNumber"), "UTF-8").toUpperCase());
            }
            if (StringUtils.isNotEmpty(pageParam.get("viStartTime"))) {// 
                vo.put("viStartTime",
                        DateUtil.parserDateFromString(pageParam.get("viStartTime"), DateUtil.DATEFORMAT5));
            }
            if (StringUtils.isNotEmpty(pageParam.get("vlCityId"))) {// 
                vo.put("vlCityId", pageParam.get("vlCityId"));
            }
            if (StringUtils.isNotEmpty(pageParam.get("vlCityName"))) {// ??
                vo.put("vlCityName", URLDecoder.decode(pageParam.get("vlCityName"), "UTF-8"));
            }
            if (null != (pageParam.get("viMileage"))) {// 
                vo.put("viMileage", pageParam.get("viMileage"));
            }
            if (null != (pageParam.get("viVin"))) {// ?
                vo.put("viVin", pageParam.get("viVin").toUpperCase());
            }
            if (null != (pageParam.get("engineNo"))) {// ?
                vo.put("engineNo", pageParam.get("engineNo").toUpperCase());
            }
            //                request.getSession().setAttribute("newVehicleModel", vo);
            this.spyMemcachedClient.set(vehicleModelKey, Constant.MEMCACHED_SAVETIME_24, vo);
        }

        //2????
        request.setAttribute("brandsMap", brandsMap);
        request.setAttribute("brandSize", brandsMap.size());
        request.setAttribute("upst", pageParam.get("upst"));
        request.setAttribute("viId", ObjectUtil.toString(pageParam.get("viId")));

        request.setAttribute("newCarFlag", pageParam.get("newCarFlag"));
        request.setAttribute("fromPage", pageParam.get("fromPage"));
        //3??session
        request.getSession().setAttribute("backUrl", Constant.BACKURLMAP.get(pageParam.get("backUrl")));
    } catch (Exception e) {
        if (logger.isErrorEnabled()) {
            logger.error("??", e);
        }
        logUtil.log(new Throwable(), "BRAND", uId, MethodCallResultEnum.EXCEPTION, null,
                "??", startTime);
        super.redirectErrorPage("BUSY-ERR", "??", null, null, response);
        return null;
    }
    if (logger.isInfoEnabled()) {
        logger.info("???,uid={},toPage->page/cars/selectBrand.jsp",
                super.getUserInfo(request).getUid());
    }
    logUtil.log(new Throwable(), "BRAND", uId, MethodCallResultEnum.SUCCESS, null,
            "??", startTime);
    return "page/cars/selectBrand";
}

From source file:com.seleniumtests.ut.reporter.TestTestStep.java

@Test(groups = { "ut" })
public void testTestActionEncodeXmlExceptionKept() {
    TestAction action = new TestAction("action2 \"'<>&", false, new ArrayList<>());
    action.setActionException(new Throwable());
    TestAction encodedAction = action.encode("xml");
    Assert.assertNotNull(encodedAction.getActionException());
}

From source file:org.apache.cxf.common.logging.LogUtils.java

private static void doLog(Logger log, Level level, String msg, Throwable t) {
    LogRecord record = new LogRecord(level, msg);

    record.setLoggerName(log.getName());
    record.setResourceBundleName(log.getResourceBundleName());
    record.setResourceBundle(log.getResourceBundle());

    if (t != null) {
        record.setThrown(t);/* www .j a va  2 s.  com*/
    }

    //try to get the right class name/method name - just trace
    //back the stack till we get out of this class
    StackTraceElement stack[] = (new Throwable()).getStackTrace();
    String cname = LogUtils.class.getName();
    for (int x = 0; x < stack.length; x++) {
        StackTraceElement frame = stack[x];
        if (!frame.getClassName().equals(cname)) {
            record.setSourceClassName(frame.getClassName());
            record.setSourceMethodName(frame.getMethodName());
            break;
        }
    }
    log.log(record);
}