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:org.o3project.ocnrm.odenos.linklayerizer.LinkLayerizer.java

private Link createLinkFromFlow(Flow flow) {
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start");

    BasicFlow bfm = (BasicFlow) flow;/*w  w  w  .ja va 2 s  . co  m*/
    Map<String, List<FlowAction>> edgeActions = bfm.getEdgeActions();

    String dstNode = "";
    String dstPort = "";
    String srcNode = "";
    String srcPort = "";

    for (Entry<String, List<FlowAction>> entry : edgeActions.entrySet()) {
        if (edgeActions.entrySet().size() != 1) {
            logger.error("edgeActions size over. size:{}", edgeActions.entrySet().size());
            return null;
        }
        String nodeId = entry.getKey();
        String portId = ((FlowActionOutput) entry.getValue().get(0)).output;

        String[] str = changePortBoundaryLowToUpper(nodeId, portId);
        if (str[0] != null && str[1] != null && str.length != 0 && str[1].length() != 0) {
            logger.debug("** str[0]:" + str[0]);
            logger.debug("** str[1]:" + str[1]);
            dstNode = str[0];
            dstPort = str[1];
            break;
        } else {
            logger.error("boundary not found. NodeId:{}, PortId:{}: ", nodeId, portId);
            return null;
        }
    }

    for (BasicFlowMatch matches : bfm.getMatches()) {
        String[] str = changePortBoundaryLowToUpper(matches.inNode, matches.inPort);
        if (str[0] != null && str[1] != null && str.length != 0 && str[1].length() != 0) {
            srcNode = str[0];
            srcPort = str[1];
            break;
        } else {
            logger.error("boundary not found. matches.in_node:{}, matches.in_port:{}: ", matches.inNode,
                    matches.inPort);
            return null;
        }
    }

    Link link = new Link();
    // set link ports
    link.setPorts(srcNode, srcPort, dstNode, dstPort);

    link.putAttribute(AttrElements.MAX_BANDWIDTH,
            StringUtils.defaultString(flow.getAttribute(AttrElements.BANDWIDTH)));
    link.putAttribute(AttrElements.REQ_BANDWIDTH,
            StringUtils.defaultString(flow.getAttribute(AttrElements.REQ_BANDWIDTH)));
    link.putAttribute(AttrElements.LATENCY, StringUtils.defaultString(flow.getAttribute(AttrElements.LATENCY)));
    link.putAttribute(AttrElements.REQ_LATENCY,
            StringUtils.defaultString(flow.getAttribute(AttrElements.REQ_LATENCY)));
    link.putAttribute(TableManager.TRANSACTION_ID,
            StringUtils.defaultString(flow.getAttribute(TableManager.TRANSACTION_ID)));

    link.putAttribute(AttrElements.ESTABLISHMENT_STATUS, flow.getStatus());
    link.putAttribute(AttrElements.OPER_STATUS, STATUS_DOWN);
    return link;
}

From source file:org.apache.hadoop.security.UserGroupInformation.java

private void logPriviledgedAction(Subject subject, Object action) {
    if (LOG.isDebugEnabled()) {
        // would be nice if action included a descriptive toString()
        String where = new Throwable().getStackTrace()[2].toString();
        LOG.debug("PriviledgedAction as:" + this + " from:" + where);
    }//from  ww  w .jav a 2 s .c  om
}

From source file:org.docx4j.XmlUtils.java

/**
 * /*from   w  w  w .  j ava2  s .c o m*/
 * Transform an input document using XSLT
 * 
 * @param doc
 * @param xslt
 * @param transformParameters
 * @param result
 * @throws Docx4JException In case serious transformation errors occur
 */
