Example usage for java.lang Boolean parseBoolean

List of usage examples for java.lang Boolean parseBoolean

Introduction

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

Prototype

public static boolean parseBoolean(String s) 

Source Link

Document

Parses the string argument as a boolean.

Usage

From source file:com.esri.geoportal.harvester.agp.AgpOutputBrokerDefinitionAdaptor.java

/**
 * Creates instance of the adaptor.//  w w  w . j  a va2  s.  c om
 * @param def broker definition
 * @throws IllegalArgumentException if invalid broker definition
 */
public AgpOutputBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException {
    super(def);
    this.credAdaptor = new CredentialsDefinitionAdaptor(def);
    if (StringUtils.trimToEmpty(def.getType()).isEmpty()) {
        def.setType(AgpOutputConnector.TYPE);
    } else if (!AgpOutputConnector.TYPE.equals(def.getType())) {
        throw new InvalidDefinitionException("Broker definition doesn't match");
    } else {
        try {
            hostUrl = new URL(get(P_HOST_URL));
        } catch (MalformedURLException ex) {
            throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL, get(P_HOST_URL)),
                    ex);
        }
        folderId = get(P_FOLDER_ID);
        cleanup = Boolean.parseBoolean(get(P_FOLDER_CLEANUP));
    }
}

From source file:org.wso2.am.integration.ui.tests.util.TestUtil.java

/**
 * Login to API Store or Publisher/* www .  j  a va2s.c o  m*/
 *
 * @param userName
 * @param password
 * @param URL      API Store or Publisher URL
 * @return
 * @throws Exception
 */
public static HttpContext login(String userName, String password, String URL) throws Exception {
    CookieStore cookieStore = new BasicCookieStore();
    HttpContext httpContext = new BasicHttpContext();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(URL + APIMTestConstants.APISTORE_LOGIN_URL);
    // Request parameters and other properties.
    List<NameValuePair> params = new ArrayList<NameValuePair>(3);

    params.add(new BasicNameValuePair(APIMTestConstants.API_ACTION, APIMTestConstants.API_LOGIN_ACTION));
    params.add(new BasicNameValuePair(APIMTestConstants.APISTORE_LOGIN_USERNAME, userName));
    params.add(new BasicNameValuePair(APIMTestConstants.APISTORE_LOGIN_PASSWORD, password));
    httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));

    HttpResponse response = httpclient.execute(httppost, httpContext);
    HttpEntity entity = response.getEntity();
    String responseString = EntityUtils.toString(entity, "UTF-8");
    boolean isError = Boolean.parseBoolean(responseString.split(",")[0].split(":")[1].split("}")[0].trim());

    if (isError) {
        String errorMsg = responseString.split(",")[1].split(":")[1].split("}")[0].trim();
        throw new Exception("Error while Login to API Publisher : " + errorMsg);

    } else {
        return httpContext;
    }

}

From source file:com.trailmagic.image.ui.ImageTag.java

