List of usage examples for java.lang Long parseLong
public static long parseLong(String s) throws NumberFormatException
From source file:ispok.helper.SeriesLazyDataModel.java
@Override public SeriesDto getRowData(String rowKey) { return seriesService.getSeriesById(Long.parseLong(rowKey)); }
From source file:de.lava.marvin.whaosleaguepersistence.dao.impl.BaseDaoImpl.java
@Override public T read(Class<T> entityClass, String id) { return entityManager.find(entityClass, Long.parseLong(id)); }
From source file:com.astamuse.asta4d.data.convertor.String2Long.java
@Override public Long convert(String s) throws UnsupportedValueException { if (StringUtils.isEmpty(s)) { return null; }/*from ww w.j a v a 2s . c o m*/ try { return Long.parseLong(s); } catch (NumberFormatException nfe) { throw new UnsupportedValueException(); } }
From source file:com.mycompany.CRMFly.Converters.ContactConverter.java
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { Long id = Long.parseLong(value.split(" ")[0]); return contactBean.getContactForId(id); }
From source file:org.commonjava.maven.galley.transport.htcli.util.HttpUtil.java
public static long getContentLength(CloseableHttpResponse response) { if (response == null) { return -1; }// ww w .j a v a 2s. c o m Header header = response.getFirstHeader(CONTENT_LENGTH); return header == null ? 0 : Long.parseLong(header.getValue()); }
From source file:com.bdnc.ecommercebdnc.command.PerfilProduto.java
@Override public void execute(HttpServletRequest request, HttpServletResponse response) { try {/*from w w w . ja va 2s . c o m*/ LojaService lojaService = new LojaService(); Produto produto = lojaService.buscarProduto(Long.parseLong(request.getParameter("idProduto"))); request.setAttribute("produto", produto); request.setAttribute("produtosSugeridos", lojaService.buscarProdutosSugeridos(produto)); RequestDispatcher dispather = request.getRequestDispatcher("produto.jsp"); dispather.forward(request, response); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.glaf.jbpm.util.CustomFieldInstantiator.java
public static Object getValue(Class<?> type, Element propertyElement) { Object value = null;/*from w w w.j av a2s. c om*/ if (type == String.class) { value = propertyElement.getText(); } else if ((type == Integer.class) || (type == int.class)) { value = Integer.parseInt(propertyElement.getTextTrim()); } else if ((type == Long.class) || (type == long.class)) { value = Long.parseLong(propertyElement.getTextTrim()); } else if ((type == Float.class) || (type == float.class)) { value = new Float(propertyElement.getTextTrim()); } else if ((type == Double.class) || (type == double.class)) { value = Double.parseDouble(propertyElement.getTextTrim()); } else if ((type == Boolean.class) || (type == boolean.class)) { value = Boolean.valueOf(propertyElement.getTextTrim()); } else if ((type == Character.class) || (type == char.class)) { value = Character.valueOf(propertyElement.getTextTrim().charAt(0)); } else if ((type == Short.class) || (type == short.class)) { value = Short.valueOf(propertyElement.getTextTrim()); } else if ((type == Byte.class) || (type == byte.class)) { value = Byte.valueOf(propertyElement.getTextTrim()); } else if (type.isAssignableFrom(java.util.Date.class)) { value = DateUtils.toDate(propertyElement.getTextTrim()); } else if (type.isAssignableFrom(List.class)) { value = getCollectionValue(propertyElement, new java.util.ArrayList<Object>()); } else if (type.isAssignableFrom(Set.class)) { value = getCollectionValue(propertyElement, new LinkedHashSet<Object>()); } else if (type.isAssignableFrom(Collection.class)) { value = getCollectionValue(propertyElement, new java.util.ArrayList<Object>()); } else if (type.isAssignableFrom(Map.class)) { value = getMapValue(propertyElement, new LinkedHashMap<Object, Object>()); } else if (type == Element.class) { value = propertyElement; } else { try { Constructor<?> constructor = type.getConstructor(new Class[] { String.class }); if ((propertyElement.isTextOnly()) && (constructor != null)) { value = constructor.newInstance(new Object[] { propertyElement.getTextTrim() }); } } catch (Exception ex) { logger.error("couldn't parse the bean property value '" + propertyElement.asXML() + "' to a '" + type.getName() + "'"); throw new RuntimeException(ex); } } return value; }
From source file:uk.ac.ebi.intact.editor.config.property.LongPropertyConverter.java
@Override public Long convertFromString(String str) { if (str == null) return null; return Long.parseLong(str); }
From source file:com.esri.geoportal.harvester.api.base.SimpleScrambler.java
/** * Decodes string./*from ww w. j a v a2 s .c o m*/ * @param encoded encoded string to decode * @return decoded string or <code>null</code> if error decoding string */ public static String decode(String encoded) { try { encoded = StringUtils.defaultIfEmpty(encoded, ""); Base64.Decoder decoder = Base64.getDecoder(); String crctxt = new String(decoder.decode(encoded), "UTF-8"); if (crctxt.length() < 10) { return null; } long crc = Long.parseLong(StringUtils.trimToEmpty(crctxt.substring(0, 10))); String txt = crctxt.substring(10); CRC32 crC32 = new CRC32(); crC32.update(txt.getBytes("UTF-8")); if (crc != crC32.getValue()) { return null; } return txt; } catch (NumberFormatException | UnsupportedEncodingException ex) { return null; } }
From source file:com.mycompany.springrest.token.JwtUtil.java
/** * Tries to parse specified String as a JWT token. If successful, returns User object with username, id and role prefilled (extracted from token). * If unsuccessful (token is invalid or not containing all required user properties), simply returns null. * // w ww.j av a 2 s .c o m * @param token the JWT token to parse * @return the User object extracted from specified token or null if a token is invalid. */ public User parseToken(String token) { try { Claims body = Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody(); User u = new User(); u.setUsername(body.getSubject()); u.setId(Long.parseLong((String) body.get("userId"))); u.setRole((String) body.get("role")); return u; } catch (JwtException | ClassCastException e) { return null; } }