Example usage for java.io IOException getClass

List of usage examples for java.io IOException getClass

Introduction

In this page you can find the example usage for java.io IOException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

public void addUrlResultString(final String url, final String resultString) {
    new Thread(new Runnable() {
        @Override/*from w w  w  . j  av a2  s  . c  o m*/
        public void run() {
            ScriptResolverUrlResult result = null;
            try {
                result = mObjectMapper.readValue(resultString, ScriptResolverUrlResult.class);
            } catch (IOException e) {
                Log.e(TAG, "addUrlResultString: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
            if (result != null) {
                PipeLine.getInstance().reportUrlResult(url, ScriptResolver.this, result);
            }
            mStopped = true;
        }
    }).start();
}

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

/**
 * Sometimes we need the String returned by a certain javascript function. Therefore we wrap the
 * function call in a call to "callbackToJava", which is being received by the ScriptInterface.
 * The ScriptInterface redirects the call to this method, where we can access the returned
 * String. Throughout this whole process we are passing an id along, which enables us to
 * identify which call wants to return its result.
 *
 * @param id         used to identify which function did the callback
 * @param jsonString the json-string which is the result of the called function. Can be null.
 *///ww w.  j  a v a  2 s  . c o m
public void handleCallbackToJava(final int id, final String... jsonString) {
    try {
        if (id == R.id.scriptresolver_resolver_settings && jsonString != null && jsonString.length == 1) {
            ScriptResolverSettings settings = mObjectMapper.readValue(jsonString[0],
                    ScriptResolverSettings.class);
            mWeight = settings.weight;
            mTimeout = settings.timeout * 1000;
            resolverGetConfigUi();
        } else if (id == R.id.scriptresolver_resolver_get_config_ui && jsonString != null
                && jsonString.length == 1) {
            mConfigUi = mObjectMapper.readValue(jsonString[0], ScriptResolverConfigUi.class);
        } else if (id == R.id.scriptresolver_resolver_init) {
            resolverSettings();
        } else if (id == R.id.scriptresolver_resolver_collection && jsonString != null
                && jsonString.length == 1) {
            mCollectionMetaData = mObjectMapper.readValue(jsonString[0],
                    ScriptResolverCollectionMetaData.class);
            CollectionManager.getInstance().addCollection(new ScriptResolverCollection(this));
        }
    } catch (IOException e) {
        Log.e(TAG, "handleCallbackToJava: " + e.getClass() + ": " + e.getLocalizedMessage());
    }
}

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

public void addTrackResultsString(final String results) {
    ThreadManager.getInstance().execute(new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_REPORTING) {
        @Override//w  w  w.jav a 2  s .  c  o m
        public void run() {
            ScriptResolverResult result = null;
            try {
                result = mObjectMapper.readValue(results, ScriptResolverResult.class);
            } catch (IOException e) {
                Log.e(TAG, "addTrackResultsString: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
            if (result != null) {
                ArrayList<Result> parsedResults = parseResultList(result.results, result.qid);
                PipeLine.getInstance().reportResults(mQueryKeys.get(result.qid), parsedResults, mId);
            }
            mTimeOutHandler.removeCallbacksAndMessages(null);
            mStopped = true;
        }
    });
}

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

public void addAlbumResultsString(final String results) {
    ThreadManager.getInstance().execute(new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_REPORTING) {
        @Override/*  ww w. ja  v  a  2s .c  o m*/
        public void run() {
            ScriptResolverAlbumResult result = null;
            try {
                result = mObjectMapper.readValue(results, ScriptResolverAlbumResult.class);
            } catch (IOException e) {
                Log.e(TAG, "addAlbumResultsString: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
            if (result != null) {
                ScriptResolverCollection collection = (ScriptResolverCollection) CollectionManager.getInstance()
                        .getCollection(result.qid);
                if (collection != null) {
                    Artist artist = Artist.get(result.artist);
                    ArrayList<Album> albums = new ArrayList<Album>();
                    for (String albumName : result.albums) {
                        albums.add(Album.get(albumName, artist));
                    }
                    collection.addAlbumResults(albums);
                }
            }
            mTimeOutHandler.removeCallbacksAndMessages(null);
            mStopped = true;
        }
    });
}

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

public void addArtistResultsString(final String results) {
    ThreadManager.getInstance().execute(new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_REPORTING) {
        @Override//from  ww w  .  j  ava  2  s.  com
        public void run() {
            ScriptResolverArtistResult result = null;
            try {
                result = mObjectMapper.readValue(results, ScriptResolverArtistResult.class);
            } catch (IOException e) {
                Log.e(TAG, "addArtistResultsString: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
            if (result != null) {
                ScriptResolverCollection collection = (ScriptResolverCollection) CollectionManager.getInstance()
                        .getCollection(result.qid);
                if (collection != null) {
                    ArrayList<Artist> artists = new ArrayList<Artist>();
                    for (String artistName : result.artists) {
                        artists.add(Artist.get(artistName));
                    }
                    collection.addArtistResults(artists);
                }
            }
            mTimeOutHandler.removeCallbacksAndMessages(null);
            mStopped = true;
        }
    });
}

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

public void addAlbumTrackResultsString(final String results) {
    ThreadManager.getInstance().execute(new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_REPORTING) {
        @Override/*from  w  w  w  . j a  va  2s  .com*/
        public void run() {
            ScriptResolverAlbumTrackResult result = null;
            try {
                result = mObjectMapper.readValue(results, ScriptResolverAlbumTrackResult.class);
            } catch (IOException e) {
                Log.e(TAG, "addAlbumTrackResultsString: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
            if (result != null) {
                ScriptResolverCollection collection = (ScriptResolverCollection) CollectionManager.getInstance()
                        .getCollection(result.qid);
                ArrayList<Result> parsedResults = parseResultList(result.results, result.qid);
                Artist artist = Artist.get(result.artist);
                Album album = Album.get(result.album, artist);
                collection.addAlbumTrackResults(album, parsedResults);
            }
            mTimeOutHandler.removeCallbacksAndMessages(null);
            mStopped = true;
        }
    });
}

From source file:org.tomahawk.libtomahawk.resolver.ScriptResolver.java

/**
 * Initialize the WebView. Loads the .js script from the given path and sets the appropriate
 * base URL.// ww w .ja  v a2  s  .  c  o m
 *
 * @return the initialized WebView
 */
private synchronized WebView getWebView() {
    if (mWebView == null) {
        mWebView = new WebView(TomahawkApp.getContext());
        WebSettings settings = mWebView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setDatabaseEnabled(true);
        settings.setDatabasePath(TomahawkApp.getContext().getDir("databases", Context.MODE_PRIVATE).getPath());
        settings.setDomStorageEnabled(true);
        mWebView.setWebChromeClient(new TomahawkWebChromeClient());
        mWebView.setWebViewClient(new ScriptWebViewClient(ScriptResolver.this));
        final ScriptInterface scriptInterface = new ScriptInterface(ScriptResolver.this);
        mWebView.addJavascriptInterface(scriptInterface, SCRIPT_INTERFACE_NAME);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
        }

        final String baseurl = "file:///android_asset/test.html";
        String data = "<!DOCTYPE html>" + "<html><body>"
                + "<script src=\"file:///android_asset/js/cryptojs-core.js"
                + "\" type=\"text/javascript\"></script>";
        for (String scriptPath : mMetaData.manifest.scripts) {
            data += "<script src=\"file:///android_asset/" + mPath + "/" + scriptPath
                    + "\" type=\"text/javascript\"></script>";
        }
        try {
            String[] cryptoJsScripts = TomahawkApp.getContext().getAssets().list("js/cryptojs");
            for (String scriptPath : cryptoJsScripts) {
                data += "<script src=\"file:///android_asset/js/cryptojs/" + scriptPath
                        + "\" type=\"text/javascript\"></script>";
            }
        } catch (IOException e) {
            Log.e(TAG, "ScriptResolver: " + e.getClass() + ": " + e.getLocalizedMessage());
        }
        data += "<script src=\"file:///android_asset/js/tomahawk_android_pre.js"
                + "\" type=\"text/javascript\"></script>" + "<script src=\"file:///android_asset/js/tomahawk.js"
                + "\" type=\"text/javascript\"></script>"
                + "<script src=\"file:///android_asset/js/tomahawk_android_post.js"
                + "\" type=\"text/javascript\"></script>" + "<script src=\"file:///android_asset/" + mPath + "/"
                + mMetaData.manifest.main + "\" type=\"text/javascript\"></script>" + "</body></html>";
        final String finalData = data;
        mWebView.loadDataWithBaseURL(baseurl, finalData, "text/html", null, null);
    }
    return mWebView;
}

From source file:org.squale.welcom.taglib.progressbar.ProgressBarTag.java

public int doStartTag() throws JspException {
    JspWriter out = this.pageContext.getOut();

    try {/*  ww  w.ja v a2  s.c o m*/
        // Inclusion de la librairie JS
        CanvasUtil.addJs(
                WelcomConfigurator.getMessage(WelcomConfigurator.HEADER_LOCALJS_PATH_KEY) + "progressbar.js",
                this, pageContext);

        boolean isIE = false;
        boolean isSafari = false;
        boolean isOpera = false;
        String userAgent = ((HttpServletRequest) pageContext.getRequest()).getHeader("User-Agent");

        if (userAgent != null) {
            if (userAgent.indexOf("MSIE") != -1) {
                isIE = true;
            } else {
                if (userAgent.indexOf("Safari") != -1) {
                    isSafari = true;
                } else {
                    if (userAgent.indexOf("Opera") != -1) {
                        isOpera = true;
                    }
                }
            }
        }

        String pbProperties = " wRefreshRate='" + refreshRate + "'";

        if (!GenericValidator.isBlankOrNull(onChangeHook)) {
            pbProperties += " wOnChangeHook='" + onChangeHook + "'";
        }

        if (!GenericValidator.isBlankOrNull(onCompleteHook)) {
            pbProperties += " wOnCompleteHook='" + onCompleteHook + "'";
        }

        pbProperties += " wIsFullScreen='" + isFullScreen + "'";

        out.println("<input type='hidden' id='wWatchedTaskId' name='wWatchedTaskId'>");

        out.println("<DIV id='" + id + "' " + pbProperties + ">");

        if (isFullScreen) {

            // Cration de variable pour viter de passer ces infos dans l'appel
            // JS

            if (isIE) {
                out.println("<IFRAME frameborder=0 id=wDivProgressBarBG style=\"background-color:#ffffff;");
                out.println("filter:alpha(opacity=60);");
                out.println("visibility: hidden;");
                out.println(
                        "position:absolute; top:0px; left:0px; width:1400px; height:909px; z-index:123; padding:0; border-width:0; border-style:none, margin:0;\">");
                out.println("</IFRAME>");
            } else {
                out.println("<div id=wDivProgressBarBG style=\"background-color:#ffffff;");
                out.print("-moz-opacity:0.6;");
                out.print("opacity: 0.6;");
                out.print("visibility: hidden;");
                out.print(
                        "position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:123; margin:0;\">");
                out.println("</div>");
            }

            out.println("<div id=wDivProgressBar style=\"background-color:#FFFFFF;");
            out.print("position:absolute;");
            out.print("left:50%;");
            out.print("top:50%;");
            out.print("visibility: hidden;");
            out.print("margin-left:-50px;");
            out.print("margin-top:-50px; ");
            out.print("z-index:124;");
            out.print("border:1px solid #888\">");
        } // Fin IF isFullScreen

        // Cration de la zone d'affichage
        String tdStatus;
        if (showStatusText) {
            tdStatus = "<span style=\"color:#000\" id='" + getId() + "_status'>-</span>";
        } else {
            tdStatus = "";
        }

        String tdPct;
        if (showPctText) {
            tdPct = "<span style=\"color:#000\" id=\"" + getId() + "_pctText\">0%</span>";
        } else {
            tdPct = "";
        }

        boolean leftExists = false;
        boolean topExists = false;
        boolean rightExists = false;
        boolean bottomExists = false;
        boolean progressSolo = true;

        if (showPctText || showStatusText) {
            if ((pctTextPosition.equals(POS_LEFT)) || (statusTextPosition.equals(POS_LEFT))) {
                leftExists = true;
                progressSolo = false;
            }

            if ((pctTextPosition.equals(POS_TOP)) || (statusTextPosition.equals(POS_TOP))) {
                topExists = true;
                progressSolo = false;
            }

            if ((pctTextPosition.equals(POS_RIGHT)) || (statusTextPosition.equals(POS_RIGHT))) {
                rightExists = true;
                progressSolo = false;
            }

            if ((pctTextPosition.equals(POS_BOTTOM)) || (statusTextPosition.equals(POS_BOTTOM))) {
                bottomExists = true;
                progressSolo = false;
            }
        }

        if (isSafari) {
            progressSolo = true;
            bottomExists = false;
            topExists = false;
            leftExists = false;
            rightExists = false;
        }

        if (isFullScreen()) {
            out.println(
                    "<div style=\"background-image:url(theme/charte_v03_001/img/lignage/lignage_trans.gif);background-position:left bottom;background-repeat:repeat-x;height:32px;width:"
                            + width
                            + "px;\" class=\"bg_theme\"><div style=\"margin: 0pt; padding: 0px 5px; font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: bold; font-size: 10px; color: rgb(255, 255, 255); background-color: rgb(5, 16, 57); cursor: default; height: 16px; float: left;\">Execution</div></div>");
        }

        // out.println("<div>");
        out.println("<table border=\"0\" cellspacing=\"2px\" style=\"0px 3px 3px 3px\" width=\"" + width
                + "px\" >");

        // Formattage
        out.print("<tr>");
        if (leftExists) {
            out.print("<th style='width: 15%'></th>");
        }

        if (!progressSolo) {
            if (leftExists && rightExists) {
                out.print("<th style='width: 70%'></th>");
            } else {
                if (leftExists || rightExists) {
                    out.print("<th style='width: 85%'></th>");
                } else {
                    out.print("<th style='width: 100%'></th>");
                }

            }
        }

        if (rightExists) {
            out.print("<th style='width: 15%'></th>");
        }

        out.println("</tr>");

        // ###############
        // LIGNE du haut
        // ###############

        if (topExists) {
            out.println("<tr>");

            // ------------

            if (leftExists || rightExists) {
                out.println("<td " + STYLE_TD_NOBORDER_PADDING + " colspan=2>");
            } else {
                out.println("<td " + STYLE_TD_NOBORDER_PADDING + " >");
            }

            if (pctTextPosition.equals(POS_TOP)) {
                out.println(tdPct);
            }

            if (statusTextPosition.equals(POS_TOP)) {
                out.println(tdStatus);
            }
            out.println("</td>");

            // ------------

            out.println("</tr>");
        }

        // ###############
        // LIGNE du milieu
        // ###############
        // ------------
        out.println("<tr>");
        if (leftExists) {

            out.println("<td " + STYLE_TD_NOBORDER_PADDING + " >");
            if (pctTextPosition.equals(POS_LEFT)) {
                out.println(tdPct);
            }

            if (statusTextPosition.equals(POS_LEFT)) {
                out.println(tdStatus);
            }
            out.println("</td>");

        }
        // ------------

        out.print(" <td " + STYLE_TD_NOBORDER_PADDING + ">");

        // ----- PROGRESS BAR -----
        if (isSafari) {
            out.print(render.drawAnimatedProgressBar());
        } else {
            out.print(render.drawRealProgressBar(getId()));
        }

        // ----- PROGRESS BAR -----
        out.println("   </td>");

        // ------------
        if (rightExists) {
            out.println("<td " + STYLE_TD_NOBORDER + " >");
            if (pctTextPosition.equals(POS_RIGHT)) {
                out.println(tdPct);
            }

            if (statusTextPosition.equals(POS_RIGHT)) {
                out.println(tdStatus);
            }
            out.println("</td>");
        }

        out.println("</tr>");
        // ------------

        // ###############
        // LIGNE du bas
        // ###############
        if (bottomExists) {
            out.println("<tr>");

            // ------------

            if (leftExists || rightExists) {
                out.println("<td  " + STYLE_TD_NOBORDER_PADDING + " colspan=2>");
            } else {
                out.println("<td " + STYLE_TD_NOBORDER_PADDING + " >");
            }

            if (pctTextPosition.equals(POS_BOTTOM)) {
                out.println(tdPct);
            }

            if (statusTextPosition.equals(POS_BOTTOM)) {
                out.println(tdStatus);
            }
            out.println("</td>");

            // ------------

            out.println("</tr>");
        }

        out.println("</table>");
        // out.println("</div>");
        if (isFullScreen) {
            out.println(
                    "<div style=\"background-image:url(theme/charte_v03_001/img/lignage/footer_trans.gif);background-position:left bottom;clear:both;height:20px;width:"
                            + width + "px;\" class=\"bg_theme\"></div>");
            out.println("</div>");
        }
        out.println("</div>");
    } catch (IOException e) {
        try {
            out.println("unable to render tag due to " + e.getClass().getName() + ":" + e.getMessage());
        } catch (IOException e1) {
            // On fait rien car l'exception doit tre la mme que celle du
            // bloc catch englobant
        }
        e.printStackTrace();
    }

    // Continue processing this page
    release();
    return (EVAL_PAGE);
}

From source file:com.twinsoft.convertigo.eclipse.ConvertigoPlugin.java

static public Properties decodePscFromWorkspace(String convertigoWorkspace) throws PscException {
    File pscFile = new File(convertigoWorkspace, "studio/psc.txt");
    if (pscFile.exists()) {
        try {// www  . j  ava2 s  .  c om
            String psc = FileUtils.readFileToString(pscFile, "utf-8");
            return decodePsc(psc);
        } catch (IOException e) {
            throw new PscException("Invalid PSC (failed to read the file '" + pscFile.getAbsolutePath()
                    + "' because of a '" + e.getClass().getSimpleName() + " : " + e.getMessage() + "')!");
        }
    } else {
        throw new PscException("Invalid PSC (the file '" + pscFile.getAbsolutePath() + "' doesn't exist)!");
    }
}

From source file:org.tomahawk.libtomahawk.database.DatabaseHelper.java

/**
 * @return an InfoRequestData object that contains all data that should be delivered to the API
 *///from w  ww .  ja  v  a2  s . c om
public List<InfoRequestData> getLoggedOps() {
    List<InfoRequestData> loggedOps = new ArrayList<InfoRequestData>();
    String[] columns = new String[] { TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_ID,
            TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_TYPE,
            TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_HTTPTYPE,
            TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_JSONSTRING,
            TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_PARAMS };

    Cursor opLogCursor = mDatabase.query(TomahawkSQLiteHelper.TABLE_INFOSYSTEMOPLOG, columns, null, null, null,
            null, TomahawkSQLiteHelper.INFOSYSTEMOPLOG_COLUMN_TIMESTAMP + " DESC");
    opLogCursor.moveToFirst();
    while (!opLogCursor.isAfterLast()) {
        String requestId = TomahawkMainActivity.getSessionUniqueStringId();
        String paramJsonString = opLogCursor.getString(4);
        QueryParams params = null;
        if (paramJsonString != null) {
            try {
                params = InfoSystemUtils.getObjectMapper().readValue(paramJsonString, QueryParams.class);
            } catch (IOException e) {
                Log.e(TAG, "getLoggedOps: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
        }
        InfoRequestData infoRequestData = new InfoRequestData(requestId, opLogCursor.getInt(1), params,
                opLogCursor.getInt(0), opLogCursor.getInt(2), opLogCursor.getString(3));
        loggedOps.add(infoRequestData);
        opLogCursor.moveToNext();
    }
    opLogCursor.close();
    return loggedOps;
}