public static void transform(javax.xml.transform.Source source, javax.xml.transform.Templates template,
        Map<String, Object> transformParameters, javax.xml.transform.Result result) throws Docx4JException {

    if (source == null) {
        Throwable t = new Throwable();
        throw new Docx4JException("Null Source doc", t);
    }

    // Use the template to create a transformer
    // A Transformer may not be used in multiple threads running concurrently. 
    // Different Transformers may be used concurrently by different threads.
    // A Transformer may be used multiple times. Parameters and output properties 
    // are preserved across transformations.      
    javax.xml.transform.Transformer xformer;
    try {
        xformer = template.newTransformer();
    } catch (TransformerConfigurationException e) {
        throw new Docx4JException("The Transformer is ill-configured", e);
    }

    log.info("Using " + xformer.getClass().getName());

    if (xformer.getClass().getName().equals("org.apache.xalan.transformer.TransformerImpl")) {

        if (Docx4jProperties.getProperty("docx4j.xalan.XALANJ-2419.workaround", false)) {
            // Use our patched serializer, which fixes Unicode astral character
            // issue. See https://issues.apache.org/jira/browse/XALANJ-2419

            log.info("Working around https://issues.apache.org/jira/browse/XALANJ-2419");

            Properties p = xformer.getOutputProperties();
            String method = p.getProperty("method");
            System.out.println("method: " + method);
            if (method == null || method.equals("xml")) {

                ((org.apache.xalan.transformer.TransformerImpl) xformer).setOutputProperty(
                        S_KEY_CONTENT_HANDLER, "org.docx4j.org.apache.xml.serializer.ToXMLStream");

            } else if (method.equals("html")) {

                ((org.apache.xalan.transformer.TransformerImpl) xformer).setOutputProperty(
                        S_KEY_CONTENT_HANDLER, "org.docx4j.org.apache.xml.serializer.ToHTMLStream");

            } else if (method.equals("text")) {

                ((org.apache.xalan.transformer.TransformerImpl) xformer).setOutputProperty(
                        S_KEY_CONTENT_HANDLER, "org.docx4j.org.apache.xml.serializer.ToTextStream");

            } else {

                log.warn("fallback for method: " + method);
                ((org.apache.xalan.transformer.TransformerImpl) xformer).setOutputProperty(
                        S_KEY_CONTENT_HANDLER, "org.docx4j.org.apache.xml.serializer.ToUnknownStream");

            }

            /* That wasn't quite enough:
             * 
               at org.docx4j.org.apache.xml.serializer.ToXMLStream.startDocumentInternal(ToXMLStream.java:143)
               at org.docx4j.org.apache.xml.serializer.SerializerBase.startDocument(SerializerBase.java:1190)
               at org.apache.xml.serializer.ToSAXHandler.startDocumentInternal(ToSAXHandler.java:97)
               at org.apache.xml.serializer.ToSAXHandler.flushPending(ToSAXHandler.java:273)
               at org.apache.xml.serializer.ToXMLSAXHandler.startPrefixMapping(ToXMLSAXHandler.java:350)
               at org.apache.xml.serializer.ToXMLSAXHandler.startPrefixMapping(ToXMLSAXHandler.java:320)
               at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1317)
             *
             * (TransformerImpl's createSerializationHandler makes a new org.apache.xml.serializer.ToXMLSAXHandler.ToXMLSAXHandler
             * and that's hard coded.)
             * 
             * But it seems to be enough now...
                        
             */
        }

    } else {

        log.error("Detected " + xformer.getClass().getName()
                + ", but require org.apache.xalan.transformer.TransformerImpl. "
                + "Ensure Xalan 2.7.x is on your classpath!");
    }
    LoggingErrorListener errorListener = new LoggingErrorListener(false);
    xformer.setErrorListener(errorListener);

    if (transformParameters != null) {
        Iterator parameterIterator = transformParameters.entrySet().iterator();
        while (parameterIterator.hasNext()) {
            Map.Entry pairs = (Map.Entry) parameterIterator.next();

            if (pairs.getKey() == null) {
                log.info("Skipped null key");
                // pairs = (Map.Entry)parameterIterator.next();
                continue;
            }

            if (pairs.getKey().equals("customXsltTemplates"))
                continue;

            if (pairs.getValue() == null) {
                log.warn("parameter '" + pairs.getKey() + "' was null.");
            } else {
                xformer.setParameter((String) pairs.getKey(), pairs.getValue());
            }
        }
    }

    /* SUPER DEBUGGING
    // http://xml.apache.org/xalan-j/usagepatterns.html#debugging
    // debugging
    // Set up a PrintTraceListener object to print to a file.
    java.io.FileWriter fw = new java.io.FileWriter("/tmp/xslt-events" + xsltCount++ + ".log");
    java.io.PrintWriter pw = new java.io.PrintWriter(fw);
    PrintTraceListener ptl = new PrintTraceListener(pw);
            
    // Print information as each node is 'executed' in the stylesheet.
    ptl.m_traceElements = true;
    // Print information after each result-tree generation event.
    ptl.m_traceGeneration = true;
    // Print information after each selection event.
    ptl.m_traceSelection = true;
    // Print information whenever a template is invoked.
    ptl.m_traceTemplates = true;
    // Print information whenever an extension is called.
    ptl.m_traceExtension = true;
    TransformerImpl transformerImpl = (TransformerImpl)xformer;
            
      // Register the TraceListener with the TraceManager associated
      // with the TransformerImpl.
      TraceManager trMgr = transformerImpl.getTraceManager();
      trMgr.addTraceListener(ptl);
            
    */
    // DEBUGGING
    // use the identity transform if you want to send wordDocument;
    // otherwise you'll get the XHTML
    // javax.xml.transform.Transformer xformer = tfactory.newTransformer();
    try {
        xformer.transform(source, result);
    } catch (TransformerException e) {
        throw new Docx4JException("Cannot perform the transformation", e);
    } finally {
        //pw.flush();
    }

}