public int doStartTag() throws JspException {
    StringBuffer html = new StringBuffer();
    ImageManifestation mf;/* w  ww  .  ja va  2 s . c  o m*/

    try {
        HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
        // XXX: maybe this should be a parameter of the tag instead?

        // XXX: this is sort of a kludge for setting a default label
        String defaultLabel = req.getParameter(DEFAULT_LABEL_ATTR);
        HttpSession session = req.getSession();
        if (defaultLabel != null) {
            session.setAttribute(DEFAULT_LABEL_ATTR, defaultLabel);
        }

        // XXX: end kludge

        String size = req.getParameter(SIZE_ATTR);
        String originalp = req.getParameter("original");
        if (size != null) {
            mf = WebSupport.getMFBySize(m_image, Integer.parseInt(size), Boolean.parseBoolean(originalp));
        } else {
            // get label by precedence: req param, tag spec, sess attr
            String label = req.getParameter(LABEL_ATTR);
            if (label == null) {
                label = m_sizeLabel;
            }
            if (label == null) {
                label = (String) session.getAttribute(DEFAULT_LABEL_ATTR);
            }
            if (label != null) {
                mf = WebSupport.getMFByLabel(m_image, label);
            } else {
                mf = WebSupport.getDefaultMF((User) pageContext.findAttribute(USER_ATTR), m_image);
            }
        }

        if (mf != null) {
            // XXX: resume kludge
            pageContext.setAttribute("currentLabel", getLabel(mf));
            // XXX: end kludge
            // XXX: end kludge
            html.append("<img src=\"");

            //XXX: yeek?
            /*
            LinkHelper helper =
            new LinkHelper((HttpServletRequest)pageContext.getRequest());
            */
            WebApplicationContext ctx = WebApplicationContextUtils
                    .getRequiredWebApplicationContext(pageContext.getServletContext());
            LinkHelper helper = (LinkHelper) ctx.getBean("linkHelper");

            html.append(helper.getImageMFUrl((HttpServletRequest) pageContext.getRequest(), mf));
            html.append("\" height=\"");
            html.append(mf.getHeight());
            html.append("\" width=\"");
            html.append(mf.getWidth());
            html.append("\" alt=\"");
            if (m_alt != null) {
                html.append(m_alt);
            } else if (m_image.getCaption() != null) {
                html.append(Util.escapeXml(m_image.getCaption()));
            } else {
                html.append(Util.escapeXml(m_image.getDisplayName()));
            }

            html.append("\" class=\"");
            if (mf.getWidth() > mf.getHeight()) {
                html.append("landscape");
            } else {
                html.append("portrait");
            }
            if (m_cssClass != null) {
                html.append(" ");
                html.append(m_cssClass);
            }

            html.append("\"/>");
        } else {
            html.append("No manifestations found for the specified " + "image.");
        }
        pageContext.getOut().write(html.toString());
        return SKIP_BODY;
    } catch (IOException e) {
        throw new JspException(e);
    }
}

From source file:com.esri.geoportal.harvester.gpt.GptBrokerDefinitionAdaptor.java

/**
 * Creates instance of the adaptor.//  w  ww  .java2 s  .  co m
 * @param def broker definition
 */
public GptBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException {
    super(def);
    this.credAdaptor = new CredentialsDefinitionAdaptor(def);
    if (StringUtils.trimToEmpty(def.getType()).isEmpty()) {
        def.setType(GptConnector.TYPE);
    } else if (!GptConnector.TYPE.equals(def.getType())) {
        throw new InvalidDefinitionException("Broker definition doesn't match");
    } else {
        try {
            String sHostUrl = get(P_HOST_URL);
            if (sHostUrl != null) {
                sHostUrl = sHostUrl.replaceAll("/*$", "/");
            }
            hostUrl = new URL(sHostUrl);
        } catch (MalformedURLException ex) {
            throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL, get(P_HOST_URL)),
                    ex);
        }
        forceAdd = Boolean.parseBoolean(get(P_FORCE_ADD));
        cleanup = Boolean.parseBoolean(get(P_CLEANUP));
    }
}

From source file:com.matthewcasperson.validation.ruleimpl.FailIfContainsHTMLValidationRule.java

/**
 * {@inheritDoc}/* w w  w  . ja  va  2s.c o m*/
 */
public void configure(final Map<String, String> settings) {
    if (settings.containsKey(ALLOW_AMPERSANDS)) {
        allowAmpersands = Boolean.parseBoolean(settings.get(ALLOW_AMPERSANDS));
    }

    if (settings.containsKey(ALLOW_ACCENTS)) {
        allowAccents = Boolean.parseBoolean(settings.get(ALLOW_ACCENTS));
    }

    if (settings.containsKey(ALLOW_ELLIPSIS)) {
        allowEllipsis = Boolean.parseBoolean(settings.get(ALLOW_ELLIPSIS));
    }
}

From source file:com.openedit.generators.VelocityGenerator.java

