List of usage examples for java.lang Boolean parseBoolean
public static boolean parseBoolean(String s)
From source file:de.dal33t.powerfolder.util.ConfigurationLoader.java
public static boolean overwriteConfigEntries(Properties p) { boolean overWrite = Boolean.valueOf(ConfigurationEntry.CONFIG_OVERWRITE_VALUES.getDefaultValue()); String owStr = p.getProperty(ConfigurationEntry.CONFIG_OVERWRITE_VALUES.getConfigKey()); try {/*from ww w . ja va 2 s .c om*/ overWrite = Boolean.parseBoolean(owStr); } catch (Exception e) { LOG.warning("Unable to parse pre-config overwrite value. Problem value: " + owStr + ". Now using: " + overWrite + ". " + e); } return overWrite; }
From source file:com.intel.cosbench.web.AbstractController.java
@Override public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse res) throws Exception { ModelAndView result;//from ww w . j a va 2 s.com try { result = process(req, res); } catch (BadRequestException bre) { return new ModelAndView("400"); } catch (NotFoundException nfe) { return new ModelAndView("404"); } catch (FileNotFoundException fnfe) { return new ModelAndView("404", "resource", fnfe.getMessage()); } catch (Exception e) { StringWriter writer = new StringWriter(); e.printStackTrace(new PrintWriter(writer)); return new ModelAndView("500", "cause", writer.toString()); } String showDetails = req.getParameter("showDetails"); result.addObject("showDetails", Boolean.parseBoolean(showDetails)); String perfDetails = req.getParameter("perfDetails"); result.addObject("perfDetails", Boolean.parseBoolean(perfDetails)); String showErrorStatistics = req.getParameter("showErrorStatistics"); result.addObject("showErrorStatistics", Boolean.parseBoolean(showErrorStatistics)); return result; }
From source file:caphyon.jenkins.advinst.AdvinstParameters.java
public boolean get(String key, boolean defaultValue) { boolean rvalue = defaultValue; String tmp = this.mProperties.getProperty(key); if (tmp != null) { try {/*from w ww . j a v a2 s.co m*/ rvalue = Boolean.parseBoolean(tmp); } catch (Exception e) { // nothing to do } } return rvalue; }
From source file:persistence.AuthorDao.java
public List<Author> search(String name, String surname, String middlename, String email, String phone, String login, Direction direction, String active) { Criteria crit = currentSession().createCriteria(Author.class); if (StringAdapter.NotNull(name)) { crit.add(Restrictions.like("name", "%" + name + "%")); }//from w ww. j av a2s . c o m if (StringAdapter.NotNull(surname)) { crit.add(Restrictions.like("surname", "%" + surname + "%")); } if (StringAdapter.NotNull(middlename)) { crit.add(Restrictions.like("middlename", "%" + middlename + "%")); } if (StringAdapter.NotNull(phone)) { crit.add(Restrictions.like("phone", "%" + phone + "%")); } if (StringAdapter.NotNull(login)) { crit.add(Restrictions.like("login", "%" + login + "%")); } if (direction != null) { crit.createAlias("directions", "d"); crit.add(Restrictions.eq("d.directionId", direction.getDirectionId())); } if (StringAdapter.NotNull(active)) { boolean activeBoolean = Boolean.parseBoolean(active); crit.add(Restrictions.eq("active", activeBoolean)); } crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); List<Author> list = crit.list(); return list; }
From source file:org.openbaton.nfvo.security.authentication.ResourceServer.java
@Override public void configure(HttpSecurity http) throws Exception { http.headers().frameOptions().disable(); boolean enabled = Boolean.parseBoolean(enabledSt); // API calls//from www. jav a 2s . c o m if (true) { log.info("Security is enabled"); http.authorizeRequests().regexMatchers(HttpMethod.POST, "/api/v1/").access("#oauth2.hasScope('write')") .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER).and() .exceptionHandling(); http.authorizeRequests().antMatchers(HttpMethod.POST, "/api/**").access("#oauth2.hasScope('write')") .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER).and() .exceptionHandling(); http.authorizeRequests().regexMatchers(HttpMethod.GET, "/api/v1/vnf-packages/*/download-with-link") .permitAll(); } else { log.warn("Security is not enabled!"); http.authorizeRequests().anyRequest().permitAll(); } }
From source file:org.hummer.spring.ReferenceParser.java
public BeanDefinition parse(Element ele, ParserContext context) { //?/* w ww. ja v a 2s . co m*/ service = ele.getAttribute(ATTR_SERVICE); version = ele.getAttribute(ATTR_VERSION); if (service == null || version == null) { throw new RuntimeException("?!"); } timeout = ele.getAttribute(ATTR_TIMEOUT) == null ? 3000 : Integer.parseInt(ele.getAttribute(ATTR_TIMEOUT)); unit = ele.getAttribute(ATTR_UNIT) == null ? false : Boolean.parseBoolean(ele.getAttribute(ATTR_UNIT)); retry = ele.getAttribute(ATTR_RETRY) == null ? 3 : Integer.parseInt(ele.getAttribute(ATTR_RETRY)); RootBeanDefinition root = new RootBeanDefinition(ReferenceBean.class); root.getPropertyValues().add("service", service); root.getPropertyValues().add("version", version); root.getPropertyValues().add("timeout", timeout); root.getPropertyValues().add("unit", unit); root.getPropertyValues().add("retry", retry); context.getRegistry().registerBeanDefinition(ele.getAttribute("id"), root); return root; }
From source file:org.openscore.content.httpclient.build.URIBuilder.java
public URI buildURI() { try {//www .ja va2 s . co m //validate as URL new URL(url); } catch (MalformedURLException e) { throw new IllegalArgumentException("could not parse " + url, e); } org.apache.http.client.utils.URIBuilder uriBuilder; try { uriBuilder = new org.apache.http.client.utils.URIBuilder(url); } catch (URISyntaxException e) { throw new IllegalArgumentException("could not parse " + url + " as a URI", e); } boolean bEncodeQueryParams = !Boolean.parseBoolean(queryParamsAreURLEncoded); if (!StringUtils.isEmpty(queryParams)) { try { uriBuilder.addParameters( (List<NameValuePair>) Utils.urlEncodeMultipleParams(queryParams, bEncodeQueryParams)); } catch (IllegalArgumentException ie) { throw new IllegalArgumentException(HttpClientInputs.QUERY_PARAMS_ARE_URLENCODED + " is 'false' but queryParams are not properly encoded. " + ie.getMessage(), ie); } } try { return uriBuilder.build(); } catch (URISyntaxException e) { throw new IllegalArgumentException("could not build '" + HttpClientInputs.URL + "' for " + url + " and queries " + queryParamsAreURLEncoded, e); } }
From source file:de.tor.tribes.util.ClipboardWatch.java
private synchronized void playNotification() { if (!Boolean.parseBoolean(GlobalOptions.getProperty("clipboard.notification"))) { return;//from w ww . j a v a 2 s . co m } Timer t = new Timer("ClipboardNotification", true); t.schedule(new TimerTask() { @Override public void run() { if (clip != null) {//reset clip clip.stop(); clip.setMicrosecondPosition(0); } if (ac != null) { ac.stop(); } try { if (org.apache.commons.lang.SystemUtils.IS_OS_WINDOWS) { if (clip == null) { clip = AudioSystem.getClip(); AudioInputStream inputStream = AudioSystem .getAudioInputStream(ClockFrame.class.getResourceAsStream("/res/Ding.wav")); clip.open(inputStream); } clip.start(); } else { if (ac == null) { ac = Applet.newAudioClip(ClockFrame.class.getResource("/res/Ding.wav")); } ac.play(); } } catch (Exception e) { logger.error("Failed to play notification", e); } } }, 0); }
From source file:com.amalto.core.servlet.ExportServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse resp) throws ServletException { XmlServer server = Util.getXmlServerCtrlLocal(); String clusterName = getParameter(request, PARAMETER_CLUSTER, true); int start = Integer.parseInt(getParameter(request, PARAMETER_START, true)); int end = Integer.parseInt(getParameter(request, PARAMETER_END, true)); boolean includeMetadata = Boolean .parseBoolean(getParameter(request, PARAMETER_INCLUDE_METADATA, false, "false")); //$NON-NLS-1$ ServletOutputStream outputStream;// w w w. j av a 2s. c o m try { outputStream = resp.getOutputStream(); } catch (IOException e) { throw new ServletException(e); } try { resp.setContentType("text/xml"); server.exportDocuments(clusterName, start, end, includeMetadata, outputStream); } catch (XtentisException e) { throw new ServletException(e); } finally { try { outputStream.flush(); } catch (IOException e) { LOGGER.error("Error during flush", e); } } }
From source file:cz.muni.fi.myweb1.registerServlet.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request/* w w w . j a v 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 doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name = (String) request.getAttribute("username"); String password = (String) request.getAttribute("password"); Boolean employee = Boolean.parseBoolean(request.getAttribute("employee").toString()); if (myFacade.register(name, password, employee)) { request.getSession().setAttribute("username", name); RequestDispatcher rd = request.getRequestDispatcher("/outline.jsp"); rd.forward(request, response); } else { //TODO error } }