From source file:com.android.launcher4.Workspace.java

/**
 * Adds the specified child in the specified screen. The position and dimension of
 * the child are defined by x, y, spanX and spanY.
 *
 * @param child The child to add in one of the workspace's screens.
 * @param screenId The screen in which to add the child.
 * @param x The X position of the child in the screen's grid.
 * @param y The Y position of the child in the screen's grid.
 * @param spanX The number of cells spanned horizontally by the child.
 * @param spanY The number of cells spanned vertically by the child.
 * @param insert When true, the child is inserted at the beginning of the children list.
 * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute
 *                          the x and y position in which to place hotseat items. Otherwise
 *                          we use the x and y position to compute the rank.
 *//* w w w.j a v  a  2s  .c o  m*/
void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert,
        boolean computeXYFromRank) {
    if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
        if (getScreenWithId(screenId) == null) {
            Log.e(TAG, "Skipping child, screenId " + screenId + " not found");
            // DEBUGGING - Print out the stack trace to see where we are adding from
            new Throwable().printStackTrace();
            return;
        }
    }
    if (screenId == EXTRA_EMPTY_SCREEN_ID) {
        // This should never happen
        throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
    }

    final CellLayout layout;
    if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
        layout = mLauncher.getHotseat().getLayout();
        child.setOnKeyListener(new HotseatIconKeyEventListener());

        // Hide folder title in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(false);
        }

        if (computeXYFromRank) {
            x = mLauncher.getHotseat().getCellXFromOrder((int) screenId);
            y = mLauncher.getHotseat().getCellYFromOrder((int) screenId);
        } else {
            screenId = mLauncher.getHotseat().getOrderInHotseat(x, y);
        }
    } else {
        // Show folder title if not in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(true);
        }
        layout = getScreenWithId(screenId);
        child.setOnKeyListener(new IconKeyEventListener());
    }

    ViewGroup.LayoutParams genericLp = child.getLayoutParams();
    CellLayout.LayoutParams lp;
    if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
        lp = new CellLayout.LayoutParams(x, y, spanX, spanY);
    } else {
        lp = (CellLayout.LayoutParams) genericLp;
        lp.cellX = x;
        lp.cellY = y;
        lp.cellHSpan = spanX;
        lp.cellVSpan = spanY;
    }

    if (spanX < 0 && spanY < 0) {
        lp.isLockedToGrid = false;
    }

    // Get the canonical child id to uniquely represent this view in this screen
    ItemInfo info = (ItemInfo) child.getTag();
    int childId = mLauncher.getViewIdForItem(info);

    boolean markCellsAsOccupied = !(child instanceof Folder);
    if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) {
        // TODO: This branch occurs when the workspace is adding views
        // outside of the defined grid
        // maybe we should be deleting these items from the LauncherModel?
        Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout",
                true);
    }

    if (!(child instanceof Folder)) {
        child.setHapticFeedbackEnabled(false);
        child.setOnLongClickListener(mLongClickListener);
    }
    if (child instanceof DropTarget) {
        mDragController.addDropTarget((DropTarget) child);
    }
}

