Example usage for java.lang IllegalStateException printStackTrace

List of usage examples for java.lang IllegalStateException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.imaginea.betterdocs.BetterDocsAction.java

private static String getESResultJson(String esQueryJson, String url) {
    StringBuilder stringBuilder = new StringBuilder();
    try {/*from   w  w w.  j  a  v  a  2s. c o m*/
        HttpClient httpClient = new DefaultHttpClient();
        String encodedJson = URLEncoder.encode(esQueryJson, UTF_8);
        String esGetURL = url + encodedJson;

        HttpGet getRequest = new HttpGet(esGetURL);
        getRequest.setHeader(USER_AGENT, IDEA_PLUGIN);

        HttpResponse response = httpClient.execute(getRequest);
        if (response.getStatusLine().getStatusCode() != 200) {
            throw new RuntimeException(FAILED_HTTP_ERROR_CODE + url + response.getStatusLine().getStatusCode());
        }

        BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
        String output;
        while ((output = br.readLine()) != null) {
            stringBuilder.append(output);
        }
        httpClient.getConnectionManager().shutdown();
    } catch (IllegalStateException e) {
        e.printStackTrace();
        return EMPTY_ES_URL;
    } catch (MalformedURLException e) {
        e.printStackTrace();
        return EMPTY_ES_URL;
    } catch (IOException e) {
        e.printStackTrace();
        return EMPTY_ES_URL;
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        return EMPTY_ES_URL;
    }
    return stringBuilder.toString();
}

From source file:com.bbxiaoqu.api.ApiResponseFactory.java

/**
  * ?API?// www.ja  va 2 s.c o m
  * 
  * @param action
  *            API
  *            HTTP Response
  * @return ???Null
  */