public void generate(WebPageRequest inContext, Page inPage, Output inOut) throws OpenEditException {
    if (log.isDebugEnabled()) {
        log.debug("Rendering " + inPage);
    }/*from   w w  w .ja va2 s  . c o  m*/

    if (!inPage.exists()) //TODO: Create a new existed() method to speed up checks
    {
        String vir = inPage.get("virtual");
        if (!Boolean.parseBoolean(vir)) {
            log.info("Missing: " + inPage.getPath());
            try {
                inOut.getWriter().write("404: " + inPage.getPath());
                return;
            } catch (IOException e) {
                throw new ContentNotAvailableException("Missing: " + inPage.getPath(), inPage.getPath());
            }
        } else {
            return; //do nothing
        }
    }
    try {

        if (inPage.isBinary()) {
            //this should not happen
            InputStream in = inPage.getInputStream();
            new OutputFiller().fill(in, inContext.getOutputStream());
            return;
        }
        inContext.unpackageVariables(); //TODO: Remove this silliness
        VelocityContext context = new VelocityContext(inContext.getPageMap());
        Writer writer = inOut.getWriter();

        if (inPage.getContentItem() instanceof FileItem) //Faster and does cache
        {
            String path = inPage.getContentItem().getPath();
            //log.info( "Rendering " + inPage );
            String filter = inPage.getProperty("oetextfilter");
            if (filter != null) {
                path = path + "?filter=" + filter + "&locale=" + inContext.getLocale();
            }

            getEngine().mergeTemplate(path, inPage.getCharacterEncoding(), context, writer);
        } else //do a string eval MUCH SLOWER
        {
            Reader in = inPage.getReader();
            //log.info( "Eval " + inPage );
            getEngine().evaluate(context, writer, inPage.getPath(), in);
        }
        writer.flush();
    } catch (MethodInvocationException ex) {
        if (ex.getWrappedThrowable() instanceof ContentNotAvailableException) {
            throw new OpenEditException("Error generating " + inPage.getPath(),
                    (OpenEditException) ex.getWrappedThrowable());
        }
        if (ex.getWrappedThrowable() instanceof OpenEditException) {
            throw (OpenEditException) ex.getWrappedThrowable();
        }
        Throwable wrapped = ex.getWrappedThrowable();
        if (ignoreError(wrapped)) {
            //ignore
            return;
        }
        throw new OpenEditException(wrapped);
    } catch (ParseErrorException pex) {
        throw new OpenEditException(pex.getMessage() + " on " + inPage.getPath(), pex);
    } catch (Exception ioex) {
        if (ignoreError(ioex)) {
            log.info("Browser canceled request");
            return;
        }
        if (ioex instanceof OpenEditException) {
            throw (OpenEditException) ioex;
        }
        throw new OpenEditException(ioex);
    }
}

From source file:com.ubikod.capptain.android.sdk.reach.CapptainPoll.java

/**
 * Parse an announcement./*  ww w. ja va 2s. c om*/
 * @param jid service that sent the announcement.
 * @param xml raw XML of announcement to store in SQLite.
 * @param root parsed XML root DOM element.
 * @throws JSONException if a parsing error occurs.
 */
CapptainPoll(String jid, String xml, Element root) throws JSONException {
    super(jid, xml, root);
    mAnswers = new Bundle();
    mQuestions = new JSONArray();
    NodeList questions = root.getElementsByTagNameNS(REACH_NAMESPACE, "question");
    for (int i = 0; i < questions.getLength(); i++) {
        Element questionE = (Element) questions.item(i);
        NodeList choicesN = questionE.getElementsByTagNameNS(REACH_NAMESPACE, "choice");
        JSONArray choicesJ = new JSONArray();
        for (int j = 0; j < choicesN.getLength(); j++) {
            Element choiceE = (Element) choicesN.item(j);
            JSONObject choiceJ = new JSONObject();
            choiceJ.put("id", choiceE.getAttribute("id"));
            choiceJ.put("title", XmlUtil.getText(choiceE));
            choiceJ.put("default", Boolean.parseBoolean(choiceE.getAttribute("default")));
            choicesJ.put(choiceJ);
        }
        JSONObject questionJ = new JSONObject();
        questionJ.put("id", questionE.getAttribute("id"));
        questionJ.put("title", XmlUtil.getTagText(questionE, "title", null));
        questionJ.put("choices", choicesJ);
        mQuestions.put(questionJ);
    }
}