From source file:com.fairphone.fplauncher3.Workspace.java

/**
 * Adds the specified child in the specified screen. The position and dimension of
 * the child are defined by x, y, spanX and spanY.
 *
 * @param child The child to add in one of the workspace's screens.
 * @param screenId The screen in which to add the child.
 * @param x The X position of the child in the screen's grid.
 * @param y The Y position of the child in the screen's grid.
 * @param spanX The number of cells spanned horizontally by the child.
 * @param spanY The number of cells spanned vertically by the child.
 * @param insert When true, the child is inserted at the beginning of the children list.
 * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute
 *                          the x and y position in which to place hotseat items. Otherwise
 *                          we use the x and y position to compute the rank.
 *///from   w w  w  .j a va  2s .  c o  m
void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert,
        boolean computeXYFromRank) {
    if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
        if (getScreenWithId(screenId) == null) {
            Log.e(TAG, "Skipping child, screenId " + screenId + " not found");
            // DEBUGGING - Print out the stack trace to see where we are adding from
            new Throwable().printStackTrace();
            return;
        }
    }
    if (screenId == EXTRA_EMPTY_SCREEN_ID) {
        // This should never happen
        throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
    }

    final CellLayout layout;
    // Show folder title
    if (child instanceof FolderIcon) {
        ((FolderIcon) child).setTextVisible(true);
    }
    layout = getScreenWithId(screenId);
    child.setOnKeyListener(new IconKeyEventListener());

    ViewGroup.LayoutParams genericLp = child.getLayoutParams();
    CellLayout.LayoutParams lp;
    if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
        lp = new CellLayout.LayoutParams(x, y, spanX, spanY);
    } else {
        lp = (CellLayout.LayoutParams) genericLp;
        lp.cellX = x;
        lp.cellY = y;
        lp.cellHSpan = spanX;
        lp.cellVSpan = spanY;
    }

    if (spanX < 0 && spanY < 0) {
        lp.isLockedToGrid = false;
    }

    // Get the canonical child id to uniquely represent this view in this screen
    ItemInfo info = (ItemInfo) child.getTag();
    int childId = mLauncher.getViewIdForItem(info);

    boolean markCellsAsOccupied = !(child instanceof Folder);
    if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) {
        // TODO: This branch occurs when the workspace is adding views
        // outside of the defined grid
        // maybe we should be deleting these items from the LauncherModel?
        Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout",
                true);
    }

    if (!(child instanceof Folder)) {
        child.setHapticFeedbackEnabled(false);
        child.setOnLongClickListener(mLongClickListener);
    }
    if (child instanceof DropTarget) {
        mDragController.addDropTarget((DropTarget) child);
    }
}

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

