List of usage examples for java.lang Boolean parseBoolean
public static boolean parseBoolean(String s)
From source file:com.kijes.ela.common.JSONSerializers.java
public static ElaUser userFromJson(JSONObject jsonUser) throws InvalidDataException { String userId = jsonUser.getString(ElaUser.PROPERTY_USER_ID); String cardId = jsonUser.getString(ElaUser.PROPERTY_CARD_ID); String enteredArea = jsonUser.getString(ElaUser.PROPERTY_ENTERED_AREA); if (userId == null) { throw new InvalidDataException("Invalid " + ElaUser.PROPERTY_USER_ID); }/*from w w w . j a va2 s .c om*/ if (cardId == null) { throw new InvalidDataException("Invalid " + ElaUser.PROPERTY_CARD_ID); } if (enteredArea != null) { return new ElaUser(userId, cardId, Boolean.parseBoolean(enteredArea)); } return new ElaUser(userId, cardId); }
From source file:com.omertron.yamjtrakttv.tools.CompleteMoviesTools.java
/** * Parse the video element and extract the information from it. * * @param eVideo//from ww w .j a v a 2s .c o m * @return */ public static Video parseVideo(Element eVideo) { Video v = new Video(); v.setTitle(DOMHelper.getValueFromElement(eVideo, "title")); v.setYear(DOMHelper.getValueFromElement(eVideo, "year")); v.setType(DOMHelper.getValueFromElement(eVideo, "movieType")); v.setWatched(Boolean.parseBoolean(DOMHelper.getValueFromElement(eVideo, "watched"))); String stringDate = DOMHelper.getValueFromElement(eVideo, "watchedDate"); if (StringUtils.isNumeric(stringDate) && !"0".equals(stringDate)) { v.setWatchedDate(new Date(Long.parseLong(stringDate))); } else { LOG.debug("Invalid watched date '" + stringDate + "' using current date"); v.setWatchedDate(new Date()); // Because the date was set by us, let's add a small (1 second) delay to ensure that we don't get identical watched dates try { TimeUnit.SECONDS.sleep(DEFAULT_DELAY); } catch (InterruptedException ex) { // Don't care if we are interrupted or not. } } NodeList nlID = eVideo.getElementsByTagName("id"); if (nlID.getLength() > 0) { Node nID; Element eID; for (int loop = 0; loop < nlID.getLength(); loop++) { nID = nlID.item(loop); if (nID.getNodeType() == Node.ELEMENT_NODE) { eID = (Element) nID; String moviedb = eID.getAttribute("movieDatabase"); if (StringUtils.isNotBlank(moviedb)) { v.addId(moviedb, eID.getTextContent()); } } } } // TV specific processing if (v.isTvshow()) { v.addEpisodes(parseTvFiles(eVideo)); } return v; }
From source file:it.unibas.spicy.persistence.Types.java
public static Object getTypedValue(String type, Object value) throws DAOException { if (value == null || value.toString().equalsIgnoreCase("NULL")) { return NullValueFactory.getNullValue(); }/* w w w .ja v a 2s .c om*/ if (type.equals(BOOLEAN)) { return Boolean.parseBoolean(value.toString()); } if (type.equals(STRING)) { return value.toString(); } if (type.equals(INTEGER)) { try { return Integer.parseInt(value.toString()); } catch (NumberFormatException ex) { logger.error(ex); throw new DAOException(ex.getMessage()); } } if (type.equals(DOUBLE)) { try { return Double.parseDouble(value.toString()); } catch (NumberFormatException ex) { logger.error(ex); throw new DAOException(ex.getMessage()); } } if (type.equals(FLOAT)) { try { return Float.parseFloat(value.toString()); } catch (NumberFormatException ex) { logger.error(ex); throw new DAOException(ex.getMessage()); } } if (type.equals(DATE) || type.equals(DATETIME)) { return value.toString(); // try { // return DateFormat.getDateInstance().parse(value.toString()); // } catch (ParseException ex) { // logger.error(ex); // throw new DAOException(ex.getMessage()); // } } return value.toString(); }
From source file:org.apache.batchee.jackson.Jacksons.java
public static ObjectMapper newMapper(final String config) { final ObjectMapper mapper = new ObjectMapper(); if (config != null) { final String deserializationName = DeserializationFeature.class.getSimpleName(); final String serializationName = SerializationFeature.class.getSimpleName(); final String mapperName = MapperFeature.class.getSimpleName(); for (final String conf : config.split(",")) { final String[] parts = conf.split("="); parts[0] = parts[0].trim();//from w w w . jav a2s. c o m parts[1] = parts[1].trim(); if (parts[0].startsWith(deserializationName)) { mapper.configure( DeserializationFeature.valueOf(parts[0].substring(deserializationName.length() + 1)), Boolean.parseBoolean(parts[1])); } else if (parts[0].startsWith(serializationName)) { mapper.configure( SerializationFeature.valueOf(parts[0].substring(serializationName.length() + 1)), Boolean.parseBoolean(parts[1])); } else if (parts[0].startsWith(mapperName)) { mapper.configure(MapperFeature.valueOf(parts[0].substring(mapperName.length() + 1)), Boolean.parseBoolean(parts[1])); } else { throw new IllegalArgumentException("Ignored config: " + conf); } } } return mapper; }
From source file:eu.eidas.node.ApplicationContextProvider.java
private static void setGlobalAppContext(ApplicationContext ctx) { applicationContext = ctx;/* w w w . j ava 2 s.c o m*/ booleanMap = new HashMap<String, Boolean>(); //check production flag AUSERVICEUtil util = ApplicationContextProvider.getApplicationContext().getBean(AUSERVICEUtil.class); if (Boolean.parseBoolean(util.getConfigs().getProperty(EIDASValues.EIDAS_PRODUCTION.toString()))) { resetParamsForProduction(util.getConfigs()); } }
From source file:com.astamuse.asta4d.data.convertor.String2Bool.java
@Override public Boolean convert(String s) throws UnsupportedValueException { if (StringUtils.isEmpty(s)) { return null; } else {//from w w w .j a v a 2 s . c o m return Boolean.parseBoolean(s); } }
From source file:kenh.expl.functions.Not.java
public boolean process(String bs) { try {/*from w w w .jav a 2s. co m*/ boolean b = Boolean.parseBoolean(bs); return !b; } catch (Exception e) { return false; } }
From source file:org.zht.framework.util.ZBeanUtil.java
public static Boolean parseBoolean(Object value) { try {//from www . j a va 2 s.c o m return Boolean.parseBoolean((String) value); } catch (Exception e) { return null; } }
From source file:lineage2.gameserver.utils.XMLUtil.java
/** * Method getAttributeBooleanValue./*from w w w . j a va2 s . co m*/ * @param n Node * @param item String * @param dflt boolean * @return boolean */ public static boolean getAttributeBooleanValue(Node n, String item, boolean dflt) { final Node d = n.getAttributes().getNamedItem(item); if (d == null) { return dflt; } final String val = d.getNodeValue(); if (val == null) { return dflt; } return Boolean.parseBoolean(val); }
From source file:org.terasoluna.gfw.web.util.JspTagUtils.java
/** * Convert to the Boolean value./*from www . j a va 2 s . c om*/ * @param attributeValue string value of attribute * @param defaultValue If attribute value is not text(null or blank or whitespace only), apply this value. * @param attributeName attribute name (If attribute value is not true or false, sets in exception message) * @return converted Boolean value * @throws JspTagException If value that is not true or false is specified. */ public static boolean toBoolean(String attributeValue, boolean defaultValue, String attributeName) throws JspTagException { if (StringUtils.hasText(attributeValue)) { if ("true".equalsIgnoreCase(attributeValue) || "false".equalsIgnoreCase(attributeValue)) { return Boolean.parseBoolean(attributeValue); } else { throw new JspTagException("The value of " + attributeName + " must be either true or false."); } } return defaultValue; }