From source file:it.govpay.web.rs.dars.anagrafica.iban.input.IdNegozio.java

@Override
protected boolean isHidden(List<RawParamValue> values, Object... objects) {
    String attivatoObepValue = Utils.getValue(values, this.attivatoObepId);

    if (StringUtils.isNotEmpty(attivatoObepValue) && Boolean.parseBoolean(attivatoObepValue)) {
        return false;
    }//  w  w  w  . ja  va  2 s .c om

    return true;
}

From source file:fr.ensimag.biblio.controllers.StatImg.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request/*  w w w.  jav  a2s  . com*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    OutputStream out = response.getOutputStream();
    response.setContentType("image/png");
    //int val1 = 40;
    //int val2 = 60;
    try {
        DefaultPieDataset dataset = new DefaultPieDataset();
        String title = "Statistiques";
        boolean legend = true;

        Map<String, String[]> params = request.getParameterMap();
        for (Map.Entry<String, String[]> param : params.entrySet()) {
            String key = param.getKey();
            String[] value = param.getValue();
            System.out.println("key : " + key + "value : " + value[0]);
            if (key.equals("legend"))
                legend = Boolean.parseBoolean(value[0]);
            else
                dataset.setValue(key, Double.parseDouble(value[0]));
        }

        //dataset.setValue("Valeur 1", val1);
        //dataset.setValue("Valeur 2", val2);
        JFreeChart chart = ChartFactory.createPieChart(title, dataset, legend, false, false);
        chart.setBackgroundPaint(Color.WHITE);
        ChartUtilities.writeChartAsPNG(out, chart, 500, 300);
    } finally {
        out.close();
    }
}

From source file:com.oakesville.mythling.prefs.firetv.FireTvConnectPrefs.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getActivity().getActionBar().setTitle(R.string.title_connect);
    addPreferencesFromResource(R.xml.firetv_connect_prefs);

    AppSettings appSettings = new AppSettings(getPreferenceScreen().getContext());

    Preference pref = getPreferenceScreen().findPreference(AppSettings.MYTH_BACKEND_INTERNAL_HOST);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(true, true) {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean ret = super.onPreferenceChange(preference, newValue);
            preference.setTitle(//w  w w  .ja  v  a2s  . co  m
                    newValue.toString().isEmpty() ? R.string.title_backend_host_ : R.string.title_backend_host);
            return ret;
        }
    });
    String internalHost = appSettings.getInternalBackendHost();
    pref.setSummary(internalHost);
    if (internalHost.isEmpty())
        pref.setTitle(R.string.title_backend_host_);

    pref = getPreferenceScreen().findPreference(AppSettings.ALWAYS_PROMPT_FOR_PLAYBACK_OPTIONS);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(false, false) {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean update = super.onPreferenceChange(preference, newValue);
            if (Boolean.parseBoolean(newValue.toString())) {
                AppSettings settings = new AppSettings(getPreferenceScreen().getContext());
                try {
                    settings.getPlaybackOptions().clearAlwaysDoThisSettings();
                } catch (JSONException ex) {
                    Log.e(TAG, ex.getMessage(), ex);
                    if (settings.isErrorReportingEnabled())
                        new Reporter(ex).send();
                    settings.getPlaybackOptions().clearAll();
                }
            }
            return update;
        }
    });

    pref = getPreferenceScreen().findPreference(AppSettings.ERROR_REPORTING);
    pref.setOnPreferenceChangeListener(new PrefChangeListener(false, false));

    pref = getPreferenceScreen().findPreference(AppSettings.MYTHLING_VERSION);
    pref.setTitle(appSettings.getMythlingVersion());
}