public void setHookedWebViewClient(final WebView webView, final String javaScript) {
    webView.post(new Runnable() {
        // @Override
        public void run() {
            final WebViewClient orginalWebViewClient = getOriginalWebViewClient(webView);
            if (orginalWebViewClient != null) {
                webView.setWebViewClient(new WebViewClient() {

                    HashMap<String, Boolean> invoke = new HashMap<String, Boolean>();

                    @Override/*from  w w w.j a va  2  s.  c  o m*/
                    public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
                        orginalWebViewClient.doUpdateVisitedHistory(view, url, isReload);
                    }

                    @Override
                    public void onFormResubmission(WebView view, Message dontResend, Message resend) {
                        orginalWebViewClient.onFormResubmission(view, dontResend, resend);
                    }

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

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

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

                    @Override
                    public void onReceivedError(WebView view, int errorCode, String description,
                            String failingUrl) {
                        orginalWebViewClient.onReceivedError(view, errorCode, description, failingUrl);
                    }

                    @Override
                    public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host,
                            String realm) {
                        orginalWebViewClient.onReceivedHttpAuthRequest(view, handler, host, realm);
                    }

                    public void onReceivedLoginRequest(WebView view, String realm, String account,
                            String args) {
                        // do support onReceivedLoginRequest since the
                        // version 4.0
                        if (Build.VERSION.SDK_INT >= 14) {
                            orginalWebViewClient.onReceivedLoginRequest(view, realm, account, args);
                        }
                    }

                    @Override
                    public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                        orginalWebViewClient.onReceivedSslError(view, handler, error);
                    }

                    @Override
                    public void onScaleChanged(WebView view, float oldScale, float newScale) {
                        orginalWebViewClient.onScaleChanged(view, oldScale, newScale);
                    }

                    @Override
                    public void onTooManyRedirects(WebView view, Message cancelMsg, Message continueMsg) {
                        orginalWebViewClient.onTooManyRedirects(view, cancelMsg, continueMsg);
                    }

                    @Override
                    public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
                        orginalWebViewClient.onUnhandledKeyEvent(view, event);
                    }

                    @Override
                    public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
                        if (Build.VERSION.SDK_INT >= 14) {
                            return orginalWebViewClient.shouldInterceptRequest(view, url);
                        } else {
                            return null;
                        }
                    }

                    @Override
                    public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
                        return orginalWebViewClient.shouldOverrideKeyEvent(view, event);
                    }

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

                });
            } else {
                // set hook WebViewClient
                webView.setWebViewClient(new WebViewClient() {

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

                    /* (non-Javadoc)
                     * @see android.webkit.WebViewClient#onFormResubmission(android.webkit.WebView, android.os.Message, android.os.Message)
                     */
                    @Override
                    public void onFormResubmission(WebView view, Message dontResend, Message resend) {
                        // TODO Auto-generated method stub
                        super.onFormResubmission(view, dontResend, resend);
                    }

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

                    /* (non-Javadoc)
                     * @see android.webkit.WebViewClient#onPageStarted(android.webkit.WebView, java.lang.String, android.graphics.Bitmap)
                     */
                    @Override
                    public void onPageStarted(WebView view, String url, Bitmap favicon) {
                        // TODO Auto-generated method stub
                        super.onPageStarted(view, url, favicon);
                    }

                    /* (non-Javadoc)
                     * @see android.webkit.WebViewClient#onReceivedError(android.webkit.WebView, int, java.lang.String, java.lang.String)
                     */
                    @Override
                    public void onReceivedError(WebView view, int errorCode, String description,
                            String failingUrl) {
                        // TODO Auto-generated method stub
                        super.onReceivedError(view, errorCode, description, failingUrl);
                    }

                    /* (non-Javadoc)
                     * @see android.webkit.WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView, android.webkit.HttpAuthHandler, java.lang.String, java.lang.String)
                     */
                    @Override
                    public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host,
                            String realm) {
                        // TODO Auto-generated method stub
                        super.onReceivedHttpAuthRequest(view, handler, host, realm);
                    }

                    /* (non-Javadoc)
                     * @see android.webkit.WebViewClient#onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String)
                     */
                    @Override
                    public void onReceivedLoginRequest(WebView view, String realm, String account,
                            String args) {
                        // TODO Auto-generated method stub
                        super.onReceivedLoginRequest(view, realm, account, args);
                    }

                    /* (non-Javadoc)
                     * @see android.webkit.WebViewClient#onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError)
                     */
                    @Override
                    public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                        // TODO Auto-generated method stub
                        super.onReceivedSslError(view, handler, error);
                    }

                    /* (non-Javadoc)
                     * @see android.webkit.WebViewClient#onScaleChanged(android.webkit.WebView, float, float)
                     */
                    @Override
                    public void onScaleChanged(WebView view, float oldScale, float newScale) {
                        // TODO Auto-generated method stub
                        super.onScaleChanged(view, oldScale, newScale);
                    }

                    /* (non-Javadoc)
                     * @see android.webkit.WebViewClient#onTooManyRedirects(android.webkit.WebView, android.os.Message, android.os.Message)
                     */
                    @Override
                    public void onTooManyRedirects(WebView view, Message cancelMsg, Message continueMsg) {
                        // TODO Auto-generated method stub
                        super.onTooManyRedirects(view, cancelMsg, continueMsg);
                    }

                    /* (non-Javadoc)
                     * @see android.webkit.WebViewClient#onUnhandledKeyEvent(android.webkit.WebView, android.view.KeyEvent)
                     */
                    @Override
                    public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
                        // TODO Auto-generated method stub
                        super.onUnhandledKeyEvent(view, event);
                    }

                    /* (non-Javadoc)
                     * @see android.webkit.WebViewClient#shouldInterceptRequest(android.webkit.WebView, java.lang.String)
                     */
                    @Override
                    public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
                        // TODO Auto-generated method stub
                        return super.shouldInterceptRequest(view, url);
                    }

                    /* (non-Javadoc)
                     * @see android.webkit.WebViewClient#shouldOverrideKeyEvent(android.webkit.WebView, android.view.KeyEvent)
                     */
                    @Override
                    public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
                        // TODO Auto-generated method stub
                        return super.shouldOverrideKeyEvent(view, event);
                    }

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

                    @Override
                    public void onPageFinished(WebView view, String url) {
                        super.onPageFinished(webView, url);
                        // print("webView onPageFinished: " + url);
                        if (url != null) {
                            hookWebElements(view, javaScript);
                        }
                    }
                });
            }
        }
    });
}

