List of usage examples for java.lang Boolean valueOf
public static Boolean valueOf(String s)
From source file:fr.univlorraine.ecandidat.controllers.DemoController.java
public Boolean getDemoMode() { if (isDemoMode == null) { isDemoMode = Boolean.valueOf(environment.getProperty("demoMode")); if (isDemoMode == null) { isDemoMode = false;// ww w .j av a 2 s .c o m } } return isDemoMode; }
From source file:com.betfair.cougar.marshalling.impl.databinding.xml.XMLUtils.java
public static Schema getSchema(JAXBContext context) { Result result = new ResultImplementation(); SchemaOutputResolver outputResolver = new SchemaOutputResolverImpl(result); File tempFile = null;// w w w . j a va 2s .c o m try { context.generateSchema(outputResolver); String schemaFile = result.getSystemId(); if (schemaFile != null) { tempFile = new File(URI.create(schemaFile)); String content = FileUtils.readFileToString(tempFile); // JAXB nicely generates a schema with element refs, unfortunately it also adds the nillable attribute to the // referencing element, which is invalid, it has to go on the target. this string manipulation is to move the // nillable attribute to the correct place, preserving it's value. Map<String, Boolean> referenceElementsWithNillable = new HashMap<>(); BufferedReader br = new BufferedReader(new StringReader(content)); String line; while ((line = br.readLine()) != null) { if (line.contains("<xs:element") && line.contains(" ref=\"") && line.contains(" nillable=\"")) { // we've got a reference element with nillable set int refStartIndex = line.indexOf(" ref=\"") + 6; int refEndIndex = line.indexOf("\"", refStartIndex); int nillableStartIndex = line.indexOf(" nillable=\"") + 11; int nillableEndIndex = line.indexOf("\"", nillableStartIndex); String ref = line.substring(refStartIndex, refEndIndex); if (ref.startsWith("tns:")) { ref = ref.substring(4); } String nillable = line.substring(nillableStartIndex, nillableEndIndex); referenceElementsWithNillable.put(ref, Boolean.valueOf(nillable)); } } // if we got some hits, then we need to rewrite this schema if (!referenceElementsWithNillable.isEmpty()) { StringBuilder sb = new StringBuilder(); br = new BufferedReader(new StringReader(content)); while ((line = br.readLine()) != null) { // these we need to remove the nillable section from if (line.contains("<xs:element") && line.contains(" ref=\"") && line.contains(" nillable=\"")) { int nillableStartIndex = line.indexOf(" nillable=\""); int nillableEndIndex = line.indexOf("\"", nillableStartIndex + 11); line = line.substring(0, nillableStartIndex) + line.substring(nillableEndIndex + 1); } else if (line.contains("<xs:element name=\"")) { for (String key : referenceElementsWithNillable.keySet()) { // this we need to add the nillable back to String elementTagWithName = "<xs:element name=\"" + key + "\""; if (line.contains(elementTagWithName)) { int endOfElementName = line.indexOf(elementTagWithName) + elementTagWithName.length(); line = line.substring(0, endOfElementName) + " nillable=\"" + referenceElementsWithNillable.get(key) + "\"" + line.substring(endOfElementName); break; } } } sb.append(line).append("\n"); } content = sb.toString(); } SchemaFactory sf = SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI); return sf.newSchema(new StreamSource(new StringReader(content))); } } catch (IOException e) { throw new PanicInTheCougar(e); } catch (SAXException e) { throw new PanicInTheCougar(e); } finally { if (tempFile != null) tempFile.delete(); } return null; }
From source file:com.alibaba.dubboadmin.web.mvc.RouterController.java
private Object convertPrimitive(Class<?> cls, String value) { if (cls == boolean.class || cls == Boolean.class) { return value == null || value.length() == 0 ? false : Boolean.valueOf(value); } else if (cls == byte.class || cls == Byte.class) { return value == null || value.length() == 0 ? 0 : Byte.valueOf(value); } else if (cls == char.class || cls == Character.class) { return value == null || value.length() == 0 ? '\0' : value.charAt(0); } else if (cls == short.class || cls == Short.class) { return value == null || value.length() == 0 ? 0 : Short.valueOf(value); } else if (cls == int.class || cls == Integer.class) { return value == null || value.length() == 0 ? 0 : Integer.valueOf(value); } else if (cls == long.class || cls == Long.class) { return value == null || value.length() == 0 ? 0 : Long.valueOf(value); } else if (cls == float.class || cls == Float.class) { return value == null || value.length() == 0 ? 0 : Float.valueOf(value); } else if (cls == double.class || cls == Double.class) { return value == null || value.length() == 0 ? 0 : Double.valueOf(value); }/*from w w w . ja v a 2 s.co m*/ return value; }
From source file:com.lexicalintelligence.admin.remove.RemoveRequest.java
public RemoveResponse execute() { List<BasicNameValuePair> params = Collections .singletonList(new BasicNameValuePair(getName(), StringUtils.join(items, ","))); RemoveResponse removeResponse;/*from www. jav a 2 s.c o m*/ Reader reader = null; try { HttpResponse response = client.getHttpClient().execute(new HttpGet(client.getUrl() + PATH + getPath() + "?" + URLEncodedUtils.format(params, StandardCharsets.UTF_8))); reader = new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8); removeResponse = new RemoveResponse(Boolean.valueOf(IOUtils.toString(reader))); } catch (Exception e) { removeResponse = new RemoveResponse(false); log.error(e); } finally { try { reader.close(); } catch (Exception e) { log.error(e); } } return removeResponse; }
From source file:org.jasig.portlet.notice.controller.notification.NotificationIconController.java
@RenderMapping() public ModelAndView display(RenderRequest req) { final Map<String, Object> model = new HashMap<String, Object>(); final PortletPreferences prefs = req.getPreferences(); final boolean usePortalJsLibs = Boolean.valueOf(prefs.getValue(USE_PPORTAL_JS_LIBS_PREFERENCE, "true")); // default is true model.put("usePortalJsLibs", usePortalJsLibs); final String portalJsNamespace = prefs.getValue(PPORTAL_JS_NAMESPACE_PREFERENCE, "up"); // Matches the current convention in uPortal model.put("portalJsNamespace", portalJsNamespace); final String faIcon = prefs.getValue(ICON_PREFERENCE, ICON_DEFAULT); model.put("faIcon", faIcon); final String activeNotificationColor = prefs.getValue(ACTIVE_COLOR_PREFERENCE, ACTIVE_COLOR_DEFAULT); model.put("activeNotificationColor", activeNotificationColor); final String url = prefs.getValue(URL_PREFERENCE, URL_DEFAULT); model.put("url", url); final UUID uuid = UUID.randomUUID(); model.put("uuid", uuid); return new ModelAndView(VIEW_NAME, model); }
From source file:org.jasig.portlet.announcements.mvc.servlet.AjaxApproveController.java
@RequestMapping public ModelAndView toggleApprove(HttpServletRequest request) throws PortletException { final Long annId = Long.valueOf(request.getParameter("annId")); final Boolean approval = Boolean.valueOf(request.getParameter("approval")); final Announcement ann = announcementService.getAnnouncement(annId); final Date startDisplay = ann.getStartDisplay(); Date endDisplay = ann.getEndDisplay(); if (endDisplay == null) { // Unspecified end date means the announcement does not expire; we // will substitute a date in the future each time this item is // evaluated. final long aYearFromNow = System.currentTimeMillis() + Announcement.MILLISECONDS_IN_A_YEAR; endDisplay = new Date(aYearFromNow); }/* w ww .j av a 2s. c o m*/ final Date now = new Date(); int status = STATUS_PENDING; // default /* Scheduled = 0 Expired = 1 Showing = 2 Pending = 3 */ if (startDisplay.after(now) && endDisplay.after(now) && approval) { status = STATUS_SCHEDULED; } else if (startDisplay.before(now) && endDisplay.after(now) && approval) { status = STATUS_SHOWING; } else if (endDisplay.before(now)) { status = STATUS_EXPIRED; } ann.setPublished(approval); announcementService.addOrSaveAnnouncement(ann); return new ModelAndView("ajaxApprove", "status", status); }
From source file:org.openbaton.common.vnfm_sdk.amqp.AbstractVnfmSpringJMS.java
@Bean public JmsListenerContainerFactory<?> jmsListenerContainerFactory(ConnectionFactory connectionFactory) { SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory(); factory.setConnectionFactory(connectionFactory); loadProperties();/* w w w. j av a 2 s . c o m*/ log.debug("JMSCONTAINER Properties are: " + properties); factory.setSessionTransacted(Boolean.valueOf(properties.getProperty("transacted", "false"))); // factory.setSessionTransacted(true); return factory; }
From source file:blue.orchestra.blueSynthBuilder.PresetGroup.java
public static PresetGroup loadFromXML(Element data) { PresetGroup group = new PresetGroup(); group.setPresetGroupName(data.getAttributeValue("name")); String val = data.getAttributeValue("currentPresetUniqueId"); if (val != null && val.length() > 0) { group.setCurrentPresetUniqueId(val); }// ww w .j av a2 s . com val = data.getAttributeValue("currentPresetModified"); if (val != null && val.length() > 0) { group.setCurrentPresetModified(Boolean.valueOf(val).booleanValue()); } Elements nodes = data.getElements(); while (nodes.hasMoreElements()) { Element node = nodes.next(); if (node.getName().equals("presetGroup")) { PresetGroup pGroup = PresetGroup.loadFromXML(node); group.getSubGroups().add(pGroup); } else if (node.getName().equals("preset")) { Preset preset = Preset.loadFromXML(node); group.getPresets().add(preset); } } return group; }
From source file:de.betterform.xml.xforms.action.DispatchAction.java
/** * Performs element init./* w w w.j a va2 s .co m*/ */ public void init() throws XFormsException { super.init(); this.eventName = new AttributeOrValueChild(this.element, this.model, NAME_ATTRIBUTE); this.eventName.init(); this.eventTarget = new AttributeOrValueChild(this.element, this.model, TARGETID_ATTRIBUTE); this.eventTarget.init(); if (!this.eventTarget.isAvailable()) { throw new XFormsBindingException( "missing targetid attribute or child at " + DOMUtil.getCanonicalPath(this.getElement()), this.target, null); } String bubblesAttribute = getXFormsAttribute(BUBBLES_ATTRIBUTE); if (bubblesAttribute != null) { this.bubbles = Boolean.valueOf(bubblesAttribute).booleanValue(); } String cancelableAttribute = getXFormsAttribute(CANCELABLE_ATTRIBUTE); if (cancelableAttribute != null) { this.cancelable = Boolean.valueOf(cancelableAttribute).booleanValue(); } this.delay = new AttributeOrValueChild(this.element, this.model, DELAY); this.delay.init(); }
From source file:com.github.dozermapper.core.classmap.Configuration.java
public Boolean getWildcardCaseInsensitive() { return wildcardCaseInsensitive != null ? wildcardCaseInsensitive : Boolean.valueOf(DozerConstants.DEFAULT_WILDCARD_CASE_INSENSITIVE_POLICY); }