List of usage examples for java.lang Boolean valueOf
public static Boolean valueOf(String s)
From source file:com.mncomunity1.gcm.MyGcmPushReceiver.java
/** * Called when message is received./*from w w w . j av a 2s.co m*/ * * @param from SenderID of the sender. * @param bundle Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ @Override public void onMessageReceived(String from, Bundle bundle) { String title = bundle.getString("title"); Boolean isBackground = Boolean.valueOf(bundle.getString("is_background")); String flag = bundle.getString("flag"); String data = bundle.getString("data"); Log.d(TAG, "From: " + from); Log.d(TAG, "title: " + title); Log.d(TAG, "isBackground: " + isBackground); Log.d(TAG, "flag: " + flag); Log.d(TAG, "data: " + data); if (flag == null) return; if (IsmartApp.getInstance().getPrefManager().getUser() == null) { // user is not logged in, skipping push notification Log.e(TAG, "user is not logged in, skipping push notification"); return; } if (from.startsWith("/topics/")) { // message received from some topic. } else { // normal downstream message. } switch (Integer.parseInt(flag)) { case Config.PUSH_TYPE_CHATROOM: // push notification belongs to a chat room processChatRoomPush(title, isBackground, data); break; case Config.PUSH_TYPE_USER: // push notification is specific to user processUserMessage(title, isBackground, data); break; } }
From source file:com.haulmont.cuba.gui.xml.layout.loaders.SuggestionFieldQueryLoader.java
protected void loadQuery(SuggestionField suggestionField, Element element) { Element queryElement = element.element("query"); if (queryElement != null) { final boolean escapeValue; String stringQuery = queryElement.getStringValue(); String searchFormat = queryElement.attributeValue("searchStringFormat"); String view = queryElement.attributeValue("view"); String escapeValueForLike = queryElement.attributeValue("escapeValueForLike"); if (StringUtils.isNotEmpty(escapeValueForLike)) { escapeValue = Boolean.valueOf(escapeValueForLike); } else {/*from w w w .ja v a 2 s . co m*/ escapeValue = false; } String entityClassName = queryElement.attributeValue("entityClass"); if (StringUtils.isNotEmpty(entityClassName)) { suggestionField.setSearchExecutor((searchString, searchParams) -> { DataSupplier supplier = suggestionField.getFrame().getDsContext().getDataSupplier(); Class<Entity> entityClass = ReflectionHelper.getClass(entityClassName); if (escapeValue) { searchString = QueryUtils.escapeForLike(searchString); } searchString = applySearchFormat(searchString, searchFormat); LoadContext loadContext = LoadContext.create(entityClass); if (StringUtils.isNotEmpty(view)) { loadContext.setView(view); } loadContext.setQuery( LoadContext.createQuery(stringQuery).setParameter("searchString", searchString)); //noinspection unchecked return supplier.loadList(loadContext); }); } else { throw new GuiDevelopmentException( String.format("Field 'entityClass' is empty in component %s.", suggestionField.getId()), getContext().getFullFrameId()); } } }
From source file:org.red5.server.Launcher.java
/** * Launch Red5 under it's own classloader *//*from w ww . j ava 2 s. c om*/ public void launch() { System.out.printf("Root: %s\nDeploy type: %s\nLogback selector: %s\n", System.getProperty("red5.root"), System.getProperty("red5.deployment.type"), System.getProperty("logback.ContextSelector")); try { // install the slf4j bridge (mostly for JUL logging) SLF4JBridgeHandler.install(); // we create the logger here so that it is instanced inside the expected classloader // check for the logback disable flag boolean useLogback = Boolean.valueOf(System.getProperty("useLogback", "true")); Red5LoggerFactory.setUseLogback(useLogback); // get the first logger Logger log = Red5LoggerFactory.getLogger(Launcher.class); // version info banner log.info("{} (http://code.google.com/p/red5/)", Red5.getVersion()); // pimp red5 System.out.printf("%s (http://code.google.com/p/red5/)\n", Red5.getVersion()); // create red5 app context FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext( new String[] { "classpath:/red5.xml" }, false); // set the current threads classloader as the loader for the factory/appctx ctx.setClassLoader(Thread.currentThread().getContextClassLoader()); // refresh must be called before accessing the bean factory ctx.refresh(); /* if (log.isTraceEnabled()) { String[] names = ctx.getBeanDefinitionNames(); for (String name : names) { log.trace("Bean name: {}", name); } } */ } catch (Throwable t) { System.out.printf("Exception %s\n", t); System.exit(9999); } }
From source file:com.wickettasks.business.services.user.TestUserService.java
public void testAddUser() { User user = null;/* w w w . j a v a2 s . c om*/ try { user = this.userService.add("test@email.com", "password"); } catch (ExistingUserException e) { e.printStackTrace(); } assertEquals(Boolean.TRUE, Boolean.valueOf(user != null)); }
From source file:Main.java
/** * convert value to given type.// w w w . j a va 2s .c o m * null safe. * * @param value value for convert * @param type will converted type * @return value while converted */ public static Object convertCompatibleType(Object value, Class<?> type) { if (value == null || type == null || type.isAssignableFrom(value.getClass())) { return value; } if (value instanceof String) { String string = (String) value; if (char.class.equals(type) || Character.class.equals(type)) { if (string.length() != 1) { throw new IllegalArgumentException(String.format("CAN NOT convert String(%s) to char!" + " when convert String to char, the String MUST only 1 char.", string)); } return string.charAt(0); } else if (type.isEnum()) { return Enum.valueOf((Class<Enum>) type, string); } else if (type == BigInteger.class) { return new BigInteger(string); } else if (type == BigDecimal.class) { return new BigDecimal(string); } else if (type == Short.class || type == short.class) { return Short.valueOf(string); } else if (type == Integer.class || type == int.class) { return Integer.valueOf(string); } else if (type == Long.class || type == long.class) { return Long.valueOf(string); } else if (type == Double.class || type == double.class) { return Double.valueOf(string); } else if (type == Float.class || type == float.class) { return Float.valueOf(string); } else if (type == Byte.class || type == byte.class) { return Byte.valueOf(string); } else if (type == Boolean.class || type == boolean.class) { return Boolean.valueOf(string); } else if (type == Date.class) { try { return new SimpleDateFormat(DATE_FORMAT).parse((String) value); } catch (ParseException e) { throw new IllegalStateException("Failed to parse date " + value + " by format " + DATE_FORMAT + ", cause: " + e.getMessage(), e); } } else if (type == Class.class) { return forName((String) value); } } else if (value instanceof Number) { Number number = (Number) value; if (type == byte.class || type == Byte.class) { return number.byteValue(); } else if (type == short.class || type == Short.class) { return number.shortValue(); } else if (type == int.class || type == Integer.class) { return number.intValue(); } else if (type == long.class || type == Long.class) { return number.longValue(); } else if (type == float.class || type == Float.class) { return number.floatValue(); } else if (type == double.class || type == Double.class) { return number.doubleValue(); } else if (type == BigInteger.class) { return BigInteger.valueOf(number.longValue()); } else if (type == BigDecimal.class) { return BigDecimal.valueOf(number.doubleValue()); } else if (type == Date.class) { return new Date(number.longValue()); } } else if (value instanceof Collection) { Collection collection = (Collection) value; if (type.isArray()) { int length = collection.size(); Object array = Array.newInstance(type.getComponentType(), length); int i = 0; for (Object item : collection) { Array.set(array, i++, item); } return array; } else if (!type.isInterface()) { try { Collection result = (Collection) type.newInstance(); result.addAll(collection); return result; } catch (Throwable e) { e.printStackTrace(); } } else if (type == List.class) { return new ArrayList<>(collection); } else if (type == Set.class) { return new HashSet<>(collection); } } else if (value.getClass().isArray() && Collection.class.isAssignableFrom(type)) { Collection collection; if (!type.isInterface()) { try { collection = (Collection) type.newInstance(); } catch (Throwable e) { collection = new ArrayList<>(); } } else if (type == Set.class) { collection = new HashSet<>(); } else { collection = new ArrayList<>(); } int length = Array.getLength(value); for (int i = 0; i < length; i++) { collection.add(Array.get(value, i)); } return collection; } return value; }
From source file:org.ow2.proactive_grid_cloud_portal.cli.cmd.rm.RemoveNodeCommand.java
public RemoveNodeCommand(String nodeUrl, String preempt) { this.nodeUrl = nodeUrl; this.preempt = Boolean.valueOf(preempt); }
From source file:com.android.prachat.gcm.MyGcmPushReceiver.java
/** * Called when message is received.// ww w . j av a 2s . co m * * @param from SenderID of the sender. * @param bundle Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ @Override public void onMessageReceived(String from, Bundle bundle) { String title = bundle.getString("title"); Boolean isBackground = Boolean.valueOf(bundle.getString("is_background")); String flag = bundle.getString("flag"); String data = bundle.getString("data"); Log.d(TAG, "From: " + from); Log.d(TAG, "title: " + title); Log.d(TAG, "isBackground: " + isBackground); Log.d(TAG, "flag: " + flag); Log.d(TAG, "data: " + data); if (flag == null) return; if (MyApplication.getInstance().getPrefManager().getUser() == null) { // user is not logged in, skipping push notification Log.e(TAG, "user is not logged in, skipping push notification"); return; } if (from.startsWith("/topics/")) { // message received from some topic. } else { // normal downstream message. } switch (Integer.parseInt(flag)) { case Config.PUSH_TYPE_CHATROOM: // push notification belongs to a chat room processChatRoomPush(title, isBackground, data); break; case Config.PUSH_TYPE_USER: // push notification is specific to user processUserMessage(title, isBackground, data); break; } }
From source file:net.sourceforge.fenixedu.presentationTier.Action.base.FenixContextDispatchAction.java
public static Boolean getFromRequestBoolean(String parameter, HttpServletRequest request) { return (request.getParameter(parameter) != null) ? Boolean.valueOf(request.getParameter(parameter)) : (Boolean) request.getAttribute(parameter); }
From source file:org.ow2.proactive_grid_cloud_portal.cli.cmd.rm.RemoveNodeSourceCommand.java
public RemoveNodeSourceCommand(String nodeSource, String preempt) { this.nodeSource = nodeSource; this.preempt = Boolean.valueOf(preempt); }
From source file:org.duracloud.duradmin.control.ContentItemDownloadController.java
@RequestMapping(value = "/download/contentItem", method = RequestMethod.GET) public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { String storeId = request.getParameter("storeID"); if (storeId == null) { storeId = request.getParameter("storeId"); }//from ww w . jav a 2 s . c om if (storeId == null) { storeId = controllerSupport.getContentStoreManager().getPrimaryContentStore().getStoreId(); } String spaceId = request.getParameter("spaceId"); String contentId = request.getParameter("contentId"); String attachment = request.getParameter("attachment"); if (Boolean.valueOf(attachment)) { StringBuffer contentDisposition = new StringBuffer(); contentDisposition.append("attachment;"); contentDisposition.append("filename=\""); contentDisposition.append(contentId); contentDisposition.append("\""); response.setHeader(CONTENT_DISPOSITION_HEADER, contentDisposition.toString()); } ContentStore store = controllerSupport.getContentStoreManager().getContentStore(storeId); try { SpaceUtil.streamContent(store, response, spaceId, contentId); } catch (ContentStoreException ex) { if (response.containsHeader(CONTENT_DISPOSITION_HEADER)) { response.setHeader(CONTENT_DISPOSITION_HEADER, null); } if (ex instanceof ContentStateException) { response.setStatus(HttpStatus.SC_CONFLICT); } else if (ex instanceof UnauthorizedException) { response.setStatus(HttpStatus.SC_UNAUTHORIZED); } Throwable t = ex; if (t.getCause() != null) { t = ex.getCause(); } response.getWriter().println(t.getMessage()); } return null; }