From source file:com.android.launcher3.Workspace.java

/**
 * Adds the specified child in the specified screen. The position and dimension of
 * the child are defined by x, y, spanX and spanY.
 *
 * @param child The child to add in one of the workspace's screens.
 * @param screenId The screen in which to add the child.
 * @param x The X position of the child in the screen's grid.
 * @param y The Y position of the child in the screen's grid.
 * @param spanX The number of cells spanned horizontally by the child.
 * @param spanY The number of cells spanned vertically by the child.
 * @param insert When true, the child is inserted at the beginning of the children list.
 * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute
 *                          the x and y position in which to place hotseat items. Otherwise
 *                          we use the x and y position to compute the rank.
 *//* w w  w.  j  ava 2s.  c  o m*/
void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert,
        boolean computeXYFromRank) {
    if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
        if (getScreenWithId(screenId) == null) {
            Log.e(TAG, "Skipping child, screenId " + screenId + " not found");
            // DEBUGGING - Print out the stack trace to see where we are adding from
            new Throwable().printStackTrace();
            return;
        }
    }
    if (screenId == EXTRA_EMPTY_SCREEN_ID) {
        // This should never happen
        throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
    }

    final CellLayout layout;
    if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
        layout = mLauncher.getHotseat().getLayout();
        child.setOnKeyListener(new HotseatIconKeyEventListener());

        // Hide folder title in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(false);
        }

        if (computeXYFromRank) {
            x = mLauncher.getHotseat().getCellXFromOrder((int) screenId);
            y = mLauncher.getHotseat().getCellYFromOrder((int) screenId);
        } else {
            screenId = mLauncher.getHotseat().getOrderInHotseat(x, y);
        }
    } else {
        // Show folder title if not in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(true);
        }
        layout = getScreenWithId(screenId);
        child.setOnKeyListener(new IconKeyEventListener());
    }

    ViewGroup.LayoutParams genericLp = child.getLayoutParams();
    CellLayout.LayoutParams lp;
    if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
        lp = new CellLayout.LayoutParams(x, y, spanX, spanY);
    } else {
        lp = (CellLayout.LayoutParams) genericLp;
        lp.cellX = x;
        lp.cellY = y;
        lp.cellHSpan = spanX;
        lp.cellVSpan = spanY;
    }

    if (spanX < 0 && spanY < 0) {
        lp.isLockedToGrid = false;
    }

    // Get the canonical child id to uniquely represent this view in this screen
    ItemInfo info = (ItemInfo) child.getTag();
    int childId = mLauncher.getViewIdForItem(info);

    boolean markCellsAsOccupied = !(child instanceof Folder);
    if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) {
        // TODO: This branch occurs when the workspace is adding views
        // outside of the defined grid
        // maybe we should be deleting these items from the LauncherModel?
        Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout",
                true);
    }

    if (!(child instanceof Folder)) {
        child.setHapticFeedbackEnabled(false);
        //CG wujiangwei Add B for Launcher for Glass 2015.09.30
        //child.setOnLongClickListener(mLongClickListener);
    }
    if (child instanceof DropTarget) {
        mDragController.addDropTarget((DropTarget) child);
    }
}