public static Object getResponse(Context context, int action, HttpResponse httpResponse) {
    InputStream in = null;
    if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
        try {
            in = httpResponse.getEntity().getContent();
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    String requestMethod = "";
    Object result = null;
    switch (action) {
    case MarketAPI.ACTION_REGISTER:
        // 
        requestMethod = "ACTION_REGISTER";
        result = parseLoginOrRegisterResult(in);
        break;
    case MarketAPI.ACTION_LOGIN:
        // 
        requestMethod = "ACTION_LOGIN";
        result = parseLoginOrRegisterResult(in);
        break;
    case MarketAPI.ACTION_GETDYNAMICS:
        // ??
        requestMethod = "ACTION_GETDYNAMICS";
        result = parseGetDaymicResult(in);
        break;
    case MarketAPI.ACTION_GONGGAO:
        // 
        requestMethod = "ACTION_GONGGAO";
        result = parseGongGaoResult(in);
        break;
    case MarketAPI.ACTION_GETINFO:
        // ???
        requestMethod = "ACTION_GETINFO";
        result = parseInfoResult(in);
        break;
    case MarketAPI.ACTION_GETITEMNUM:
        // ???
        requestMethod = "ACTION_GETITEMNUM";
        result = parseItemNumsResult(in);
        break;
    case MarketAPI.ACTION_GETINFOS:
        // ??
        requestMethod = "ACTION_GETINFOS";
        result = parseGetInfosResult(in);
        break;
    case MarketAPI.ACTION_GETFRIENDS:
        // ??
        requestMethod = "ACTION_GETINFOS";
        result = parseGetFriendsResult(in);
        break;
    case MarketAPI.ACTION_GETXIAOQUS:
        // ??
        requestMethod = "ACTION_GETXIAOQUS";
        result = parseGetXiaoqusResult(in);
        break;
    case MarketAPI.ACTION_GETFWINFOS:
        // ??
        requestMethod = "ACTION_GETFWINFOS";
        result = parseGetFwInfosResult(in);
        break;
    case MarketAPI.ACTION_SYSTEMINFO:
        // ??
        requestMethod = "ACTION_SYSTEMINFO";
        result = parseSystemXmlResult(in);
        break;
    case MarketAPI.ACTION_GETUESERINFO:
        // ??
        requestMethod = "ACTION_GETUESERINFO";
        result = parseGetUserInfoResult(in);
        break;

    case MarketAPI.ACTION_MYRANK:
        // ??
        requestMethod = "ACTION_MYRANK";
        result = parseResult(in);
        break;
    case MarketAPI.ACTION_RANK:
        // ??
        requestMethod = "ACTION_RANK";
        result = parseResult(in);
        break;
    case MarketAPI.ACTION_GETUERSUMMARY:
        // ??
        requestMethod = "ACTION_GETUERSUMMARY";
        result = parseResult(in);
        break;
    case MarketAPI.ACTION_GETUSERVISIBLERANGE:
        // ??
        requestMethod = "ACTION_GETUERSUMMARY";
        result = parseResult(in);
        break;
    case MarketAPI.ACTION_GETUSERVISIBLECOMMUNITY:
        // ??
        requestMethod = "ACTION_GETUERSUMMARY";
        result = parseResult(in);
        break;
    case MarketAPI.ACTION_DAILYLOGIN:
        // ??
        requestMethod = "ACTION_GETUERSUMMARY";
        result = parseResult(in);
        break;
    case MarketAPI.ACTION_GETSHOPINFO:
        // ??
        requestMethod = "ACTION_GETSHOPINFO";
        result = parseResult(in);
        break;
    default:
        break;
    }
    if (result != null) {
        Utils.D(requestMethod + "'s Response is : " + result.toString());
    } else {
        Utils.D(requestMethod + "'s Response is null");
    }
    return result;
}

From source file:com.fuzz.android.limelight.util.JSONTool.java

/**
 * @param reader/*from  ww  w .ja  va  2  s.  c om*/
 * @return the generated ChapterTransition object from JSON
 * @throws IOException
 */
public static ChapterTransition readTransition(JsonReader reader) throws IOException {
    long time = -1;
    int itemPosition = -1;
    int childId = -1;
    int anchorId = -1;
    String message = null;
    int messageResId = -1;
    int grapicResID = -1;
    boolean isActionBarItem = false;
    double xOffset = -1;
    double yOffset = -1;
    int textColor = -1;
    int textBackgroundColor = -1;
    float textSize = -1;
    boolean textBackgroundTransparent = false;
    String animation = null;

    while (reader.hasNext()) {
        try {
            String name = reader.nextName();
            if (name.equals("time"))
                time = reader.nextLong();
            else if (name.equals("item_position"))
                itemPosition = reader.nextInt();
            else if (name.equals("child_id"))
                childId = reader.nextInt();
            else if (name.equals("id"))
                anchorId = reader.nextInt();
            else if (name.equals("message"))
                message = reader.nextString();
            else if (name.equals("message_res_id"))
                messageResId = reader.nextInt();
            else if (name.equals("graphic_res_id"))
                grapicResID = reader.nextInt();
            else if (name.equals("is_action_bar_item"))
                isActionBarItem = reader.nextBoolean();
            else if (name.equals("x_offset"))
                xOffset = reader.nextDouble();
            else if (name.equals("y_offset"))
                yOffset = reader.nextDouble();
            else if (name.equals("text_color"))
                textColor = reader.nextInt();
            else if (name.equals("text_background_color"))
                textBackgroundColor = reader.nextInt();
            else if (name.equals("text_size"))
                textSize = reader.nextLong();
            else if (name.equals("text_background_transparent"))
                textBackgroundTransparent = reader.nextBoolean();
            else if (name.equals("animation"))
                animation = reader.nextString();
        } catch (IllegalStateException e) {
            reader.nextNull();
            e.printStackTrace();
        }
    }

    reader.endObject();

    ChapterTransition transition = new ChapterTransition();
    transition.setTime(time);
    transition.setItemPosition(itemPosition);
    transition.setChildID(childId);
    transition.setId(anchorId);
    transition.setMessage(message);
    transition.setMessageResID(messageResId);
    transition.setGraphicResID(grapicResID);
    transition.setIsActionBarItem(isActionBarItem);
    transition.setDisplacement(xOffset, yOffset);
    transition.setTextColor(textColor);
    transition.setTextBackgroundColor(textBackgroundColor);
    transition.setTextSize(textSize);
    transition.setTransparentBackground(textBackgroundTransparent);
    transition.setAnimation(animation);

    return transition;
}

From source file:it.isislab.dmason.util.SystemManagement.Worker.Updater.java

private static void downloadJar(String jarName, String jarType) {

    FTPClient client = connect(FTPIP, Integer.parseInt(FTPPORT));

    login(client);//from www  .  j a  v a  2s . c om

    File downDir = new File(DOWNLOADED_JAR_PATH);
    // if the directory does not exist, create it
    if (!downDir.exists()) {

        boolean result = downDir.mkdir();
        if (result) {
            System.out.println("DIR created");
        }

    }

    try {

        if (jarType.equals("upd"))
            client.changeDirectory(UPDATE_DIR);
        if (jarType.equals("sim")) {
            client.changeDirectory(SIMULATION_DIR);

            File simFile = new File(DOWNLOADED_JAR_PATH + SEPARATOR + jarName);

            String digestFile = FilenameUtils.removeExtension(jarName) + ".hash";

            client.download(digestFile, new java.io.File(DOWNLOADED_JAR_PATH + SEPARATOR + digestFile));

            if (simFile.exists()) //if the worker has the jar
            {

                Digester dg = new Digester(DigestAlgorithm.MD5);

                String DownloadedDigest = dg.loadFromPropFile(DOWNLOADED_JAR_PATH + SEPARATOR + digestFile);

                dg = new Digester(DigestAlgorithm.MD5);

                try {
                    InputStream in = new FileInputStream(DOWNLOADED_JAR_PATH + SEPARATOR + jarName);

                    String digest = dg.getDigest(in);

                    if (DownloadedDigest.equals(digest))
                        return;

                } catch (IOException ex) {
                    ex.printStackTrace();
                }

            }
        }

        //if(jarType.equals("upd"))
        //   client.download(jarName, new java.io.File(jarName));
        //if(jarType.equals("sim"))
        client.download(jarName, new java.io.File(DOWNLOADED_JAR_PATH + SEPARATOR + jarName));

    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (FTPIllegalReplyException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (FTPException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (FTPDataTransferException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (FTPAbortedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.opendatakit.aggregate.form.FormDefinition.java

/**
 * Synchronized access to the formDefinitions map.  Synchronization is only required for the
 * put operation on the map, but also aids in efficient quota usage during periods of intense start-up.
 *
 * @param xformParameters  -- the form id, version and ui version of a form definition.
 * @param uriSubmissionDataModel -- the uri of the definition specification.
 * @param cc/*  ww  w . j  a v  a  2s.  com*/
 * @return The definition.  The uriSubmissionDataModel is used to ensure that the
 *          currently valid definition of a form is being used (should the form be
 *          deleted then reloaded).
 */
public static synchronized final FormDefinition getFormDefinition(String formId, CallingContext cc) {

    if (formId.indexOf('/') != -1) {
        throw new IllegalArgumentException("formId is not well formed: " + formId);
    }

    // always look at SubmissionAssociationTable to retrieve the proper variant
    boolean asDaemon = cc.getAsDeamon();
    try {
        cc.setAsDaemon(true);
        List<? extends CommonFieldsBase> fdmList = null;
        Datastore ds = cc.getDatastore();
        User user = cc.getCurrentUser();
        try {
            SubmissionAssociationTable sa = getSubmissionAssociation(formId, false, cc);
            if (sa == null) {
                // must be in a partially defined state.
                logger.warn("No complete persistence model for sa record matching this formId " + formId);
                return null;
            }
            String uriSubmissionDataModel = sa.getUriSubmissionDataModel();

            // try to retrieve based upon this uri...
            FormDefinition fd = formDefinitions.get(uriSubmissionDataModel);
            if (fd != null) {
                // found it...
                return fd;
            } else {
                // retrieve it...
                FormDataModel fdm = FormDataModel.assertRelation(cc);
                Query query = ds.createQuery(fdm, "FormDefinition.getFormDefinition", user);
                query.addFilter(FormDataModel.URI_SUBMISSION_DATA_MODEL, FilterOperation.EQUAL,
                        uriSubmissionDataModel);
                fdmList = query.executeQuery();

                if (fdmList == null || fdmList.size() == 0) {
                    logger.warn("No FDM records for formId " + formId);
                    return null;
                }

                // try to construct the fd...
                try {
                    fd = new FormDefinition(sa, formId, fdmList, cc);
                } catch (IllegalStateException e) {
                    e.printStackTrace();
                    logger.error("Form definition is not interpretable for formId " + formId);
                    return null;
                }

                // and synchronize field sizes to those defined in the database...
                try {
                    Set<CommonFieldsBase> objs = new HashSet<CommonFieldsBase>();
                    assertBackingObjects(fd.getTopLevelGroup(), objs, cc);
                } catch (ODKDatastoreException e1) {
                    e1.printStackTrace();
                    logger.error("Asserting relations failed for formId " + formId);
                    fd = null;
                }

                // errors might have not cleared the fd...
                if (fd != null) {
                    // remember details about this form
                    formDefinitions.put(uriSubmissionDataModel, fd);
                    return fd;
                }
            }
        } catch (ODKDatastoreException e) {
            logger.warn("Persistence Layer failure " + e.getMessage() + " for formId " + formId);
            return null;
        }
    } finally {
        cc.setAsDaemon(asDaemon);
    }
    return null;
}

From source file:de.xirp.settings.Settings.java

private static void addCheckboxOption(Settings settings) {
    SettingsPage settingsPage = settings.addPage("checkpage", "shortdescription", "description");

    Option option = settingsPage.addOption("checkbox", Option.OptionType.CHECKBOX);
    try {/*from   w w w  .  jav  a  2  s. co  m*/
        option.addNonTranslatableNamedBooleanValue("Nicht bersetzbar", SettingsState.SELECTED);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addNumberValue(30.56, SettingsState.SELECTED);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addPasswordValue("somekey", "PasswordValue");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addRGBValue("somergb", 255, 255, 0);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addSpinnerValue(20.5, -10, 20, 1);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addStringValue("somestrg", "Freier String");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addTranslatableNamedBooleanValue("value1", SettingsState.SELECTED, "Ein Argument");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}

From source file:de.xirp.settings.Settings.java

private static void addRadioOption(Settings settings) {
    SettingsPage settingsPage = settings.addPage("radiopage", "shortdescription", "description");

    Option option = settingsPage.addOption("radio", Option.OptionType.RADIOBUTTON);
    try {//from w ww  .j a  v a2 s  .co  m
        option.addNonTranslatableNamedBooleanValue("Nicht bersetzbar", SettingsState.SELECTED);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addNumberValue(30.56, SettingsState.SELECTED);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addPasswordValue("somekey", "PasswordValue");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addRGBValue("somergb", 255, 255, 0);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addSpinnerValue(20.5, -10, 20, 1);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addStringValue("somestrg", "Freier String");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addTranslatableNamedBooleanValue("value1", SettingsState.SELECTED, "Ein Argument");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}

From source file:de.xirp.settings.Settings.java

private static void addComboOption(Settings settings) {
    SettingsPage settingsPage = settings.addPage("combopage", "shortdescription", "description");

    Option option = settingsPage.addOption("combo", Option.OptionType.COMBOBOX);
    try {//from   w w w  . java2  s .co  m
        option.addNonTranslatableNamedBooleanValue("Nicht bersetzbar", SettingsState.SELECTED);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addNumberValue(30.56, SettingsState.SELECTED);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addPasswordValue("somekey", "PasswordValue");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addRGBValue("somergb", 255, 255, 0);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addSpinnerValue(20.5, -10, 20, 1);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addStringValue("somestrg", "Freier String");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    try {
        option.addTranslatableNamedBooleanValue("value1", SettingsState.SELECTED, "Ein Argument");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}

From source file:de.xirp.settings.Settings.java

private static void addColorOptions(Settings settings) {
    SettingsPage settingsPage = settings.addPage("colorpage", "shortdescription", "description");

    Option option = settingsPage.addOption("color", Option.OptionType.COLOR);
    try {/*from ww w  .  j av a2 s.com*/
        option.addNonTranslatableNamedBooleanValue("Nicht bersetzbar", SettingsState.SELECTED);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    option = settingsPage.addOption("color2", Option.OptionType.COLOR);
    try {
        option.addNumberValue(30.56, SettingsState.SELECTED);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    option = settingsPage.addOption("color3", Option.OptionType.COLOR);
    try {
        option.addPasswordValue("somekey", "PasswordValue");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    option = settingsPage.addOption("color4", Option.OptionType.COLOR);
    try {
        option.addRGBValue("somergb", 255, 255, 0);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    option = settingsPage.addOption("color5", Option.OptionType.COLOR);
    try {
        option.addSpinnerValue(20.5, -10, 20, 1);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    option = settingsPage.addOption("color6", Option.OptionType.COLOR);
    try {
        option.addStringValue("somestrg", "Freier String");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    option = settingsPage.addOption("color7", Option.OptionType.COLOR);
    try {
        option.addTranslatableNamedBooleanValue("value1", SettingsState.SELECTED, "Ein Argument");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}

From source file:de.xirp.settings.Settings.java

private static void addTextfieldOptions(Settings settings) {
    SettingsPage settingsPage = settings.addPage("textpage", "shortdescription", "description");

    Option option = settingsPage.addOption("textfield", Option.OptionType.TEXTFIELD);
    try {// w  w  w .  j a va2  s . co m
        option.addNonTranslatableNamedBooleanValue("Nicht bersetzbar", SettingsState.SELECTED);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }

    option = settingsPage.addOption("textfield2", Option.OptionType.TEXTFIELD);
    try {
        option.addNumberValue(30.56, SettingsState.SELECTED);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    option = settingsPage.addOption("textfield3", Option.OptionType.TEXTFIELD);
    try {
        option.addPasswordValue("somekey", "PasswordValue");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    option = settingsPage.addOption("textfield4", Option.OptionType.TEXTFIELD);
    try {
        option.addRGBValue("somergb", 255, 255, 0);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    option = settingsPage.addOption("textfield5", Option.OptionType.TEXTFIELD);
    try {
        option.addSpinnerValue(20.5, -10, 20, 1);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    option = settingsPage.addOption("textfield6", Option.OptionType.TEXTFIELD);
    try {
        option.addStringValue("somestrg", "Freier String");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
    option = settingsPage.addOption("textfield7", Option.OptionType.TEXTFIELD);
    try {
        option.addTranslatableNamedBooleanValue("value1", SettingsState.SELECTED, "Ein Argument");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}