List of usage examples for java.lang Boolean parseBoolean
public static boolean parseBoolean(String s)
From source file:gov.nih.nci.security.util.StringEncrypter.java
public StringEncrypter(String encryptionScheme) throws EncryptionException { if (encryptionScheme != null && encryptionScheme.equals(Constants.DES_ENCRYPTION)) encryption = new DESEncryption(); else {/* w ww.j a va2s . c om*/ DataConfiguration config = null; try { config = ConfigurationHelper.getConfiguration(); } catch (CSConfigurationException e) { e.printStackTrace(); } encryption = new AESEncryption(config.getString("AES_ENCRYPTION_KEY"), Boolean.parseBoolean(config.getString("MD5_HASH_KEY"))); } }
From source file:com.shz.foundation.service.dynamic.DynamicSpecifications.java
public static <T> Specification<T> bySearchFilter(final Collection<SearchFilter> filters, final Class<T> entityClazz) { return new Specification<T>() { @Override/* ww w .j a v a2 s . c o m*/ public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) { if (Collections3.isNotEmpty(filters)) { List<Predicate> predicates = Lists.newArrayList(); for (SearchFilter filter : filters) { // nested path translate, Task??"user.name"filedName, ?Task.user.name String[] names = StringUtils.split(filter.fieldName, "."); Path expression = root.get(names[0]); for (int i = 1; i < names.length; i++) { expression = expression.get(names[i]); } // logic operator switch (filter.operator) { case EQ: //?? Object value = filter.value; if (isBoolean(value)) { value = Boolean.parseBoolean(value.toString()); } predicates.add(builder.equal(expression, value)); break; case LIKE: predicates.add(builder.like(expression, "%" + filter.value + "%")); break; case GT: predicates.add(builder.greaterThan(expression, (Comparable) filter.value)); break; case LT: predicates.add(builder.lessThan(expression, (Comparable) filter.value)); break; case GTE: predicates.add(builder.greaterThanOrEqualTo(expression, (Comparable) filter.value)); break; case LTE: predicates.add(builder.lessThanOrEqualTo(expression, (Comparable) filter.value)); break; } } // ? and ??? if (!predicates.isEmpty()) { return builder.and(predicates.toArray(new Predicate[predicates.size()])); } } return builder.conjunction(); } private boolean isBoolean(Object value) { String valueString = value.toString().toLowerCase(); if (valueString.equals("true") || valueString.equals("false")) return true; return false; } }; }
From source file:Main.java
public static Object getNamedElemValue(Element parent, String elementName, Class basicType, Object defaultVal) { String val = getNamedElemValue(parent, elementName); if (val == null) { return defaultVal; }// w w w . j a v a 2s .c o m try { if (Boolean.class.equals(basicType)) { return Boolean.parseBoolean(val); } else if (Integer.class.equals(basicType)) { return Integer.parseInt(val); } else if (Float.class.equals(basicType)) { return Float.parseFloat(val); } else if (Double.class.equals(basicType)) { return Double.parseDouble(val); } else return val; } catch (Exception e) { return defaultVal; } }
From source file:org.os890.ds.addon.spring.impl.DefaultBeanFilter.java
public DefaultBeanFilter() { this.exposeDeltaSpikeBeans = Boolean .parseBoolean(ConfigResolver.getPropertyValue("exposeDeltaSpikeBeansToSpring", "true")); this.exposeInternalSpringBeans = Boolean .parseBoolean(ConfigResolver.getPropertyValue("exposeInternalSpringBeansToCdi", "false")); }
From source file:com.haulmont.bali.util.Dom4j.java
private static SAXReader getSaxReader() { String useThreadLocalCache = System.getProperty("cuba.saxParserThreadLocalCache"); if (useThreadLocalCache == null || Boolean.parseBoolean(useThreadLocalCache)) { try {/*from www . ja v a2 s . c o m*/ return new SAXReader(getParser().getXMLReader()); } catch (SAXException e) { throw new RuntimeException("Unable to create SAX reader", e); } } else { return new SAXReader(); } }
From source file:de.hstsoft.sdeep.Configuration.java
public void load() throws IOException, ParseException { Reader reader = new BufferedReader(new FileReader(configFile)); JSONParser jsonParser = new JSONParser(); JSONObject json = (JSONObject) jsonParser.parse(reader); saveGamePath = json.get(PREF_SAVEGAME_PATH).toString(); autorefresh = Boolean.parseBoolean(json.get(PREF_AUTOREFRESH).toString()); reader.close();/* www .ja va2 s . com*/ }
From source file:jlg.jade.example.DatagramConvertor.java
DatagramConvertor(BlockingQueue<byte[]> rawQueue, String[] args) { this.rawQueue = rawQueue; this.logger = LogFactory.getLog("jlg.jade"); this.isLogEnabled = Boolean.parseBoolean(args[1]); this.allowedCategories = args[3]; }
From source file:com.prey.json.actions.Setting.java
public void update(Context ctx, List<ActionResult> lista, JSONObject parameters) { try {//from w w w. j ava2s .com String key = parameters.getString("key"); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(ctx); SharedPreferences.Editor editor = settings.edit(); String value = parameters.getString("value"); if (StringUtil.isTextBoolean(value)) { editor.putBoolean(key, Boolean.parseBoolean(value)); } else { if (StringUtil.isTextInteger(value)) { editor.putInt(key, Integer.parseInt(value)); } else { editor.putString(key, value); } } editor.commit(); } catch (JSONException e) { PreyLogger.e("Error, causa:" + e.getMessage(), e); } }
From source file:com.haulmont.cuba.gui.xml.layout.loaders.PasswordFieldLoader.java
@Override public void loadComponent() { super.loadComponent(); loadMaxLength(resultComponent, element); String autocomplete = element.attributeValue("autocomplete"); if (StringUtils.isNotEmpty(autocomplete)) { resultComponent.setAutocomplete(Boolean.parseBoolean(autocomplete)); }/*from w w w .ja v a 2 s. co m*/ }
From source file:com.haulmont.cuba.gui.xml.layout.loaders.ResizableTextAreaLoader.java
@Override public void loadComponent() { super.loadComponent(); ResizableTextArea textArea = (ResizableTextArea) resultComponent; String resizable = element.attributeValue("resizable"); if (StringUtils.isNotEmpty(resizable)) { textArea.setResizable(Boolean.parseBoolean(resizable)); }/*from ww w. j a v a 2s.c o m*/ String resizableDirection = element.attributeValue("resizableDirection"); if (StringUtils.isNotEmpty(resizableDirection)) { textArea.setResizableDirection(ResizableTextArea.ResizeDirection.valueOf(resizableDirection)); } loadSettingsEnabled(textArea, element); }