From source file:org.apache.usergrid.persistence.cassandra.EntityManagerImpl.java

/**
 * Gets the specified entity.//from   ww w.j a  v  a 2 s. c o m
 *
 * @param entityId the entity id
 * @param entityClass the entity class
 *
 * @return entity
 *
 * @throws Exception the exception
 */
public <A extends Entity> A getEntity(UUID entityId, Class<A> entityClass) throws Exception {

    Object entity_key = key(entityId);
    Map<String, Object> results = null;

    // if (entityType == null) {
    results = deserializeEntityProperties(
            cass.getAllColumns(cass.getApplicationKeyspace(applicationId), ENTITY_PROPERTIES, entity_key));
    // } else {
    // Set<String> columnNames = Schema.getPropertyNames(entityType);
    // results = getColumns(getApplicationKeyspace(applicationId),
    // EntityCF.PROPERTIES, entity_key, columnNames, se, be);
    // }

    if (results == null) {
        logger.warn("getEntity(): No properties found for entity {}, probably doesn't exist...", entityId);
        return null;
    }

    UUID id = uuid(results.get(PROPERTY_UUID));
    String type = string(results.get(PROPERTY_TYPE));

    if (!entityId.equals(id)) {

        logger.error("Expected entity id {}, found {}. Returning null entity",
                new Object[] { entityId, id, new Throwable() });
        return null;
    }

    A entity = EntityFactory.newEntity(id, type, entityClass);
    entity.setProperties(results);

    return entity;
}

From source file:org.o3project.ocnrm.odenos.linklayerizer.LinkLayerizer.java

private void addFlowToUpper(final String networkId, final Flow flow) {
    logger.info("** " + new Throwable().getStackTrace()[0].getMethodName() + " Start");
    addFlowAndSync(networkId, flow, getUpperNetworkId());
}

From source file:cn.nukkit.Server.java

/**
 * ???// ww  w. j  a  v  a  2  s  . c o m
 * @param sender ?CommandSender
 * @param commandLine ?
 * @return boolean true?/false?
 */
public boolean dispatchCommand(CommandSender sender, String commandLine) throws ServerException {
    // First we need to check if this command is on the main thread or not, if not, warn the user
    if (!this.isPrimaryThread()) {
        getLogger().warning("Command Dispatched Async: " + commandLine);
        getLogger().warning("Please notify author of plugin causing this execution to fix this bug!",
                new Throwable());
        // TODO: We should sync the command to the main thread too!
    }
    if (sender == null) {
        throw new ServerException("CommandSender is not valid");
    }

    if (this.commandMap.dispatch(sender, commandLine)) {
        return true;
    }

    sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.notFound"));

    return false;
}